From 2a6b9ea6dbfe684c676de038b5309e6ab2fe09ce Mon Sep 17 00:00:00 2001 From: nacin Date: Thu, 8 Mar 2012 03:22:39 +0000 Subject: [PATCH] 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 --- wp-admin/includes/upgrade.php | 20 ++++++++++++++++++++ wp-includes/class-wp-theme.php | 31 +++---------------------------- wp-includes/version.php | 2 +- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 24f4ab4de..171f82c93 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -1277,16 +1277,36 @@ function upgrade_network() { $start += 20; } } + // 3.0 if ( $wp_current_db_version < 13576 ) update_site_option( 'global_terms_enabled', '1' ); + // 3.3 if ( $wp_current_db_version < 19390 ) update_site_option( 'initial_db_version', $wp_current_db_version ); + if ( $wp_current_db_version < 19470 ) { if ( false === get_site_option( 'active_sitewide_plugins' ) ) 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 diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index f1b29ff52..a72421037 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -1084,33 +1084,8 @@ final class WP_Theme implements ArrayAccess { */ public static function get_allowed_on_network() { static $allowed_themes; - if ( isset( $allowed_themes ) ) - return $allowed_themes; - - $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' ); - } - } - + if ( ! isset( $allowed_themes ) ) + $allowed_themes = (array) get_site_option( 'allowedthemes' ); return $allowed_themes; } @@ -1159,7 +1134,7 @@ final class WP_Theme implements ArrayAccess { $allowed_themes[ $blog_id ] = $converted; } // 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 ) { update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); delete_option( 'allowed_themes' ); diff --git a/wp-includes/version.php b/wp-includes/version.php index b9bb76532..bae92df95 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -11,7 +11,7 @@ $wp_version = '3.4-alpha-20142'; * * @global int $wp_db_version */ -$wp_db_version = 20080; +$wp_db_version = 20148; /** * Holds the TinyMCE version