Make WordPress Core

Changeset 2487


Ignore:
Timestamp:
03/29/2005 05:34:30 AM (22 years ago)
Author:
ryan
Message:

Use private, install/upgrade safe version of get_option() in upgrade-functions.php. Fixes ​http://mosquito.wordpress.org/view.php?id=1165

File:
1 edited

Legend:

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

    r2451 r2487  
    181181    }
    182182
    183         if ( !is_array( get_settings('active_plugins') ) ) {
    184                 $plugins = explode("\n", trim(get_settings('active_plugins')) );
    185                 update_option('active_plugins', $plugins);
    186         }
     183                $active_plugins = __get_option('active_plugins');
     184
     185                // If plugins are not stored in an array, they're stored in the old
     186                // newline separated format.  Convert to new format.
     187                if ( !is_array( $active_plugins ) ) {
     188                        $active_plugins = explode("\n", trim($active_plugins));
     189                        update_option('active_plugins', $active_plugins);
     190                }
    187191
    188192        // Obsolete tables
    … …  
    290294        }
    291295        return $all_options;
     296}
     297
     298// Version of get_option that is private to install/upgrade.
     299function __get_option($setting) {
     300        global $wpdb;
     301
     302        $option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
     303
     304        @ $kellogs = unserialize($option);
     305        if ($kellogs !== FALSE)
     306                return $kellogs;
     307        else
     308                return $option;
    292309}
    293310
    … …  
    562579                if ($lines) {
    563580                        $f = fopen("$site_dir/$newfile", 'w');
    564                        
     581
     582                        $siteurl = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'");
    565583                        foreach ($lines as $line) {
    566584                                if (preg_match('/require.*wp-blog-header/', $line))
    … …  
    568586
    569587                                // Update stylesheet references.
    570                                 $line = str_replace("<?php echo get_settings('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
     588                                $line = str_replace("<?php echo $siteurl; ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
    571589
    572590                                // Update comments template inclusion.
    … …  
    580598
    581599        // Add a theme header.
    582         $header = "/*\nTheme Name: $theme_name\nTheme URI: " . get_option('siteurl') . "\nDescription: A theme automatically created by the upgrade.\nVersion: 1.0\nAuthor: Moi\n*/\n";
     600        $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the upgrade.\nVersion: 1.0\nAuthor: Moi\n*/\n";
    583601
    584602        $stylelines = file_get_contents("$site_dir/style.css");
    … …  
    619637                foreach ($stylelines as $line) {
    620638                        if (strstr($line, "Theme Name:")) $line = "Theme Name: $theme_name";
    621                         elseif (strstr($line, "Theme URI:")) $line = "Theme URI: " . get_option('siteurl');
     639                        elseif (strstr($line, "Theme URI:")) $line = "Theme URI: " . __get_option('siteurl');
    622640                        elseif (strstr($line, "Description:")) $line = "Description: Your theme";
    623641                        elseif (strstr($line, "Version:")) $line = "Version: 1";
    … …  
    649667function make_site_theme() {
    650668        // Name the theme after the blog.
    651         $theme_name = get_option('blogname');
     669        $theme_name = __get_option('blogname');
    652670        $template = sanitize_title($theme_name);
    653671        $site_dir = ABSPATH . "wp-content/themes/$template";
    … …  
    680698
    681699        // Make the new site theme active.
    682         $current_template = get_option('template');
     700        $current_template = __get_option('template');
    683701        if ($current_template == 'default') {
    684702                update_option('template', $template);
Note: See TracChangeset for help on using the changeset viewer.