• Since a few times, this really great plugin was failing to move comments.

    It was returning the error Uncaught ArgumentCountError: Too few arguments to function wpdb::prepare()

    The fix is really simple. Go to your WordPress Dashboard, under the menu “Plugins”, select the “Plugin Editor”. Next, top-right, select “plugin to edit:” = “Move WordPress Comment” and click “Select”.

    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" ) );
    			}
    • This topic was modified 4 years, 3 months ago by vletroye.
  • The topic ‘Uncaught ArgumentCountError: Too few arguments to function wpdb::prepare()’ is closed to new replies.