Changeset 4524 for trunk/wp-includes/post.php
- Timestamp:
- 11/23/2006 08:39:39 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.