Support » Plugin: XML Sitemaps » SQL query bug in Google XML Sitemaps v. 4.1.4

  • There’s an SQL query bug in version 4.1.4 of the Google XML Sitemaps plug-in. I’ve posted the PHP error message below. It looks like it should just be a case of putting quotes around the p.post_type value on line 190 of class-googlesitemapgeneratorstandardbuilder.php.

    WordPress database error Unknown column 'post' in 'where clause' for query SELECT
    									COUNT(*)
    								FROM
    									wp_posts p
    								WHERE
    									p.post_password = ''
    									AND p.post_type = post
    									AND p.post_status = 'publish'
    									AND p.ID NOT IN (103)  made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), do_action('template_redirect'), WP_Hook->do_action, WP_Hook->apply_filters, GoogleSitemapGeneratorLoader::do_template_redirect, GoogleSitemapGeneratorLoader::call_show_sitemap, GoogleSitemapGenerator->show_sitemap, do_action('sm_build_content'), WP_Hook->do_action, WP_Hook->apply_filters, GoogleSitemapGeneratorStandardBuilder->content, GoogleSitemapGeneratorStandardBuilder->build_posts
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter nexbridge

    (@nexbridge)

    UPDATE: Even when you apply the above fix, the same query then triggers the error below due to it being a prepared statement with no placeholders for variables.

    Function wpdb::prepare was called <strong>incorrectly</strong>. The query argument of wpdb::prepare() must have a placeholder. Please see <a href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 3.9.0.) in /var/www/bulksmsdelivery.com/wp-includes/functions.php on line 5831

    A better fix would therefore be to add a placeholder for the value of p.post_type and add the value as the second argument of wpdb::prepare().

    Thread Starter nexbridge

    (@nexbridge)

    UPDATE: Having applied the above fix, I’m now getting a similar issue reported for the following query (around line 800 in the same file), for which I imagine the same fix will work.

    "SELECT
    	YEAR(p.post_date_gmt) AS <code>year</code>,
    	MONTH(p.post_date_gmt) AS <code>month</code>,
    	COUNT(p.ID) AS <code>numposts</code>,
    	MAX(p.post_modified_gmt) as <code>last_mod</code>
    	FROM
    		{$wpdb->posts} p
    	WHERE
    		p.post_password = ''
    		AND p.post_type = '" . esc_sql( $post_type_custom ) . "'
    		AND p.post_status = 'publish'
    		" . $ex_post_s_q_l . ''
    		. $ex_cat_s_q_l . "
    	GROUP BY
    		YEAR(p.post_date_gmt),
    		MONTH(p.post_date_gmt)
    	ORDER BY
    		p.post_date_gmt DESC"

    Version 4.1.4 didn’t fix the items it specifically stated it did, in fact it made it worse and it has been over a week without even a response from the developer. This sitemap worked great for literally years – what is going on?

    The only option currently, to avoid all the current bugs is to downgrade to 4.1.1.

    Plugin Author Auctollo

    (@auctollo)

    We believe that this issue is fixed in the latest release, now generally available. Please let us know if everything is working as expected.

    LX T

    (@lxt)

    @auctollo no, it’s not fixed in 4.1.5. We had to downgrade to 4.1.1 as well!

    Plugin Author Auctollo

    (@auctollo)

    @lxt: Please share some more information and if possible provide the error details by looking into the error logs. Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.