Make WordPress Core


Ignore:
Timestamp:
09/06/2009 06:46:27 PM (15 years ago)
Author:
ryan
Message:

is_blog_installed() improvements and repair.php. see #10728

File:
1 edited

Legend:

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

    r11883 r11902  
    17721772    wp_cache_set( 'is_blog_installed', $installed );
    17731773
    1774     return $installed;
     1774    if ( $installed )
     1775        return true;
     1776
     1777    $suppress = $wpdb->suppress_errors();
     1778    $tables = $wpdb->get_col('SHOW TABLES');
     1779    $wpdb->suppress_errors( $suppress );
     1780
     1781    // Loop over the WP tables.  If none exist, then scratch install is allowed.
     1782    // If one or more exist, suggest table repair since we got here because the options
     1783    // table could not be accessed.
     1784    foreach ($wpdb->tables as $table) {
     1785        // If one of the WP tables exist, then we are in an insane state.
     1786        if ( in_array($wpdb->prefix . $table, $tables) ) {
     1787            // If visiting repair.php, return true and let it take over.
     1788            if ( defined('WP_REPAIRING') )
     1789                return true;
     1790            // Die with a DB error.
     1791            $wpdb->error = __('One or more database tables are unavailable.  The database may need to be <a href="maint/repair.php?referrer=is_blog_installed">repaired</a>.');
     1792            dead_db();
     1793        }
     1794    }
     1795
     1796    wp_cache_set( 'is_blog_installed', false );
     1797
     1798    return false;
    17751799}
    17761800
Note: See TracChangeset for help on using the changeset viewer.