Changeset 879

Show
Ignore:
Timestamp:
02/05/07 11:49:12 (2 years ago)
Author:
donncha
Message:

WP Merge to rev 4865

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/upgrade-schema.php

    r817 r879  
    33 
    44global $wp_queries; 
     5$charset_collate = ''; 
     6         
     7if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { 
     8        if ( ! empty($wpdb->charset) ) 
     9                $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 
     10        if ( ! empty($wpdb->collate) ) 
     11                $charset_collate .= " COLLATE $wpdb->collate";   
     12} 
    513 
    614$wp_queries="CREATE TABLE $wpdb->categories ( 
     
    1624  PRIMARY KEY  (cat_ID), 
    1725  KEY category_nicename (category_nicename) 
    18 ) TYPE=MyISAM
     26) $charset_collate
    1927CREATE TABLE $wpdb->comments ( 
    2028  comment_ID bigint(20) unsigned NOT NULL auto_increment, 
     
    3644  KEY comment_approved (comment_approved), 
    3745  KEY comment_post_ID (comment_post_ID) 
    38 ) TYPE=MyISAM
     46) $charset_collate
    3947CREATE TABLE $wpdb->link2cat ( 
    4048  rel_id bigint(20) NOT NULL auto_increment, 
     
    4351  PRIMARY KEY  (rel_id), 
    4452  KEY link_id (link_id,category_id) 
    45 ) TYPE=MyISAM
     53) $charset_collate
    4654CREATE TABLE $wpdb->links ( 
    4755  link_id bigint(20) NOT NULL auto_increment, 
     
    6270  KEY link_category (link_category), 
    6371  KEY link_visible (link_visible) 
    64 ) TYPE=MyISAM
     72) $charset_collate
    6573CREATE TABLE $wpdb->options ( 
    6674  option_id bigint(20) NOT NULL auto_increment, 
     
    7785  PRIMARY KEY  (option_id,blog_id,option_name), 
    7886  KEY option_name (option_name) 
    79 ) TYPE=MyISAM
     87) $charset_collate
    8088CREATE TABLE $wpdb->post2cat ( 
    8189  rel_id bigint(20) NOT NULL auto_increment, 
     
    8492  PRIMARY KEY  (rel_id), 
    8593  KEY post_id (post_id,category_id) 
    86 ) TYPE=MyISAM
     94) $charset_collate
    8795CREATE TABLE $wpdb->postmeta ( 
    8896  meta_id bigint(20) NOT NULL auto_increment, 
     
    93101  KEY post_id (post_id), 
    94102  KEY meta_key (meta_key) 
    95 ) TYPE=MyISAM
     103) $charset_collate
    96104CREATE TABLE $wpdb->posts ( 
    97105  ID bigint(20) unsigned NOT NULL auto_increment, 
     
    122130  KEY post_name (post_name), 
    123131  KEY type_status_date (post_type,post_status,post_date,ID) 
    124 ) TYPE=MyISAM
     132) $charset_collate
    125133CREATE TABLE $wpdb->users ( 
    126134  ID bigint(20) unsigned NOT NULL auto_increment, 
     
    138146  PRIMARY KEY  (ID), 
    139147  KEY user_login_key (user_login) 
    140 )
     148) $charset_collate
    141149CREATE TABLE $wpdb->usermeta ( 
    142150  umeta_id bigint(20) NOT NULL auto_increment, 
     
    147155  KEY user_id (user_id), 
    148156  KEY meta_key (meta_key) 
    149 )
     157) $charset_collate;"
    150158CREATE TABLE $wpdb->blogs ( 
    151159  blog_id bigint(20) NOT NULL auto_increment, 
  • trunk/wp-config-sample.php

    r700 r879  
    2323define( "WP_USE_MULTIPLE_DB", false ); 
    2424 
    25 /* Stop editing */ 
     25/* That's all, stop editing! Happy blogging. */ 
    2626 
    2727define('ABSPATH', dirname(__FILE__).'/'); 
  • trunk/wp-includes/cache.php

    r878 r879  
    218218                                } 
    219219                        } 
    220                 } else 
    221                         if ('options' == $group) { 
    222                                 $wpdb->hide_errors(); 
    223                                 if (!$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'")) { 
    224                                         $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); 
    225                                 } 
    226                                 $wpdb->show_errors(); 
    227  
    228                                 if ( ! $options ) 
    229                                         return; 
    230  
    231                                 foreach ($options as $option) { 
    232                                         $this->cache['options'][$option->option_name] = $option->option_value; 
    233                                         $this->cache[$this->key( $option->option_name, 'options' )] = $option->option_value; 
    234                                 } 
    235                         } 
     220                } 
     221 
    236222        } 
    237223 
  • trunk/wp-includes/functions.php

    r877 r879  
    210210 
    211211        if ( $switched == false && defined('WP_INSTALLING') == false ) { 
     212        // prevent non-existent options from triggering multiple queries 
     213        $notoptions = wp_cache_get('notoptions', 'options'); 
     214        if ( isset($notoptions[$setting]) ) 
     215                return false; 
     216 
     217        $alloptions = wp_load_alloptions(); 
     218 
     219        if ( isset($alloptions[$setting]) ) { 
     220                $value = $alloptions[$setting]; 
     221        } else { 
    212222                $value = wp_cache_get($setting, 'options'); 
     223        } 
    213224        } else { 
    214225                $value = false; 
    215226                wp_cache_delete($setting, 'options'); 
    216227        } 
    217  
    218228// Uncomment if we get any page not found or rewrite errors      
    219229//      if( $setting == 'rewrite_rules' ) 
    220230//              $value = false; 
    221  
    222231        if ( $value == 'novalueindb' ) 
    223232                return false; 
     
    234243                if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values 
    235244                        $value = $row->option_value; 
    236                         wp_cache_set($setting, ($value=='')?'emptystringindb':$value, 'options'); 
    237                 } else { 
    238                         wp_cache_set($setting, 'novalueindb', 'options'); 
    239                         return false; 
     245                                wp_cache_set($setting, $value, 'options'); 
     246                        } else { // option does not exist, so we must cache its non-existence 
     247                                $notoptions[$setting] = true; 
     248                                wp_cache_set('notoptions', $notoptions, 'options'); 
     249                                return false; 
    240250                } 
    241251        } 
     
    251261                $value = stripslashes( $value ); 
    252262        return apply_filters( 'option_' . $setting, maybe_unserialize($value) ); 
     263} 
     264 
     265function wp_protect_special_option($option) { 
     266        $protected = array('alloptions', 'notoptions'); 
     267        if ( in_array($option, $protected) ) 
     268                die(sprintf(__('%s is a protected WP option and may not be modified'), wp_specialchars($option))); 
    253269} 
    254270 
     
    280296} 
    281297 
     298function wp_load_alloptions() { 
     299        global $wpdb; 
     300 
     301        $alloptions = wp_cache_get('alloptions', 'options'); 
     302 
     303        if ( !$alloptions ) { 
     304                $wpdb->hide_errors(); 
     305                if ( !$alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'") ) 
     306                        $alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); 
     307                $wpdb->show_errors(); 
     308                $alloptions = array(); 
     309                foreach ( (array) $alloptions_db as $o ) 
     310                        $alloptions[$o->option_name] = $o->option_value; 
     311                wp_cache_set('alloptions', $alloptions, 'options'); 
     312        } 
     313        return $alloptions; 
     314} 
     315 
    282316function update_option($option_name, $newvalue) { 
    283317        global $wpdb; 
     318 
     319        wp_protect_special_option($option_name); 
    284320 
    285321        if ( is_string($newvalue) ) 
     
    297333        } 
    298334 
     335        $notoptions = wp_cache_get('notoptions', 'options'); 
     336        if ( isset($notoptions[$option_name]) ) { 
     337                unset($notoptions[$option_name]); 
     338                wp_cache_set('notoptions', $notoptions, 'options'); 
     339        } 
     340 
    299341        $_newvalue = $newvalue; 
    300342        $newvalue = maybe_serialize($newvalue); 
    301343 
    302         wp_cache_delete($option_name, 'options'); 
     344        $alloptions = wp_load_alloptions(); 
     345        if ( isset($alloptions[$option_name]) ) { 
     346                $alloptions[$option_name] = $newvalue; 
     347                wp_cache_set('alloptions', $alloptions, 'options'); 
     348        } else { 
     349                wp_cache_set($option_name, $newvalue, 'options'); 
     350        } 
    303351 
    304352        $newvalue = $wpdb->escape($newvalue); 
     
    316364        global $wpdb; 
    317365 
    318         // Make sure the option doesn't already exist 
    319         if ( false !== get_option($name) ) 
    320                 return; 
     366        wp_protect_special_option($name); 
     367 
     368        // Make sure the option doesn't already exist we can check the cache before we ask for a db query 
     369        $notoptions = wp_cache_get('notoptions', 'options'); 
     370        if ( isset($notoptions[$name]) ) { 
     371                unset($notoptions[$name]); 
     372                wp_cache_set('notoptions', $notoptions, 'options'); 
     373        } elseif ( false !== get_option($name) ) { 
     374                        return; 
     375        } 
    321376 
    322377        $value = maybe_serialize($value); 
    323378 
    324         wp_cache_delete($name, 'options'); 
     379        if ( 'yes' == $autoload ) { 
     380                $alloptions = wp_load_alloptions(); 
     381                $alloptions[$name] = $value; 
     382                wp_cache_set('alloptions', $alloptions, 'options'); 
     383        } else { 
     384                wp_cache_set($name, $value, 'options'); 
     385        } 
    325386 
    326387        $name = $wpdb->escape($name); 
     
    334395function delete_option($name) { 
    335396        global $wpdb; 
     397 
     398        wp_protect_special_option($name); 
     399 
    336400        // Get the ID, if no ID then return 
    337         $option_id = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = '$name'"); 
    338         if ( !$option_id ) return false; 
     401        $option = $wpdb->get_row("SELECT option_id, autoload FROM $wpdb->options WHERE option_name = '$name'"); 
     402        if ( !$option->option_id ) return false; 
    339403        $wpdb->query("DELETE FROM $wpdb->options WHERE option_name = '$name'"); 
    340         wp_cache_delete($name, 'options'); 
     404        if ( 'yes' == $option->autoload ) { 
     405                $alloptions = wp_load_alloptions(); 
     406                if ( isset($alloptions[$name]) ) { 
     407                        unset($alloptions[$name]); 
     408                        wp_cache_set('alloptions', $alloptions, 'options'); 
     409                } 
     410        } else { 
     411                wp_cache_delete($name, 'options'); 
     412        } 
    341413        return true; 
    342414} 
  • trunk/wp-includes/pluggable.php

    r810 r879  
    9797 
    9898        wp_cache_add($user_id, $user, 'users'); 
    99         wp_cache_add($user->user_login, $user, 'userlogins'); 
    100  
     99        wp_cache_add($user->user_login, $user_id, 'userlogins'); 
    101100        return $user; 
    102101} 
     
    117116                return false; 
    118117 
    119         $userdata = wp_cache_get($user_login, 'userlogins'); 
     118        $user_id = wp_cache_get($user_login, 'userlogins'); 
     119        $userdata = wp_cache_get($user_id, 'users'); 
     120 
    120121        if ( $userdata ) 
    121122                return $userdata; 
     
    154155 
    155156        wp_cache_add($user->ID, $user, 'users'); 
    156         wp_cache_add($user->user_login, $user, 'userlogins'); 
    157  
     157        wp_cache_add($user->user_login, $user->ID, 'userlogins'); 
    158158        return $user; 
    159159 
  • trunk/wp-includes/post-template.php

    r849 r879  
    274274 
    275275        $output = ''; 
     276        $current_page = 0; 
    276277 
    277278        // sanitize, mostly to keep spaces out 
     
    289290 
    290291                global $wp_query; 
    291                 $current_page = $wp_query->get_queried_object_id(); 
     292                if ( is_page() ) 
     293                        $current_page = $wp_query->get_queried_object_id(); 
    292294                $output .= walk_page_tree($pages, $r['depth'], $current_page, $r); 
    293295 
  • trunk/wp-includes/script-loader.php

    r868 r879  
    8080                                        $src = 0 === strpos($this->scripts[$handle]->src, 'http://') ? $this->scripts[$handle]->src : get_option( 'siteurl' ) . $this->scripts[$handle]->src; 
    8181                                        $src = add_query_arg('ver', $ver, $src); 
     82                                        $src = apply_filters( 'script_loader_src', $src ); 
    8283                                        echo "<script type='text/javascript' src='$src'></script>\n"; 
    8384                                } 
  • trunk/wp-includes/version.php

    r877 r879  
    44 
    55$wp_version = 'wordpress-mu-1.1.1'; // Let's just avoid confusion 
    6 $wp_db_version = 4772
     6$wp_db_version = 4860
    77 
    88?> 
  • trunk/wp-includes/wp-db.php

    r832 r879  
    2929        var $comments; 
    3030        var $links; 
    31         var $link2cat; 
    32         var $linkcategories; 
    3331        var $options; 
    3432        var $optiontypes; 
     
    3836        var $postmeta; 
    3937 
     38        var $charset; 
     39        var $collate; 
     40 
    4041        /** 
    4142         * Connects to the database server and selects a database 
     
    5354        function __construct($dbuser, $dbpassword, $dbname, $dbhost) { 
    5455                register_shutdown_function(array(&$this, "__destruct")); 
     56 
     57                if ( defined('DB_CHARSET') ) 
     58                        $this->charset = DB_CHARSET; 
     59 
     60                if ( defined('DB_COLLATE') ) 
     61                        $this->collate = DB_COLLATE; 
    5562 
    5663                $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword); 
     
    6774"); 
    6875                } 
     76 
     77                if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') ) 
     78                        $this->query("SET NAMES '$this->charset'"); 
    6979 
    7080                $this->select($dbname, $this->dbh); 
  • trunk/xmlrpc.php

    r876 r879  
    228228                                "wp_page_parent_title"  => $parent_title, 
    229229                                "wp_page_order"                 => $page->menu_order, 
    230                                 "wp_author_username"    => $author->user_login 
     230                                "wp_author_id"                  => $author->ID, 
     231                                "wp_author_display_username"    => $author->display_name 
    231232                        ); 
    232233 
     
    948949                // If an author id was provided then use it instead. 
    949950                if(!empty($content_struct["wp_author_id"])) { 
     951                        switch($post_type) { 
     952                                case "post": 
     953                                        if(!current_user_can("edit_others_posts")) { 
     954                                                return(new IXR_Error(401, "You are not allowed to " . 
     955                                                        "post as this user")); 
     956                                        } 
     957                                        break; 
     958                                case "page": 
     959                                        if(!current_user_can("edit_others_pages")) { 
     960                                                return(new IXR_Error(401, "You are not allowed to " . 
     961                                                        "create pages as this user")); 
     962                                        } 
     963                                        break; 
     964                                default: 
     965                                        return(new IXR_Error(401, "Invalid post type.")); 
     966                                        break; 
     967                        } 
    950968                        $post_author = $content_struct["wp_author_id"]; 
    951969                } 
     
    10801098                // Only set the post_author if one is set. 
    10811099                if(!empty($content_struct["wp_author_id"])) { 
     1100                        switch($post_type) { 
     1101                                case "post": 
     1102                                        if(!current_user_can("edit_others_posts")) { 
     1103                                                return(new IXR_Error(401, "You are not allowed to " . 
     1104                                                        "change the post author as this user.")); 
     1105                                        } 
     1106                                        break; 
     1107                                case "page": 
     1108                                        if(!current_user_can("edit_others_pages")) { 
     1109                                                return(new IXR_Error(401, "You are not allowed to " . 
     1110                                                        "change the page author as this user.")); 
     1111                                        } 
     1112                                        break; 
     1113                                default: 
     1114                                        return(new IXR_Error(401, "Invalid post type.")); 
     1115                                        break; 
     1116                        } 
    10821117                        $post_author = $content_struct["wp_author_id"]; 
    10831118                } 
     
    12001235          'wp_slug' => $postdata['post_name'], 
    12011236          'wp_password' => $postdata['post_password'], 
    1202           'wp_author' => $author->display_name
    1203           'wp_author_username' => $author->user_login 
     1237          'wp_author_id' => $author->ID
     1238          'wp_author_display_name'     => $author->display_name 
    12041239            ); 
    12051240 
     
    12671302                                'wp_slug' => $entry['post_name'], 
    12681303                                'wp_password' => $entry['post_password'], 
    1269                                 'wp_author' => $author->display_name
    1270                                 'wp_author_username' => $author->user_login 
     1304                                'wp_author_id' => $author->ID
     1305                                'wp_author_display_name' => $author->display_name 
    12711306                        ); 
    12721307