Changeset 4524
- Timestamp:
- 11/23/2006 08:39:39 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-db.php
r4495 r4524 482 482 $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'"); 483 483 wp_cache_delete($cat_id, 'category'); 484 } 484 do_action('edit_category', $cat_id); 485 } 486 487 do_action('edit_link', $link_ID); 485 488 } // wp_set_link_cats() 486 489 -
trunk/wp-includes/category-template.php
r4495 r4524 61 61 62 62 function get_the_category($id = false) { 63 global $post, $category_cache ;63 global $post, $category_cache, $blog_id; 64 64 65 65 if ( !$id ) 66 66 $id = $post->ID; 67 67 68 if ( !isset($category_cache[$ id]) )68 if ( !isset($category_cache[$blog_id][$id]) ) 69 69 update_post_category_cache($id); 70 70 71 $categories = $category_cache[$ id];71 $categories = $category_cache[$blog_id][$id]; 72 72 73 73 if ( !empty($categories) ) … … 141 141 142 142 function in_category($category) { // Check if the current post is in the given category 143 global $category_cache, $post ;144 145 if ( isset( $category_cache[$ post->ID][$category] ) )143 global $category_cache, $post, $blog_id; 144 145 if ( isset( $category_cache[$blog_id][$post->ID][$category] ) ) 146 146 return true; 147 147 else -
trunk/wp-includes/functions.php
r4517 r4524 107 107 108 108 function get_lastpostdate($timezone = 'server') { 109 global $cache_lastpostdate, $pagenow, $wpdb ;109 global $cache_lastpostdate, $pagenow, $wpdb, $blog_id; 110 110 $add_seconds_blog = get_option('gmt_offset') * 3600; 111 111 $add_seconds_server = date('Z'); 112 if ( !isset($cache_lastpostdate[$ timezone]) ) {112 if ( !isset($cache_lastpostdate[$blog_id][$timezone]) ) { 113 113 switch(strtolower($timezone)) { 114 114 case 'gmt': … … 122 122 break; 123 123 } 124 $cache_lastpostdate[$ timezone] = $lastpostdate;125 } else { 126 $lastpostdate = $cache_lastpostdate[$ timezone];124 $cache_lastpostdate[$blog_id][$timezone] = $lastpostdate; 125 } else { 126 $lastpostdate = $cache_lastpostdate[$blog_id][$timezone]; 127 127 } 128 128 return $lastpostdate; … … 130 130 131 131 function get_lastpostmodified($timezone = 'server') { 132 global $cache_lastpostmodified, $pagenow, $wpdb ;132 global $cache_lastpostmodified, $pagenow, $wpdb, $blog_id; 133 133 $add_seconds_blog = get_option('gmt_offset') * 3600; 134 134 $add_seconds_server = date('Z'); 135 if ( !isset($cache_lastpostmodified[$ timezone]) ) {135 if ( !isset($cache_lastpostmodified[$blog_id][$timezone]) ) { 136 136 switch(strtolower($timezone)) { 137 137 case 'gmt': … … 149 149 $lastpostmodified = $lastpostdate; 150 150 } 151 $cache_lastpostmodified[$ timezone] = $lastpostmodified;152 } else { 153 $lastpostmodified = $cache_lastpostmodified[$ timezone];151 $cache_lastpostmodified[$blog_id][$timezone] = $lastpostmodified; 152 } else { 153 $lastpostmodified = $cache_lastpostmodified[$blog_id][$timezone]; 154 154 } 155 155 return $lastpostmodified; … … 509 509 510 510 function update_post_cache(&$posts) { 511 global $post_cache ;511 global $post_cache, $blog_id; 512 512 513 513 if ( !$posts ) … … 515 515 516 516 for ($i = 0; $i < count($posts); $i++) { 517 $post_cache[$ posts[$i]->ID] = &$posts[$i];517 $post_cache[$blog_id][$posts[$i]->ID] = &$posts[$i]; 518 518 } 519 519 } 520 520 521 521 function clean_post_cache($id) { 522 global $post_cache ;523 524 if ( isset( $post_cache[$ id] ) )525 unset( $post_cache[$ id] );522 global $post_cache, $blog_id; 523 524 if ( isset( $post_cache[$blog_id][$id] ) ) 525 unset( $post_cache[$blog_id][$id] ); 526 526 } 527 527 528 528 function update_page_cache(&$pages) { 529 global $page_cache ;529 global $page_cache, $blog_id; 530 530 531 531 if ( !$pages ) … … 533 533 534 534 for ($i = 0; $i < count($pages); $i++) { 535 $page_cache[$ pages[$i]->ID] = &$pages[$i];535 $page_cache[$blog_id][$pages[$i]->ID] = &$pages[$i]; 536 536 wp_cache_add($pages[$i]->ID, $pages[$i], 'pages'); 537 537 } … … 540 540 541 541 function clean_page_cache($id) { 542 global $page_cache ;543 544 if ( isset( $page_cache[$ id] ) )545 unset( $page_cache[$ id] );542 global $page_cache, $blog_id; 543 544 if ( isset( $page_cache[$blog_id][$id] ) ) 545 unset( $page_cache[$blog_id][$id] ); 546 546 } 547 547 … … 579 579 function update_post_caches(&$posts) { 580 580 global $post_cache, $category_cache, $post_meta_cache; 581 global $wpdb ;581 global $wpdb, $blog_id; 582 582 583 583 // No point in doing all this work if we didn't match any posts. … … 588 588 for ($i = 0; $i < count($posts); $i++) { 589 589 $post_id_array[] = $posts[$i]->ID; 590 $post_cache[$ posts[$i]->ID] = &$posts[$i];590 $post_cache[$blog_id][$posts[$i]->ID] = &$posts[$i]; 591 591 } 592 592 … … 599 599 600 600 function update_postmeta_cache($post_id_list = '') { 601 global $wpdb, $post_meta_cache ;601 global $wpdb, $post_meta_cache, $blog_id; 602 602 603 603 // We should validate this comma-separated list for the upcoming SQL query … … 627 627 // Change from flat structure to hierarchical: 628 628 if ( !isset($post_meta_cache) ) 629 $post_meta_cache = array();629 $post_meta_cache[$blog_id] = array(); 630 630 631 631 foreach ($meta_list as $metarow) { … … 635 635 636 636 // Force subkeys to be array type: 637 if ( !isset($post_meta_cache[$ mpid]) || !is_array($post_meta_cache[$mpid]) )638 $post_meta_cache[$ mpid] = array();639 if ( !isset($post_meta_cache[$ mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]) )640 $post_meta_cache[$ mpid]["$mkey"] = array();637 if ( !isset($post_meta_cache[$blog_id][$mpid]) || !is_array($post_meta_cache[$blog_id][$mpid]) ) 638 $post_meta_cache[$blog_id][$mpid] = array(); 639 if ( !isset($post_meta_cache[$blog_id][$mpid]["$mkey"]) || !is_array($post_meta_cache[$blog_id][$mpid]["$mkey"]) ) 640 $post_meta_cache[$blog_id][$mpid]["$mkey"] = array(); 641 641 642 642 // Add a value to the current pid/key: 643 $post_meta_cache[$ mpid][$mkey][] = $mval;643 $post_meta_cache[$blog_id][$mpid][$mkey][] = $mval; 644 644 } 645 645 } -
trunk/wp-includes/post.php
r4521 r4524 10 10 11 11 function &get_children($args = '', $output = OBJECT) { 12 global $post_cache, $wpdb ;12 global $post_cache, $wpdb, $blog_id; 13 13 14 14 if ( empty($args) ) { … … 33 33 if ( $children ) { 34 34 foreach ( $children as $key => $child ) { 35 $post_cache[$ child->ID] =& $children[$key];35 $post_cache[$blog_id][$child->ID] =& $children[$key]; 36 36 $kids[$child->ID] =& $children[$key]; 37 37 } … … 75 75 // Handles post caching. 76 76 function &get_post(&$post, $output = OBJECT) { 77 global $post_cache, $wpdb ;77 global $post_cache, $wpdb, $blog_id; 78 78 79 79 if ( empty($post) ) { … … 85 85 if ( 'page' == $post->post_type ) 86 86 return get_page($post, $output); 87 if ( !isset($post_cache[$ post->ID]) )88 $post_cache[$ post->ID] = &$post;89 $_post = & $post_cache[$ post->ID];87 if ( !isset($post_cache[$blog_id][$post->ID]) ) 88 $post_cache[$blog_id][$post->ID] = &$post; 89 $_post = & $post_cache[$blog_id][$post->ID]; 90 90 } else { 91 91 if ( $_post = wp_cache_get($post, 'pages') ) 92 92 return get_page($_post, $output); 93 elseif ( isset($post_cache[$ post]) )94 $_post = & $post_cache[$ post];93 elseif ( isset($post_cache[$blog_id][$post]) ) 94 $_post = & $post_cache[$blog_id][$post]; 95 95 else { 96 96 $query = "SELECT * FROM $wpdb->posts WHERE ID = '$post' LIMIT 1"; … … 98 98 if ( 'page' == $_post->post_type ) 99 99 return get_page($_post, $output); 100 $post_cache[$ post] = & $_post;100 $post_cache[$blog_id][$post] = & $_post; 101 101 } 102 102 } 103 103 104 104 if ( defined('WP_IMPORTING') ) 105 unset($post_cache );105 unset($post_cache[$blog_id]); 106 106 107 107 if ( $output == OBJECT ) { … … 242 242 243 243 function add_post_meta($post_id, $key, $value, $unique = false) { 244 global $wpdb, $post_meta_cache ;244 global $wpdb, $post_meta_cache, $blog_id; 245 245 246 246 $post_id = (int) $post_id; … … 252 252 } 253 253 254 $post_meta_cache[$ post_id][$key][] = $value;254 $post_meta_cache[$blog_id][$post_id][$key][] = $value; 255 255 256 256 $value = maybe_serialize($value); … … 263 263 264 264 function delete_post_meta($post_id, $key, $value = '') { 265 global $wpdb, $post_meta_cache ;265 global $wpdb, $post_meta_cache, $blog_id; 266 266 267 267 $post_id = (int) $post_id; … … 278 278 if ( empty($value) ) { 279 279 $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id' AND meta_key = '$key'"); 280 unset($post_meta_cache[$ post_id][$key]);280 unset($post_meta_cache[$blog_id][$post_id][$key]); 281 281 } else { 282 282 $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id' AND meta_key = '$key' AND meta_value = '$value'"); 283 $cache_key = $post_meta_cache[$ post_id][$key];283 $cache_key = $post_meta_cache[$blog_id][$post_id][$key]; 284 284 if ($cache_key) foreach ( $cache_key as $index => $data ) 285 285 if ( $data == $value ) 286 unset($post_meta_cache[$ post_id][$key][$index]);287 } 288 289 unset($post_meta_cache[$ post_id][$key]);286 unset($post_meta_cache[$blog_id][$post_id][$key][$index]); 287 } 288 289 unset($post_meta_cache[$blog_id][$post_id][$key]); 290 290 291 291 return true; … … 293 293 294 294 function get_post_meta($post_id, $key, $single = false) { 295 global $wpdb, $post_meta_cache ;295 global $wpdb, $post_meta_cache, $blog_id; 296 296 297 297 $post_id = (int) $post_id; 298 298 299 if ( !isset($post_meta_cache[$post_id]) ) 299 if ( isset($post_meta_cache[$blog_id][$post_id][$key]) ) { 300 if ( $single ) { 301 return maybe_unserialize( $post_meta_cache[$blog_id][$post_id][$key][0] ); 302 } else { 303 return maybe_unserialize( $post_meta_cache[$blog_id][$post_id][$key] ); 304 } 305 } 306 307 if ( !isset($post_meta_cache[$blog_id][$post_id]) ) 300 308 update_postmeta_cache($post_id); 301 309 302 310 if ( $single ) { 303 if ( isset($post_meta_cache[$ post_id][$key][0]) )304 return maybe_unserialize($post_meta_cache[$ post_id][$key][0]);311 if ( isset($post_meta_cache[$blog_id][$post_id][$key][0]) ) 312 return maybe_unserialize($post_meta_cache[$blog_id][$post_id][$key][0]); 305 313 else 306 314 return ''; 307 315 } else { 308 return maybe_unserialize($post_meta_cache[$ post_id][$key]);316 return maybe_unserialize($post_meta_cache[$blog_id][$post_id][$key]); 309 317 } 310 318 } 311 319 312 320 function update_post_meta($post_id, $key, $value, $prev_value = '') { 313 global $wpdb, $post_meta_cache ;321 global $wpdb, $post_meta_cache, $blog_id; 314 322 315 323 $post_id = (int) $post_id; … … 329 337 if ( empty($prev_value) ) { 330 338 $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE meta_key = '$key' AND post_id = '$post_id'"); 331 $cache_key = $post_meta_cache[$ post_id][$key];339 $cache_key = $post_meta_cache[$blog_id][$post_id][$key]; 332 340 if ( !empty($cache_key) ) 333 341 foreach ($cache_key as $index => $data) 334 $post_meta_cache[$ post_id][$key][$index] = $original_value;342 $post_meta_cache[$blog_id][$post_id][$key][$index] = $original_value; 335 343 } else { 336 344 $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'"); 337 $cache_key = $post_meta_cache[$ post_id][$key];345 $cache_key = $post_meta_cache[$blog_id][$post_id][$key]; 338 346 if ( !empty($cache_key) ) 339 347 foreach ($cache_key as $index => $data) 340 348 if ( $data == $original_prev ) 341 $post_meta_cache[$ post_id][$key][$index] = $original_value;349 $post_meta_cache[$blog_id][$post_id][$key][$index] = $original_value; 342 350 } 343 351 … … 347 355 348 356 function get_post_custom($post_id = 0) { 349 global $id, $post_meta_cache, $wpdb ;357 global $id, $post_meta_cache, $wpdb, $blog_id; 350 358 351 359 if ( !$post_id ) … … 354 362 $post_id = (int) $post_id; 355 363 356 if ( !isset($post_meta_cache[$ post_id]) )364 if ( !isset($post_meta_cache[$blog_id][$post_id]) ) 357 365 update_postmeta_cache($post_id); 358 366 359 return $post_meta_cache[$ post_id];367 return $post_meta_cache[$blog_id][$post_id]; 360 368 } 361 369 … … 797 805 $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'"); 798 806 wp_cache_delete($cat_id, 'category'); 799 } 807 do_action('edit_category', $cat_id); 808 } 809 810 do_action('edit_post', $post_ID); 800 811 } // wp_set_post_categories() 801 812 … … 896 907 // Handles page caching. 897 908 function &get_page(&$page, $output = OBJECT) { 898 global $wpdb ;909 global $wpdb, $blog_id; 899 910 900 911 if ( empty($page) ) { … … 914 925 $_page = & $GLOBALS['page']; 915 926 wp_cache_add($_page->ID, $_page, 'pages'); 916 } elseif ( !isset($_page) && $_page == $GLOBALS['post_cache'][$ page] ) {927 } elseif ( !isset($_page) && $_page == $GLOBALS['post_cache'][$blog_id][$page] ) { 917 928 return get_post($page, $output); 918 929 } elseif ( isset($_page) && $_page == wp_cache_get($page, 'pages') ) { … … 980 991 981 992 function &get_page_children($page_id, $pages) { 982 global $page_cache ;993 global $page_cache, $blog_id; 983 994 984 995 if ( empty($pages) ) 985 $pages = &$page_cache ;996 $pages = &$page_cache[$blog_id]; 986 997 987 998 $page_list = array();
Note: See TracChangeset
for help on using the changeset viewer.