• Resolved brunswickmedia

    (@brunswickmedia)


    I’m getting a WordPress database error after updating WP to 4.6.1 and CAS to 3.3.2. It’s very similar to the problem described here:

    https://www.ads-software.com/support/topic/database-error-message-9/

    But no solution was posted, just that the issue was resolved.

    Error Message:

    WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘)) AND (taxonomy.meta_value IS NULL OR taxonomy.meta_value IN(‘category’,’post_t’ at line 3 for query SELECT p.ID, p.post_parent FROM cij_posts p LEFT JOIN cij_postmeta post_type ON post_type.post_id = p.ID AND post_type.meta_key = ‘_ca_post_type’ LEFT JOIN cij_postmeta author ON author.post_id = p.ID AND author.meta_key = ‘_ca_author’ LEFT JOIN cij_postmeta taxonomy ON taxonomy.post_id = p.ID AND taxonomy.meta_key = ‘_ca_taxonomy’ LEFT JOIN cij_term_relationships term ON term.object_id = p.ID
    WHERE
    (post_type.meta_value IS NULL OR post_type.meta_value IN (‘column’,’7364′)) AND (author.meta_value IS NULL OR author.meta_value IN (‘author’,’7′)) AND (term.term_taxonomy_id IS NULL OR term.term_taxonomy_id IN (862,864,936,1429,1254,746,764,931,1428,1427,875,999,54,1421,1217,1423,1422,977,1425,1426,1424,1430,)) AND (taxonomy.meta_value IS NULL OR taxonomy.meta_value IN(‘category’,’post_tag’,’lead_author’,’_ca_sub_category’,’_ca_sub_post_tag’,’_ca_sub_lead_author’)) AND p.post_type = ‘condition_group’ AND p.post_status IN (‘publish’,’negated’)
    made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/FST2015/single.php’), get_template_part, locate_template, load_template, require(‘/themes/FST2015/header-business-analysis.php’), display_ca_sidebar, ca_display_sidebar, CAS_Sidebar_Manager->manual_sidebar, WPCACore::get_posts, WPCACore::get_conditions

    The sidebar that is throwing this message is set to replace 1 Category, Exposure: Singular & Archive; Handle: Manual.

    I’ve tried rolling back to the previously installed version of CAS, but that did not change anything.

    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Joachim Jensen

    (@intoxstudio)

    Thanks for reporting this and for the SQL details.

    It looks like some posts have dissappeared in the thread you are referring to. The problem back then was caused when a post had no taxonomies.

    Looking at:

    term.term_taxonomy_id IN
    (862,864,936,1429,1254,746,764,931,1428,1427,875,999,54,1421,1217,1423,1422,977,1425,1426,1424,1430,)

    It looks like the post being viewed has a taxonomy (category, tag or “lead author”) with an empty ID, which makes the list end with a comma. That is very strange though. What plugin are you using for the “lead author” taxonomy?

    If possible, try to go to wp-content\plugins\content-aware-sidebars\lib\wp-content-aware-engine\module\taxonomy.php and change line 147-149 with:

    foreach($this->post_terms as $term) {
    	if($term->term_taxonomy_id) {
    		$terms[] = $term->term_taxonomy_id;
    	}
    }
    Thread Starter brunswickmedia

    (@brunswickmedia)

    Thanks for getting back so quickly Joachim!

    I’m using a plugin called CPT-onomies (https://www.ads-software.com/plugins/cpt-onomies/) to create the lead authors. Basically this is an industry news site with multiple authors on many articles, not quite academic papers, but in many cases there are 2 or more authors. CPT-onomies allows me to create CPT’s that behave more like taxonomies, providing native archives, etc.

    I swapped out the code you provided, and that has fixed the problem!

    This is very odd because I tested all of these updates on my development site before updating the live production site, and did not have this issue. There were some issues between CPT-onomies and WordPress 4.6 that caused problems with the terms being pulled from the tables, in my case, author names were replaced by random tags, but the plugin author just released an update a few days ago.

    In any case, this fix has solved the issue. Is this something that will be issued as a general fix, or should I keep a copy of this on-hand to replace for future updates on my own sites?

    Plugin Author Joachim Jensen

    (@intoxstudio)

    Good to hear that it worked!

    Terms with no term_taxonomy_id should never happen, so it does sound like you’ve experienced some data corruption during the update/migration process. Unfortunately for this reason I will not add it as a general fix, because in the long run it would get tedious to make sanity checks on IDs.

    Also because some of your terms have no ID, they might cause strange behaviour, not only in this plugin, but many others. I recommend that you investigate your database to see which terms are missing IDs and perhaps restore from a previous backup.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WordPress database error’ is closed to new replies.