Plugin "Move WordPress Comment" not working anymore

I just noticed that this really great plugin "Move WordPress Comment" was failing when trying to move comments. Fortunately, the fix was easy.

Click to Read More

This plugin is very useful when you started a discussion thread (I.e.: you reply on a comment), but the person does not answer on the last comment. Instead, he starts a new comment. In such a case, the plugin can be used to move his last comment under the last reply in the discussion thread;

Example, here under, I could attach the second discussion thread under the last reply of the first discussion thread by typing the id #46705 of that last reply into the "parent comment" of the first comment #46719 of the second discussion thread and clicking "Move".

Unfortunately, this plugin is now returning an error "Uncaught ArgumentCountError: Too few arguments to function wpdb::prepare()"

The fix is really simple. Go to your WordPress Dashboard, under the menu "Plugins" and select the "Plugin Editor".

Next, in the top-right corner, set "select plugin to edit" = "Move WordPress Comment" and click "Select".

Then, go to line 63 or search for "prepare". This methods requires 2 parameters. So, in the where clauses of the SQL Update statements, replace the variables by %s and move the variables into a second parameters.

It should result into this:

// move to different post
if ( $postID != $oldpostID ) {
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->comments SET comment_post_ID=$postID WHERE comment_ID=%s;", "$commentID") );

// Change post count
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET comment_count=comment_count+1 WHERE ID=%s", "$postID" ) );
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET comment_count=comment_count-1 WHERE ID=%s", "$oldpostID" ) );
}

// move to different parent
if ( $parentID != $commentID ) {
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->comments SET comment_parent=$parentID WHERE comment_ID=%s;", "$commentID" ) );
}

Finally, click on "Update File", at the bottom of the Plugin Editor.

Et voilĂ ,

Leave a Reply

Your email address will not be published. Required fields are marked *