WordPress.org

Make WordPress Core

Changeset 13192


Ignore:
Timestamp:
02/18/2010 07:43:35 AM (10 years ago)
Author:
azaozz
Message:

Clean attachment cache when reattaching, fixes #11647

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upload.php

    r13153 r13192  
    4444
    4545        $attach[] = $att_id;
     46        clean_attachment_cache($att_id);
    4647    }
    4748
  • trunk/wp-includes/post.php

    r13184 r13192  
    39073907}
    39083908
     3909/**
     3910 * Will clean the attachment in the cache.
     3911 *
     3912 * Cleaning means delete from the cache. Optionaly will clean the term
     3913 * object cache associated with the attachment ID.
     3914 *
     3915 * This function will not run if $_wp_suspend_cache_invalidation is not empty. See
     3916 * wp_suspend_cache_invalidation().
     3917 *
     3918 * @package WordPress
     3919 * @subpackage Cache
     3920 * @since 3.0
     3921 *
     3922 * @uses do_action() Calls 'clean_attachment_cache' on $id.
     3923 *
     3924 * @param int $id The attachment ID in the cache to clean
     3925 * @param bool $clean_terms optional. Whether to clean terms cache
     3926 */
     3927function clean_attachment_cache($id, $clean_terms = false) {
     3928    global $_wp_suspend_cache_invalidation, $wpdb;
     3929
     3930    if ( !empty($_wp_suspend_cache_invalidation) )
     3931        return;
     3932
     3933    $id = (int) $id;
     3934
     3935    wp_cache_delete($id, 'posts');
     3936    wp_cache_delete($id, 'post_meta');
     3937
     3938    if ( $clean_terms )
     3939        clean_object_term_cache($id, 'attachment');
     3940
     3941    do_action('clean_attachment_cache', $id);
     3942}
     3943
    39093944//
    39103945// Hooks
Note: See TracChangeset for help on using the changeset viewer.