WordPress.org

Forums

Simple Comment Editing
[resolved] Bug when editing a published comment (7 posts)

  1. FolioVision
    Member
    Posted 1 year ago #

    Hello,

    this is a nice and quick plugin, however you should not use

    $comment_to_save['comment_approved'] == 'spam'

    As that is true even if $comment_to_save['comment_approved'] is 0. When editing a published comment it results in the "This comment was marked as spam" error message.

    Please use this condition and issue a plugin update:

    strcmp('spam',$comment_to_save['comment_approved']) == 0

    Thanks,
    Martin

    http://wordpress.org/plugins/simple-comment-editing/

  2. Ronald Huereca
    Member
    Plugin Author

    Posted 1 year ago #

    Are you talking about the line:
    if ( $comment_to_save['comment_approved'] == 'spam' ) {

    How would that default to true if the comment is marked as 0?

  3. FolioVision
    Member
    Posted 1 year ago #

    Hello Ronald,

    you should be using strcmp() or === instead of just ==. You can try the following example:

    <?php
    var_dump(0=='spam');  //  true - not what we want
    var_dump(0==='spam'); //   false - correct!
    var_dump('spam'==='spam');  //  true - correct! This is the one to use
    var_dump('SPAM'==='spam');  //  false - because the case doesn't match
    var_dump(strcasecmp('SPAM','spam'));  //  0 - correct
    ?>

    Thanks,
    Martin

  4. Ronald Huereca
    Member
    Plugin Author

    Posted 1 year ago #

    I'll be damned. I'll push out an update soon. Thanks.

  5. Ronald Huereca
    Member
    Plugin Author

    Posted 1 year ago #

    I just pushed 1.1.1 with the fix. Thanks for the help.

  6. ghacks
    Member
    Posted 1 year ago #

    I seem to have a related problem. Some comments are marked as spam on my site after they have been edited even though that should not be the case.

    I cannot really say why this is happening, but it is happening especially when someone posts a long comment on the site and then edits it.

    An example is this comment: http://www.ghacks.net/2014/02/21/telegram-questions-answered-whatsapp-messenger-alternative/#comment-1993903

    It was marked as spam and I had to move it mark it as legit so that it would appear on the site.

  7. Ronald Huereca
    Member
    Plugin Author

    Posted 1 year ago #

    ghacks, since this post is resolved, let's move it to this thread: https://wordpress.org/support/topic/comments-marked-as-spam-when-editing

    I'll do my own internal testing to see if I can duplicate the problem.

    An edited comment is run through several checks, notably a check_comment check, a wp_blacklist_check, and if Akismet is installed, it checks it there too. If you're familiar with code, it's all in the ajax_save_comment method.

    Just let me know if there's any way to duplicate it consistently. I'll do checks on my end as well.

    Sorry about the inconvenience.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.