AskApache Google 404
Broken in 3.5? (2 posts)

  1. rrhobbs
    Posted 3 years ago #

    My PHP Error Log is filling up fast with this since I updated WP to 3.5:
    [12-Dec-2012 02:28:52 UTC] PHP Warning: Missing argument 2 for wpdb::prepare(), called in /home/usr/public_html/wp-content/plugins/askapache-google-404/askapache-google-404.php on line 1017 and defined in /home/usr/public_html/wp-includes/wp-db.php on line 990

    Googling wpdb prepare: http://apeatling.wordpress.com/2008/06/25/prepare-dont-escape/


  2. Melbourne Cup Sweep
    Posted 3 years ago #

    The latest wordpress update has revealed this slight error in a lot of plugins. It doesnt prevent the plugin from working but a lot of website servers are configured to show errors like this on page. You can change your php.ini config to not show these errors.

    I'm no coder but seem to have solved the issue in the plugin buy changing the error on line 1017 of askapache-google-404.php from

    $results = $wpdb->get_results($wpdb->prepare($sql));


    $results = $wpdb->get_results($wpdb->prepare($sql,$terms,$limit));

    On line 1014 is the database query used by line 1017

    $sql = "SELECT ID, post_title, post_content, MATCH (post_title, post_content) AGAINST ('{$terms}') AS score FROM {$wpdb->posts} WHERE MATCH (post_title, post_content) AGAINST ('{$terms}') " .
    		"AND post_type = 'post' AND post_status = 'publish' AND post_password = '' AND post_date < '" . current_time('mysql') . "' ORDER BY score DESC LIMIT {$limit}";

    $sql is a placeholder of an sql query used to get the related posts.

    $terms and $limit are placeholders used in the $sql database query

    I just added them to the $wpdb->prepare() and it seems to have worked.

    The error issue is discussed at http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • AskApache Google 404
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic