Make WordPress Core

Ticket #14273: 14273.diff

File 14273.diff, 1.2 KB (added by pento, 12 years ago)
  • src/wp-admin/install-helper.php

     
    5050 * @param string $create_ddl Create database table SQL.
    5151 * @return bool False on error, true if already exists or success.
    5252 */
    53 function maybe_create_table($table_name, $create_ddl) {
     53function maybe_create_table( $table_name, $create_ddl ) {
    5454        global $wpdb;
    55         foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
    56                 if ($table == $table_name) {
    57                         return true;
    58                 }
     55
     56        $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name );
     57        if ( strtolower( $wpdb->get_var( $query ) ) === strtolower( $table_name ) ) {
     58                return true;
    5959        }
    60         // Didn't find it, so try to create it.
    61         $wpdb->query($create_ddl);
    6260
     61        // Didn't find it, so we need to try to create it.
     62        $wpdb->query( $create_ddl );
     63
    6364        // We cannot directly tell that whether this succeeded!
    64         foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
    65                 if ($table == $table_name) {
    66                         return true;
    67                 }
    68         }
    69         return false;
     65        return ( strtolower( $wpdb->get_var( $query ) ) === strtolower( $table_name ) );
    7066}
    7167endif;
    7268