WordPress.org

Make WordPress Core

Changeset 20148


Ignore:
Timestamp:
03/08/2012 03:22:39 AM (10 years ago)
Author:
nacin
Message:

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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/upgrade.php

    r20080 r20148  
    12781278        }
    12791279    }
     1280
    12801281    // 3.0
    12811282    if ( $wp_current_db_version < 13576 )
    12821283        update_site_option( 'global_terms_enabled', '1' );
     1284
    12831285    // 3.3
    12841286    if ( $wp_current_db_version < 19390 )
    12851287        update_site_option( 'initial_db_version', $wp_current_db_version );
     1288
    12861289    if ( $wp_current_db_version < 19470 ) {
    12871290        if ( false === get_site_option( 'active_sitewide_plugins' ) )
    12881291            update_site_option( 'active_sitewide_plugins', array() );
     1292    }
     1293
     1294    // 3.4
     1295    if ( $wp_current_db_version < 20148 ) {
     1296        // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
     1297        $allowedthemes  = get_site_option( 'allowedthemes'  );
     1298        $allowed_themes = get_site_option( 'allowed_themes' );
     1299        if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) {
     1300            $converted = array();
     1301            $themes = wp_get_themes();
     1302            foreach ( $themes as $stylesheet => $theme_data ) {
     1303                if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
     1304                    $converted[ $stylesheet ] = true;
     1305            }
     1306            update_site_option( 'allowedthemes', $converted );
     1307            delete_site_option( 'allowed_themes' );
     1308        }
    12891309    }
    12901310}
  • trunk/wp-includes/class-wp-theme.php

    r20146 r20148  
    10851085    public static function get_allowed_on_network() {
    10861086        static $allowed_themes;
    1087         if ( isset( $allowed_themes ) )
    1088             return $allowed_themes;
    1089 
    1090         $allowed_themes = get_site_option( 'allowedthemes' );
    1091 
    1092         // This is all super old MU back compat joy.
    1093         // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
    1094         if ( false === $allowed_themes ) {
    1095             $allowed_themes = get_site_option( 'allowed_themes' );
    1096             if ( ! is_array( $allowed_themes ) || empty( $allowed_themes ) ) {
    1097                 $allowed_themes = array();
    1098             } else {
    1099                 $converted = array();
    1100                 $themes = wp_get_themes();
    1101                 foreach ( $themes as $stylesheet => $theme_data ) {
    1102                     if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
    1103                         $converted[ $stylesheet ] = true;
    1104                 }
    1105                 $allowed_themes = $converted;
    1106             }
    1107             // Set the option so we never have to go through this pain again.
    1108             if ( ( is_admin() && is_main_site() ) || is_network_admin() ) {
    1109                 update_site_option( 'allowedthemes', $allowed_themes );
    1110                 delete_site_option( 'allowed_themes' );
    1111             }
    1112         }
    1113 
     1087        if ( ! isset( $allowed_themes ) )
     1088            $allowed_themes = (array) get_site_option( 'allowedthemes' );
    11141089        return $allowed_themes;
    11151090    }
     
    11601135            }
    11611136            // Set the option so we never have to go through this pain again.
    1162             if ( is_admin() ) {
     1137            if ( is_admin() && $allowed_themes[ $blog_id ] ) {
    11631138                if ( $current ) {
    11641139                    update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
  • trunk/wp-includes/version.php

    r20142 r20148  
    1212 * @global int $wp_db_version
    1313 */
    14 $wp_db_version = 20080;
     14$wp_db_version = 20148;
    1515
    1616/**
Note: See TracChangeset for help on using the changeset viewer.