Ticket #19690: 19690.4.diff
File 19690.4.diff, 7.7 KB (added by , 13 years ago) |
---|
-
wp-includes/post.php
1359 1359 global $wpdb; 1360 1360 1361 1361 $post_type = sanitize_post_field('post_type', $post_type, $post_id, 'db'); 1362 $return = $wpdb->update( $wpdb->posts, array('post_type' => $post_type), array('ID' => $post_id) );1362 $return = $wpdb->update( $wpdb->posts, array('post_type' => $post_type), array('ID' => $post_id) ); 1363 1363 1364 if ( 'page' == $post_type ) 1365 clean_page_cache($post_id); 1366 else 1367 clean_post_cache($post_id); 1364 clean_post_cache( $post_id, $post_type ); 1368 1365 1369 1366 return $return; 1370 1367 } … … 2056 2053 $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); 2057 2054 do_action( 'deleted_post', $postid ); 2058 2055 2059 if ( 'page' == $post->post_type ) { 2060 clean_page_cache($postid); 2061 } else { 2062 clean_post_cache($postid); 2063 } 2056 clean_post_cache( $postid, $post->post_type ); 2064 2057 2065 2058 if ( is_post_type_hierarchical( $post->post_type ) ) { 2066 2059 foreach ( (array) $children as $child ) 2067 clean_post_cache( $child->ID );2060 clean_post_cache( $child->ID, $child->post_type ); 2068 2061 } 2069 2062 2070 2063 wp_clear_scheduled_hook('publish_future_post', array( $postid ) ); … … 2643 2636 2644 2637 $current_guid = get_post_field( 'guid', $post_ID ); 2645 2638 2646 if ( 'page' == $data['post_type'] ) 2647 clean_page_cache($post_ID); 2648 else 2649 clean_post_cache($post_ID); 2639 clean_post_cache($post_ID, $data['post_type']); 2650 2640 2651 2641 // Set GUID 2652 2642 if ( !$update && '' == $current_guid ) … … 3535 3525 } 3536 3526 3537 3527 // Update cache. 3538 update_p age_cache($pages);3528 update_post_cache( $pages ); 3539 3529 3540 3530 if ( $child_of || $hierarchical ) 3541 3531 $pages = & get_page_children($child_of, $pages); … … 3751 3741 if ( $file ) 3752 3742 update_attached_file( $post_ID, $file ); 3753 3743 3754 clean_post_cache( $post_ID);3744 clean_post_cache( $post_ID, $post_type ); 3755 3745 3756 3746 if ( ! empty( $context ) ) 3757 3747 add_post_meta( $post_ID, '_wp_attachment_context', $context, true ); … … 3864 3854 if ( ! empty($file) ) 3865 3855 @ unlink($file); 3866 3856 3867 clean_post_cache( $post_id);3857 clean_post_cache( $post_id, $post->post_type ); 3868 3858 3869 3859 return $post; 3870 3860 } … … 4314 4304 /** 4315 4305 * Updates posts in cache. 4316 4306 * 4317 * @usedby update_page_cache() Aliased by this function.4318 *4319 4307 * @package WordPress 4320 4308 * @subpackage Cache 4321 4309 * @since 1.5.1 4322 4310 * 4323 4311 * @param array $posts Array of post objects 4324 4312 */ 4325 function update_post_cache( &$posts) {4326 if ( ! $posts )4313 function update_post_cache( &$posts ) { 4314 if ( ! $posts ) 4327 4315 return; 4328 4316 4329 4317 foreach ( $posts as $post ) 4330 wp_cache_add( $post->ID, $post, 'posts');4318 wp_cache_add( $post->ID, $post, 'posts' ); 4331 4319 } 4332 4320 4333 4321 /** … … 4348 4336 * @uses do_action() Calls 'clean_post_cache' on $id before adding children (if any). 4349 4337 * 4350 4338 * @param int $id The Post ID in the cache to clean 4339 * @param string $post_type The post_type of the post. Defaults to "post" 4351 4340 */ 4352 function clean_post_cache($id ) {4341 function clean_post_cache($id, $post_type = 'post') { 4353 4342 global $_wp_suspend_cache_invalidation, $wpdb; 4354 4343 4355 if ( ! empty($_wp_suspend_cache_invalidation) )4344 if ( ! empty( $_wp_suspend_cache_invalidation ) ) 4356 4345 return; 4357 4346 4358 4347 $id = (int) $id; … … 4360 4349 if ( 0 === $id ) 4361 4350 return; 4362 4351 4363 $post = get_post( $id );4364 4365 4352 wp_cache_delete($id, 'posts'); 4366 4353 wp_cache_delete($id, 'post_meta'); 4367 4354 4368 clean_object_term_cache( $id, $post ->post_type );4355 clean_object_term_cache( $id, $post_type ); 4369 4356 4370 4357 wp_cache_delete( 'wp_get_archives', 'general' ); 4371 4358 4372 4359 do_action('clean_post_cache', $id); 4373 4360 4361 if ( 'page' == $post_type ) { 4362 wp_cache_delete( 'all_page_ids', 'posts' ); 4363 wp_cache_delete( 'get_pages', 'posts' ); 4364 } 4365 4374 4366 if ( $children = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $id) ) ) { 4375 4367 foreach ( $children as $cid ) { 4376 4368 // Loop detection 4377 4369 if ( $cid == $id ) 4378 4370 continue; 4379 clean_post_cache( $cid );4371 clean_post_cache( $cid, $post_type ); 4380 4372 } 4381 4373 } 4382 4374 … … 4385 4377 } 4386 4378 4387 4379 /** 4388 * Alias of update_post_cache().4389 *4390 * @see update_post_cache() Posts and pages are the same, alias is intentional4391 *4392 * @package WordPress4393 * @subpackage Cache4394 * @since 1.5.14395 *4396 * @param array $pages list of page objects4397 */4398 function update_page_cache(&$pages) {4399 update_post_cache($pages);4400 }4401 4402 /**4403 * Will clean the page in the cache.4404 *4405 * Clean (read: delete) page from cache that matches $id. Will also clean cache4406 * associated with 'all_page_ids' and 'get_pages'.4407 *4408 * @package WordPress4409 * @subpackage Cache4410 * @since 2.0.04411 *4412 * @uses do_action() Will call the 'clean_page_cache' hook action.4413 *4414 * @param int $id Page ID to clean4415 */4416 function clean_page_cache($id) {4417 clean_post_cache($id);4418 4419 wp_cache_delete( 'all_page_ids', 'posts' );4420 wp_cache_delete( 'get_pages', 'posts' );4421 4422 do_action('clean_page_cache', $id);4423 }4424 4425 /**4426 4380 * Call major cache updating functions for list of Post objects. 4427 4381 * 4428 4382 * @package WordPress … … 4629 4583 * @param object $post Object type containing the post information 4630 4584 */ 4631 4585 function _save_post_hook($post_id, $post) { 4632 if ( $post->post_type == 'page' ) { 4633 clean_page_cache($post_id); 4634 } else { 4635 clean_post_cache($post_id); 4636 } 4586 clean_post_cache($post_id, $post->post_type); 4637 4587 } 4638 4588 4639 4589 /** … … 5361 5311 5362 5312 update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache ); 5363 5313 } 5364 } 5365 No newline at end of file 5314 } -
wp-includes/comment.php
1583 1583 $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) ); 1584 1584 $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) ); 1585 1585 1586 if ( 'page' == $post->post_type ) 1587 clean_page_cache( $post_id ); 1588 else 1589 clean_post_cache( $post_id ); 1586 clean_post_cache( $post_id, $post->post_type ); 1590 1587 1591 1588 do_action('wp_update_comment_count', $post_id, $new, $old); 1592 1589 do_action('edit_post', $post_id, $post); -
wp-includes/deprecated.php
3116 3116 ); 3117 3117 3118 3118 return $theme_data; 3119 } 3120 No newline at end of file 3119 } 3120 3121 /** 3122 * Alias of update_post_cache(). 3123 * 3124 * @see update_post_cache() Posts and pages are the same, alias is intentional 3125 * 3126 * @since 1.5.1 3127 * @deprecated 3.4.0 3128 * 3129 * @param array $pages list of page objects 3130 */ 3131 function update_page_cache( &$pages ) { 3132 _deprecated_function( __FUNCTION__, 3.4, 'update_post_cache()' ); 3133 3134 update_post_cache( $pages ); 3135 } 3136 3137 /** 3138 * Will clean the page in the cache. 3139 * 3140 * Clean (read: delete) page from cache that matches $id. Will also clean cache 3141 * associated with 'all_page_ids' and 'get_pages'. 3142 * 3143 * @since 2.0.0 3144 * @deprecated 3.4.0 3145 * 3146 * @uses do_action() Will call the 'clean_page_cache' hook action. 3147 * 3148 * @param int $id Page ID to clean 3149 */ 3150 function clean_page_cache( $id ) { 3151 _deprecated_function( __FUNCTION__, 3.4, 'clean_post_cache()' ); 3152 3153 clean_post_cache( $id, 'page' ); 3154 } -
wp-admin/includes/class-wp-posts-list-table.php
360 360 if ( $page->post_parent == $page->ID ) { 361 361 $page->post_parent = 0; 362 362 $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); 363 clean_p age_cache( $page->ID);363 clean_post_cache( $page->ID, $page->post_type ); 364 364 } 365 365 366 366 if ( 0 == $page->post_parent )