WordPress.org

Make WordPress Core

Changeset 1401


Ignore:
Timestamp:
06/10/04 08:42:25 (11 years ago)
Author:
saxmatt
Message:

Changes to options system and query improvements.

Location:
trunk
Files:
4 edited

Legend:

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

    r1370 r1401  
    842842        $wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_description, option_admin_level) VALUES('default_email_category', 1, '1', 'by default posts by email will have this category', 8)"); 
    843843    } 
     844 
     845    if(!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'recently_edited'")) { 
     846        $wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_admin_level) VALUES ('recently_edited', 3, '', 8)"); 
     847    } 
     848 
     849    maybe_add_column($wpdb->options, 'autoload', "ALTER TABLE `$wpdb->options` ADD `autoload` ENUM( 'yes', 'no' ) NOT NULL ;"); 
     850 
     851    // Set up a few options not to load by default 
     852    $fatoptions = array( 'moderation_keys', 'recently_edited' ); 
     853    foreach ($fatoptions as $fatoption) : 
     854        $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'"); 
     855    endforeach; 
    844856} 
    845857 
  • trunk/wp-blog-header.php

    r1381 r1401  
    149149 
    150150// Update some caches. 
    151 update_user_cache(); 
    152151update_category_cache(); 
    153152 
  • trunk/wp-includes/functions.php

    r1394 r1401  
    189189function get_userdatabylogin($user_login) { 
    190190    global $cache_userdata, $wpdb; 
    191     if ( empty($cache_userdata["$user_login"]) ) { 
     191    if ( !empty($user_login) && empty($cache_userdata["$user_login"]) ) { 
    192192        $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'"); 
    193193        $cache_userdata["$user_login"] = $user; 
     
    200200function get_userid($user_login) { 
    201201    global $cache_userdata, $wpdb; 
    202     if ( empty($cache_userdata["$user_login"]) ) { 
     202    if ( !empty($user_login) && empty($cache_userdata["$user_login"]) ) { 
    203203        $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$user_login'"); 
    204204 
     
    301301function get_settings($setting) { 
    302302    global $wpdb, $cache_settings; 
    303     if (strstr($_SERVER['REQUEST_URI'], 'install.php')) { 
     303    if ( strstr($_SERVER['REQUEST_URI'], 'install.php') || strstr($_SERVER['REQUEST_URI'], 'upgrade.php') ) { 
    304304        return false; 
    305305    } 
    306306 
    307     if ( (empty($cache_settings)) ) { 
    308         $settings = get_alloptions(); 
    309         $cache_settings = $settings; 
     307    if ( empty($cache_settings) ) { 
     308        $cache_settings = get_alloptions(); 
     309    } 
     310 
     311    if ('home' == $setting && '' == $cache_settings->home) return $cache_settings->siteurl; 
     312 
     313    if (!isset($cache_settings->$setting)) { 
     314        return $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'"); 
    310315    } else { 
    311         $settings = $cache_settings; 
    312     } 
    313  
    314     if ('home' == $setting && '' == $settings->home) return $settings->siteurl; 
    315  
    316     if (!isset($settings->$setting)) { 
    317         return false; 
    318     } else { 
    319         return stripslashes($settings->$setting); 
     316        return $cache_settings->$setting; 
    320317    } 
    321318} 
     
    323320function get_alloptions() { 
    324321    global $wpdb; 
    325     $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); 
    326     if ($options) { 
     322    if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'")) { 
    327323        foreach ($options as $option) { 
    328324            // "When trying to design a foolproof system,  
    329             //  never underestimate the ingenuity of the fools :)" 
     325            //  never underestimate the ingenuity of the fools :)" -- Dougal 
    330326            if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value); 
    331327            if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value); 
    332328            if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value); 
    333329 
    334             $all_options->{$option->option_name} = $option->option_value; 
     330            $all_options->{$option->option_name} = stripslashes($option->option_value); 
    335331        } 
    336332    } 
     
    18121808    global $cache_userdata, $wpdb; 
    18131809 
    1814     $users = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_level > 0"); 
    1815     foreach ($users as $user) { 
    1816         $cache_userdata[$user->ID] = $user; 
    1817     } 
     1810    if ( $users = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_level > 0") ) : 
     1811        foreach ($users as $user) : 
     1812            $cache_userdata[$user->ID] = $user; 
     1813        endforeach; 
     1814        return true; 
     1815    else:  
     1816        return false; 
     1817    endif; 
    18181818} 
    18191819 
  • trunk/wp-settings.php

    r1377 r1401  
    4848 
    4949 
    50 $wpdb->hide_errors(); 
    51 $users = $wpdb->get_results("SELECT * FROM $wpdb->users"); 
    52 if ( !$users && !strstr($_SERVER['PHP_SELF'], 'install.php') ) 
    53     die("It doesn't look like you've installed WP yet. Try running <a href='wp-admin/install.php'>install.php</a>."); 
    54 $wpdb->show_errors(); 
    55  
    5650require (ABSPATH . WPINC . '/functions.php'); 
    5751require (ABSPATH . WPINC . '/functions-formatting.php'); 
     
    6054require (ABSPATH . WPINC . '/kses.php'); 
    6155require_once (ABSPATH . WPINC . '/wp-l10n.php'); 
     56 
     57$wpdb->hide_errors(); 
     58if ( !update_user_cache() && !strstr($_SERVER['PHP_SELF'], 'install.php') ) 
     59    die("It doesn't look like you've installed WP yet. Try running <a href='wp-admin/install.php'>install.php</a>."); 
     60$wpdb->show_errors(); 
    6261 
    6362if (!strstr($_SERVER['PHP_SELF'], 'install.php') && !strstr($_SERVER['PHP_SELF'], 'wp-admin/import')) { 
Note: See TracChangeset for help on using the changeset viewer.