[wp-trac] [WordPress Trac] #34992: update_meta_cache() fails for 'term' meta type

WordPress Trac noreply at wordpress.org
Thu Dec 10 22:18:43 UTC 2015


#34992: update_meta_cache() fails for 'term' meta type
--------------------------------+-----------------------------
 Reporter:  doublesharp         |      Owner:
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Options, Meta APIs  |    Version:  4.4
 Severity:  normal              |   Keywords:
  Focuses:                      |
--------------------------------+-----------------------------
 After the update to WordPress 4.4 I began seeing lots of error messages in
 my logs like the following:

 >[10-Dec-2015 13:41:14 America/Los_Angeles] WordPress database error
 '''Unknown column 'meta_id' in 'order clause' for query SELECT term_id,
 meta_key, meta_value FROM wp_termmeta WHERE term_id IN (6) ORDER BY
 meta_id ASC''' made by require('wp-blog-header.php'), require_once('wp-
 includes/template-loader.php'), include('/themes/my_theme/page.php'),
 dynamic_sidebar, call_user_func_array, WP_Widget->display_callback,
 LocationBased_Featured_Listings_Widget-
 >widget, get_permalink, get_the_category, get_the_terms,
 wp_get_object_terms, update_termmeta_cache, update_meta_cache,
 W3_Db->query, W3_DbCache->query, W3_DbCallUnderlying->query, W3_Db->query,
 W3_DbProcessor->query, W3_Db->default_query

 Looking at the `update_meta_cache()` method it looks like the new "term"
 meta type is not using the correct "$id_colum". From line 820 in meta.php

 {{{#!php
 // Get meta info
 $id_list = join( ',', $ids );
 $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
 $meta_list = $wpdb->get_results( "SELECT $column, meta_key, meta_value
 FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A
 );
 }}}

 The error is fixed by changing the "$id_column" to "term_id", however
 "meta_id" does exist on this table, it just isn't part of the select, so
 I'm not sure if this is the right way to fix the issue.

 {{{#!php
 $id_column = 'user' == $meta_type ? 'umeta_id' : ( 'term' == $meta_type ?
 'term_id' : 'meta_id' );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34992>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list