Changeset 7695 for branches/2.5/wp-includes/post.php
- Timestamp:
- 04/16/2008 05:23:40 PM (18 years ago)
- File:
-
- 1 edited
-
branches/2.5/wp-includes/post.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/2.5/wp-includes/post.php
r7646 r7695 166 166 return $null; 167 167 } elseif ( is_object($post) ) { 168 _get_post_ancestors($post); 168 169 wp_cache_add($post->ID, $post, 'posts'); 169 170 $_post = &$post; … … 172 173 if ( ! $_post = wp_cache_get($post, 'posts') ) { 173 174 $_post = & $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post)); 175 _get_post_ancestors($_post); 174 176 wp_cache_add($_post->ID, $_post, 'posts'); 175 177 } 176 178 } 177 178 // Populate the ancestors field.179 // Not cached since we don't clear cache for ancestors when a post changes.180 _get_post_ancestors($_post);181 179 182 180 $_post = sanitize_post($_post, $filter); … … 2728 2726 */ 2729 2727 function clean_page_cache($id) { 2728 global $wpdb; 2729 $id = (int) $id; 2730 2730 2731 clean_post_cache($id); 2731 2732 … … 2734 2735 2735 2736 do_action('clean_page_cache', $id); 2737 2738 if ( $children = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $id) ) ) 2739 foreach( $children as $cid ) 2740 clean_page_cache( $cid ); 2736 2741 } 2737 2742 … … 2957 2962 2958 2963 function _get_post_ancestors(&$_post) { 2959 global $wpdb;2960 2961 if ( !empty($_post->ancestors) )2962 return;2963 2964 $_post->ancestors = array();2965 2966 if ( empty($_post->post_parent) || $_post->ID == $_post->post_parent )2967 return;2968 2969 $id = $_post->ancestors[] = $_post->post_parent;2970 while ( $ancestor = $wpdb->get_var("SELECT `post_parent` FROM $wpdb->posts WHERE ID= '{$id}' LIMIT 1") ) {2971 if ( $id == $ancestor )2972 break;2973 $id = $_post->ancestors[] = $ancestor;2974 }2964 global $wpdb; 2965 2966 if ( isset($_post->ancestors) ) 2967 return; 2968 2969 $_post->ancestors = array(); 2970 2971 if ( empty($_post->post_parent) || $_post->ID == $_post->post_parent ) 2972 return; 2973 2974 $id = $_post->ancestors[] = $_post->post_parent; 2975 while ( $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id) ) ) { 2976 if ( $id == $ancestor ) 2977 break; 2978 $id = $_post->ancestors[] = $ancestor; 2979 } 2975 2980 } 2976 2981
Note: See TracChangeset
for help on using the changeset viewer.