Multisite: More consistency for `clean_dirsize_cache()`.
Props SergeyBiryukov. Fixes #19879. Built from https://develop.svn.wordpress.org/trunk@49616 git-svn-id: http://core.svn.wordpress.org/trunk@49354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7712866212
commit
aceaf33edd
|
@ -928,7 +928,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
|
|||
$url = $uploads['url'] . "/$filename";
|
||||
|
||||
if ( is_multisite() ) {
|
||||
invalidate_dirsize_cache( $new_file );
|
||||
clean_dirsize_cache( $new_file );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2747,7 +2747,7 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
|
|||
$url = $upload['url'] . "/$filename";
|
||||
|
||||
if ( is_multisite() ) {
|
||||
invalidate_dirsize_cache( $new_file );
|
||||
clean_dirsize_cache( $new_file );
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-admin/includes/file.php */
|
||||
|
@ -7628,7 +7628,8 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul
|
|||
$size = 0;
|
||||
|
||||
$directory = untrailingslashit( $directory );
|
||||
$cache_path = normalize_dirsize_cache_path( $directory );
|
||||
$cache_path = untrailingslashit( str_replace( ABSPATH, '', $directory ) );
|
||||
|
||||
$save_cache = false;
|
||||
|
||||
if ( ! isset( $directory_cache ) ) {
|
||||
|
@ -7722,14 +7723,14 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul
|
|||
*
|
||||
* @param string $path Full path of a directory or file.
|
||||
*/
|
||||
function invalidate_dirsize_cache( $path ) {
|
||||
function clean_dirsize_cache( $path ) {
|
||||
$directory_cache = get_transient( 'dirsize_cache' );
|
||||
|
||||
if ( empty( $directory_cache ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cache_path = normalize_dirsize_cache_path( $path );
|
||||
$cache_path = untrailingslashit( str_replace( ABSPATH, '', $path ) );
|
||||
unset( $directory_cache[ $cache_path ] );
|
||||
|
||||
while ( DIRECTORY_SEPARATOR !== $cache_path && '.' !== $cache_path && '..' !== $cache_path ) {
|
||||
|
@ -7740,22 +7741,6 @@ function invalidate_dirsize_cache( $path ) {
|
|||
set_transient( 'dirsize_cache', $directory_cache );
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize dirsize cache path.
|
||||
*
|
||||
* Ensures array keys within the dirsize_cache transient follow the same format.
|
||||
*
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
function normalize_dirsize_cache_path( $path ) {
|
||||
$path = str_replace( ABSPATH, '', $path );
|
||||
|
||||
return untrailingslashit( $path );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks compatibility with the current WordPress version.
|
||||
*
|
||||
|
|
|
@ -5918,7 +5918,7 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
|
|||
$file = get_attached_file( $post_id );
|
||||
|
||||
if ( is_multisite() ) {
|
||||
invalidate_dirsize_cache( $file );
|
||||
clean_dirsize_cache( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.6-beta4-49615';
|
||||
$wp_version = '5.6-beta4-49616';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue