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

git-svn-id: http://svn.automattic.com/wordpress/trunk@11902 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2009-09-06 18:46:27 +00:00
parent 11c3cb07b9
commit 02c7c0e38e
3 changed files with 103 additions and 1 deletions

View File

@@ -1771,7 +1771,31 @@ function is_blog_installed() {
$installed = !empty( $installed );
wp_cache_set( 'is_blog_installed', $installed );
return $installed;
if ( $installed )
return true;
$suppress = $wpdb->suppress_errors();
$tables = $wpdb->get_col('SHOW TABLES');
$wpdb->suppress_errors( $suppress );
// Loop over the WP tables. If none exist, then scratch install is allowed.
// If one or more exist, suggest table repair since we got here because the options
// table could not be accessed.
foreach ($wpdb->tables as $table) {
// If one of the WP tables exist, then we are in an insane state.
if ( in_array($wpdb->prefix . $table, $tables) ) {
// If visiting repair.php, return true and let it take over.
if ( defined('WP_REPAIRING') )
return true;
// Die with a DB error.
$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>.');
dead_db();
}
}
wp_cache_set( 'is_blog_installed', false );
return false;
}
/**

View File

@@ -254,6 +254,16 @@ class wpdb {
var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options',
'postmeta', 'terms', 'term_taxonomy', 'term_relationships');
/**
* List of deprecated WordPress tables
*
* @since 2.9.0
* @access private
* @var array
*/
var $old_tables = array('categories', 'post2cat', 'link2cat');
/**
* Format specifiers for DB columns. Columns not listed here default to %s. Initialized in wp-settings.php.
*