WordPress.org

Make WordPress Core

Ticket #6860: clean_post_cache_recursive.patch

File clean_post_cache_recursive.patch, 860 bytes (added by arnee, 10 years ago)

New argument $recursive (true by default)

  • post.php

     
    26912691 * @uses do_action() Will call the 'clean_post_cache' hook action.
    26922692 *
    26932693 * @param int $id The Post ID in the cache to clean
     2694 * @param bool $recursive Also clean the cache for child posts
    26942695 */
    2695 function clean_post_cache($id) {
     2696function clean_post_cache($id, $recursive = true) {
    26962697        global $wpdb;
    26972698        $id = (int) $id;
    26982699
     
    27052706
    27062707        do_action('clean_post_cache', $id);
    27072708
    2708         if ( $children = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $id) ) ) {
     2709        if ($recursive && $children = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $id) ) ) {
    27092710                foreach( $children as $cid )
    27102711                        clean_post_cache( $cid );
    27112712        }