Make WordPress Core

Changeset 19039


Ignore:
Timestamp:
10/21/2011 10:16:33 PM (15 years ago)
Author:
ryan
Message:

Don't use unbounded SHOW TABLES in is_blog_installed(). Do a more targeted DESCRIBE loop over the blog table list. fixes #19026

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r19012 r19039  
    19001900                return true;
    19011901
     1902        // If visiting repair.php, return true and let it take over.
     1903        if ( defined( 'WP_REPAIRING' ) )
     1904                return true;
     1905
    19021906        $suppress = $wpdb->suppress_errors();
    1903         $tables = $wpdb->get_col('SHOW TABLES');
    1904         $wpdb->suppress_errors( $suppress );
    1905 
    1906         $wp_tables = $wpdb->tables();
     1907
    19071908        // Loop over the WP tables.  If none exist, then scratch install is allowed.
    19081909        // If one or more exist, suggest table repair since we got here because the options
    19091910        // table could not be accessed.
     1911        $wp_tables = $wpdb->tables();
    19101912        foreach ( $wp_tables as $table ) {
    1911                 // If one of the WP tables exist, then we are in an insane state.
    1912                 if ( in_array( $table, $tables ) ) {
    1913                         // The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
    1914                         if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
    1915                                 continue;
    1916                         if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
    1917                                 continue;
    1918 
    1919                         // If visiting repair.php, return true and let it take over.
    1920                         if ( defined('WP_REPAIRING') )
    1921                                 return true;
    1922                         // Die with a DB error.
    1923                         $wpdb->error = sprintf( /*WP_I18N_NO_TABLES*/'One or more database tables are unavailable.  The database may need to be <a href="%s">repaired</a>.'/*/WP_I18N_NO_TABLES*/, 'maint/repair.php?referrer=is_blog_installed' );
    1924                         dead_db();
    1925                 }
    1926         }
     1913                // The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
     1914                if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
     1915                        continue;
     1916                if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
     1917                        continue;
     1918
     1919                if ( ! $wpdb->get_results( "DESCRIBE $table;" ) )
     1920                        continue;
     1921
     1922                // One or more tables exist. We are insane.
     1923
     1924                // Die with a DB error.
     1925                $wpdb->error = sprintf( /*WP_I18N_NO_TABLES*/'One or more database tables are unavailable.  The database may need to be <a href="%s">repaired</a>.'/*/WP_I18N_NO_TABLES*/, 'maint/repair.php?referrer=is_blog_installed' );
     1926                dead_db();
     1927        }
     1928
     1929        $wpdb->suppress_errors( $suppress );
    19271930
    19281931        wp_cache_set( 'is_blog_installed', false );
Note: See TracChangeset for help on using the changeset viewer.