mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Clean attachment cache when reattaching, fixes #11647
git-svn-id: http://svn.automattic.com/wordpress/trunk@13192 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0dcfcc6e20
commit
e41f7c83ce
@ -43,6 +43,7 @@ if ( isset($_GET['find_detached']) ) {
|
||||
continue;
|
||||
|
||||
$attach[] = $att_id;
|
||||
clean_attachment_cache($att_id);
|
||||
}
|
||||
|
||||
if ( ! empty($attach) ) {
|
||||
|
@ -3906,6 +3906,41 @@ function update_postmeta_cache($post_ids) {
|
||||
return update_meta_cache('post', $post_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will clean the attachment in the cache.
|
||||
*
|
||||
* Cleaning means delete from the cache. Optionaly will clean the term
|
||||
* object cache associated with the attachment ID.
|
||||
*
|
||||
* This function will not run if $_wp_suspend_cache_invalidation is not empty. See
|
||||
* wp_suspend_cache_invalidation().
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Cache
|
||||
* @since 3.0
|
||||
*
|
||||
* @uses do_action() Calls 'clean_attachment_cache' on $id.
|
||||
*
|
||||
* @param int $id The attachment ID in the cache to clean
|
||||
* @param bool $clean_terms optional. Whether to clean terms cache
|
||||
*/
|
||||
function clean_attachment_cache($id, $clean_terms = false) {
|
||||
global $_wp_suspend_cache_invalidation, $wpdb;
|
||||
|
||||
if ( !empty($_wp_suspend_cache_invalidation) )
|
||||
return;
|
||||
|
||||
$id = (int) $id;
|
||||
|
||||
wp_cache_delete($id, 'posts');
|
||||
wp_cache_delete($id, 'post_meta');
|
||||
|
||||
if ( $clean_terms )
|
||||
clean_object_term_cache($id, 'attachment');
|
||||
|
||||
do_action('clean_attachment_cache', $id);
|
||||
}
|
||||
|
||||
//
|
||||
// Hooks
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user