The allowed_themes rolling upgrade for individual sites should not add empty allowedthemes arrays. If there are no allowed themes, don't add an empty option. Move the network rolling upgrade to upgrade_network(). see #20146.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20148 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-03-08 03:22:39 +00:00
parent b16b7d770a
commit 2a6b9ea6db
3 changed files with 24 additions and 29 deletions

View File

@ -1277,16 +1277,36 @@ function upgrade_network() {
$start += 20; $start += 20;
} }
} }
// 3.0 // 3.0
if ( $wp_current_db_version < 13576 ) if ( $wp_current_db_version < 13576 )
update_site_option( 'global_terms_enabled', '1' ); update_site_option( 'global_terms_enabled', '1' );
// 3.3 // 3.3
if ( $wp_current_db_version < 19390 ) if ( $wp_current_db_version < 19390 )
update_site_option( 'initial_db_version', $wp_current_db_version ); update_site_option( 'initial_db_version', $wp_current_db_version );
if ( $wp_current_db_version < 19470 ) { if ( $wp_current_db_version < 19470 ) {
if ( false === get_site_option( 'active_sitewide_plugins' ) ) if ( false === get_site_option( 'active_sitewide_plugins' ) )
update_site_option( 'active_sitewide_plugins', array() ); update_site_option( 'active_sitewide_plugins', array() );
} }
// 3.4
if ( $wp_current_db_version < 20148 ) {
// 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
$allowedthemes = get_site_option( 'allowedthemes' );
$allowed_themes = get_site_option( 'allowed_themes' );
if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) {
$converted = array();
$themes = wp_get_themes();
foreach ( $themes as $stylesheet => $theme_data ) {
if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
$converted[ $stylesheet ] = true;
}
update_site_option( 'allowedthemes', $converted );
delete_site_option( 'allowed_themes' );
}
}
} }
// The functions we use to actually do stuff // The functions we use to actually do stuff

View File

@ -1084,33 +1084,8 @@ final class WP_Theme implements ArrayAccess {
*/ */
public static function get_allowed_on_network() { public static function get_allowed_on_network() {
static $allowed_themes; static $allowed_themes;
if ( isset( $allowed_themes ) ) if ( ! isset( $allowed_themes ) )
return $allowed_themes; $allowed_themes = (array) get_site_option( 'allowedthemes' );
$allowed_themes = get_site_option( 'allowedthemes' );
// This is all super old MU back compat joy.
// 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
if ( false === $allowed_themes ) {
$allowed_themes = get_site_option( 'allowed_themes' );
if ( ! is_array( $allowed_themes ) || empty( $allowed_themes ) ) {
$allowed_themes = array();
} else {
$converted = array();
$themes = wp_get_themes();
foreach ( $themes as $stylesheet => $theme_data ) {
if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
$converted[ $stylesheet ] = true;
}
$allowed_themes = $converted;
}
// Set the option so we never have to go through this pain again.
if ( ( is_admin() && is_main_site() ) || is_network_admin() ) {
update_site_option( 'allowedthemes', $allowed_themes );
delete_site_option( 'allowed_themes' );
}
}
return $allowed_themes; return $allowed_themes;
} }
@ -1159,7 +1134,7 @@ final class WP_Theme implements ArrayAccess {
$allowed_themes[ $blog_id ] = $converted; $allowed_themes[ $blog_id ] = $converted;
} }
// Set the option so we never have to go through this pain again. // Set the option so we never have to go through this pain again.
if ( is_admin() ) { if ( is_admin() && $allowed_themes[ $blog_id ] ) {
if ( $current ) { if ( $current ) {
update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
delete_option( 'allowed_themes' ); delete_option( 'allowed_themes' );

View File

@ -11,7 +11,7 @@ $wp_version = '3.4-alpha-20142';
* *
* @global int $wp_db_version * @global int $wp_db_version
*/ */
$wp_db_version = 20080; $wp_db_version = 20148;
/** /**
* Holds the TinyMCE version * Holds the TinyMCE version