WordPress.org

Make WordPress Core

Ticket #8977: maybe_create_table.diff

File maybe_create_table.diff, 814 bytes (added by jamescollins, 9 years ago)

Patch against r10446

  • upgrade.php

     
    926926 */
    927927function maybe_create_table($table_name, $create_ddl) {
    928928        global $wpdb;
    929         foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
    930                 if ($table == $table_name) {
    931                         return true;
    932                 }
    933         }
     929        if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name )
     930                return true;
    934931        //didn't find it try to create it.
    935932        $q = $wpdb->query($create_ddl);
    936933        // we cannot directly tell that whether this succeeded!
    937         foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
    938                 if ($table == $table_name) {
    939                         return true;
    940                 }
    941         }
     934        if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name )
     935                return true;
    942936        return false;
    943937}
    944938