[wp-trac] [WordPress Trac] #32029: WP_Error( 'wpdb_get_table_charset_failure' ) thrown when doing "SHOW TABLES LIKE %s"

WordPress Trac noreply at wordpress.org
Mon Apr 20 19:24:30 UTC 2015


#32029: WP_Error( 'wpdb_get_table_charset_failure' ) thrown when doing "SHOW TABLES
LIKE %s"
---------------------------+-----------------------------
 Reporter:  datafeedr.com  |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Database       |    Version:  trunk
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 When attempting to check if a DB table exists, the
 "wpdb_get_table_charset_failure" error is being thrown. Here's where I
 believe the error is being thrown (wp-includes/wp-db.php:2235~2238):

 {{{
                 $results = $this->get_results( "SHOW FULL COLUMNS FROM
 `$table`" );
                 if ( ! $results ) {
                         return new WP_Error(
 'wpdb_get_table_charset_failure' );
                 }
 }}}

 My PHP error log has "WordPress database error Table
 'private.wp_dfrpswc_temp_post_ids_by_set_id' doesn't exist for query SHOW
 FULL COLUMNS FROM `wp_dfrpswc_temp_post_ids_by_set_id`".

 I believe the issue is related to the get_table_charset() method being
 called before the new table has been created.

 I'm running WP 4.2-RC1-32175. This is my custom code which generates the
 error:

 {{{
 $table_name = $wpdb->prefix . 'dfrpswc_temp_post_ids_by_set_id';
 $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name );
 if ( $wpdb->get_var( $query ) != $table_name ) {
         dfrpswc_create_table();
 }
 }}}

 Let me know if you need any additional information.

 Thanks
 Eric

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


More information about the wp-trac mailing list