Changeset 879
- Timestamp:
- 02/05/07 11:49:12 (2 years ago)
- Files:
-
- trunk/wp-admin/upgrade-schema.php (modified) (11 diffs)
- trunk/wp-config-sample.php (modified) (1 diff)
- trunk/wp-includes/cache.php (modified) (1 diff)
- trunk/wp-includes/functions.php (modified) (7 diffs)
- trunk/wp-includes/pluggable.php (modified) (3 diffs)
- trunk/wp-includes/post-template.php (modified) (2 diffs)
- trunk/wp-includes/script-loader.php (modified) (1 diff)
- trunk/wp-includes/version.php (modified) (1 diff)
- trunk/wp-includes/wp-db.php (modified) (4 diffs)
- trunk/xmlrpc.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-admin/upgrade-schema.php
r817 r879 3 3 4 4 global $wp_queries; 5 $charset_collate = ''; 6 7 if ( 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 } 5 13 6 14 $wp_queries="CREATE TABLE $wpdb->categories ( … … 16 24 PRIMARY KEY (cat_ID), 17 25 KEY category_nicename (category_nicename) 18 ) TYPE=MyISAM;26 ) $charset_collate; 19 27 CREATE TABLE $wpdb->comments ( 20 28 comment_ID bigint(20) unsigned NOT NULL auto_increment, … … 36 44 KEY comment_approved (comment_approved), 37 45 KEY comment_post_ID (comment_post_ID) 38 ) TYPE=MyISAM;46 ) $charset_collate; 39 47 CREATE TABLE $wpdb->link2cat ( 40 48 rel_id bigint(20) NOT NULL auto_increment, … … 43 51 PRIMARY KEY (rel_id), 44 52 KEY link_id (link_id,category_id) 45 ) TYPE=MyISAM;53 ) $charset_collate; 46 54 CREATE TABLE $wpdb->links ( 47 55 link_id bigint(20) NOT NULL auto_increment, … … 62 70 KEY link_category (link_category), 63 71 KEY link_visible (link_visible) 64 ) TYPE=MyISAM;72 ) $charset_collate; 65 73 CREATE TABLE $wpdb->options ( 66 74 option_id bigint(20) NOT NULL auto_increment, … … 77 85 PRIMARY KEY (option_id,blog_id,option_name), 78 86 KEY option_name (option_name) 79 ) TYPE=MyISAM;87 ) $charset_collate; 80 88 CREATE TABLE $wpdb->post2cat ( 81 89 rel_id bigint(20) NOT NULL auto_increment, … … 84 92 PRIMARY KEY (rel_id), 85 93 KEY post_id (post_id,category_id) 86 ) TYPE=MyISAM;94 ) $charset_collate; 87 95 CREATE TABLE $wpdb->postmeta ( 88 96 meta_id bigint(20) NOT NULL auto_increment, … … 93 101 KEY post_id (post_id), 94 102 KEY meta_key (meta_key) 95 ) TYPE=MyISAM;103 ) $charset_collate; 96 104 CREATE TABLE $wpdb->posts ( 97 105 ID bigint(20) unsigned NOT NULL auto_increment, … … 122 130 KEY post_name (post_name), 123 131 KEY type_status_date (post_type,post_status,post_date,ID) 124 ) TYPE=MyISAM;132 ) $charset_collate; 125 133 CREATE TABLE $wpdb->users ( 126 134 ID bigint(20) unsigned NOT NULL auto_increment, … … 138 146 PRIMARY KEY (ID), 139 147 KEY user_login_key (user_login) 140 ) ;148 ) $charset_collate; 141 149 CREATE TABLE $wpdb->usermeta ( 142 150 umeta_id bigint(20) NOT NULL auto_increment, … … 147 155 KEY user_id (user_id), 148 156 KEY meta_key (meta_key) 149 ) ;157 ) $charset_collate;"; 150 158 CREATE TABLE $wpdb->blogs ( 151 159 blog_id bigint(20) NOT NULL auto_increment, trunk/wp-config-sample.php
r700 r879 23 23 define( "WP_USE_MULTIPLE_DB", false ); 24 24 25 /* Stop editing*/25 /* That's all, stop editing! Happy blogging. */ 26 26 27 27 define('ABSPATH', dirname(__FILE__).'/'); trunk/wp-includes/cache.php
r878 r879 218 218 } 219 219 } 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 236 222 } 237 223 trunk/wp-includes/functions.php
r877 r879 210 210 211 211 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 { 212 222 $value = wp_cache_get($setting, 'options'); 223 } 213 224 } else { 214 225 $value = false; 215 226 wp_cache_delete($setting, 'options'); 216 227 } 217 218 228 // Uncomment if we get any page not found or rewrite errors 219 229 // if( $setting == 'rewrite_rules' ) 220 230 // $value = false; 221 222 231 if ( $value == 'novalueindb' ) 223 232 return false; … … 234 243 if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values 235 244 $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; 240 250 } 241 251 } … … 251 261 $value = stripslashes( $value ); 252 262 return apply_filters( 'option_' . $setting, maybe_unserialize($value) ); 263 } 264 265 function 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))); 253 269 } 254 270 … … 280 296 } 281 297 298 function 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 282 316 function update_option($option_name, $newvalue) { 283 317 global $wpdb; 318 319 wp_protect_special_option($option_name); 284 320 285 321 if ( is_string($newvalue) ) … … 297 333 } 298 334 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 299 341 $_newvalue = $newvalue; 300 342 $newvalue = maybe_serialize($newvalue); 301 343 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 } 303 351 304 352 $newvalue = $wpdb->escape($newvalue); … … 316 364 global $wpdb; 317 365 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 } 321 376 322 377 $value = maybe_serialize($value); 323 378 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 } 325 386 326 387 $name = $wpdb->escape($name); … … 334 395 function delete_option($name) { 335 396 global $wpdb; 397 398 wp_protect_special_option($name); 399 336 400 // 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; 339 403 $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 } 341 413 return true; 342 414 } trunk/wp-includes/pluggable.php
r810 r879 97 97 98 98 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'); 101 100 return $user; 102 101 } … … 117 116 return false; 118 117 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 120 121 if ( $userdata ) 121 122 return $userdata; … … 154 155 155 156 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'); 158 158 return $user; 159 159 trunk/wp-includes/post-template.php
r849 r879 274 274 275 275 $output = ''; 276 $current_page = 0; 276 277 277 278 // sanitize, mostly to keep spaces out … … 289 290 290 291 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(); 292 294 $output .= walk_page_tree($pages, $r['depth'], $current_page, $r); 293 295 trunk/wp-includes/script-loader.php
r868 r879 80 80 $src = 0 === strpos($this->scripts[$handle]->src, 'http://') ? $this->scripts[$handle]->src : get_option( 'siteurl' ) . $this->scripts[$handle]->src; 81 81 $src = add_query_arg('ver', $ver, $src); 82 $src = apply_filters( 'script_loader_src', $src ); 82 83 echo "<script type='text/javascript' src='$src'></script>\n"; 83 84 } trunk/wp-includes/version.php
r877 r879 4 4 5 5 $wp_version = 'wordpress-mu-1.1.1'; // Let's just avoid confusion 6 $wp_db_version = 4 772;6 $wp_db_version = 4860; 7 7 8 8 ?> trunk/wp-includes/wp-db.php
r832 r879 29 29 var $comments; 30 30 var $links; 31 var $link2cat;32 var $linkcategories;33 31 var $options; 34 32 var $optiontypes; … … 38 36 var $postmeta; 39 37 38 var $charset; 39 var $collate; 40 40 41 /** 41 42 * Connects to the database server and selects a database … … 53 54 function __construct($dbuser, $dbpassword, $dbname, $dbhost) { 54 55 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; 55 62 56 63 $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword); … … 67 74 "); 68 75 } 76 77 if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') ) 78 $this->query("SET NAMES '$this->charset'"); 69 79 70 80 $this->select($dbname, $this->dbh); trunk/xmlrpc.php
r876 r879 228 228 "wp_page_parent_title" => $parent_title, 229 229 "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 231 232 ); 232 233 … … 948 949 // If an author id was provided then use it instead. 949 950 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 } 950 968 $post_author = $content_struct["wp_author_id"]; 951 969 } … … 1080 1098 // Only set the post_author if one is set. 1081 1099 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 } 1082 1117 $post_author = $content_struct["wp_author_id"]; 1083 1118 } … … 1200 1235 'wp_slug' => $postdata['post_name'], 1201 1236 'wp_password' => $postdata['post_password'], 1202 'wp_author ' => $author->display_name,1203 'wp_author_ username' => $author->user_login1237 'wp_author_id' => $author->ID, 1238 'wp_author_display_name' => $author->display_name 1204 1239 ); 1205 1240 … … 1267 1302 'wp_slug' => $entry['post_name'], 1268 1303 'wp_password' => $entry['post_password'], 1269 'wp_author ' => $author->display_name,1270 'wp_author_ username' => $author->user_login1304 'wp_author_id' => $author->ID, 1305 'wp_author_display_name' => $author->display_name 1271 1306 ); 1272 1307
