Multisite: Rename the `calculate_current_dirsize` filter to `pre_recurse_dirsize`.

Set the default value to `false`. This brings some consistency with the `pre_get_space_used` filter.

Follow-up to [49212], [49616], [49628].

See #19879.
Built from https://develop.svn.wordpress.org/trunk@49629


git-svn-id: http://core.svn.wordpress.org/trunk@49367 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-11-17 15:44:07 +00:00
parent e123448589
commit 5801fc9a93
3 changed files with 8 additions and 6 deletions

View File

@ -7624,8 +7624,6 @@ function get_dirsize( $directory, $max_execution_time = null ) {
* @return int|false|null Size in bytes if a valid directory. False if not. Null if timeout. * @return int|false|null Size in bytes if a valid directory. False if not. Null if timeout.
*/ */
function recurse_dirsize( $directory, $exclude = null, $max_execution_time = null, &$directory_cache = null ) { function recurse_dirsize( $directory, $exclude = null, $max_execution_time = null, &$directory_cache = null ) {
$size = 0;
$directory = untrailingslashit( $directory ); $directory = untrailingslashit( $directory );
$cache_path = untrailingslashit( str_replace( ABSPATH, '', $directory ) ); $cache_path = untrailingslashit( str_replace( ABSPATH, '', $directory ) );
@ -7674,11 +7672,13 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul
* *
* @since 5.6.0 * @since 5.6.0
* *
* @param int|false $space_used The amount of used space, in bytes. Default 0. * @param int|false $space_used The amount of used space, in bytes. Default false.
*/ */
$size = apply_filters( 'calculate_current_dirsize', $size, $directory, $exclude, $max_execution_time, $directory_cache ); $size = apply_filters( 'pre_recurse_dirsize', false, $directory, $exclude, $max_execution_time, $directory_cache );
if ( false === $size ) {
$size = 0;
if ( 0 === $size ) {
$handle = opendir( $directory ); $handle = opendir( $directory );
if ( $handle ) { if ( $handle ) {
while ( ( $file = readdir( $handle ) ) !== false ) { while ( ( $file = readdir( $handle ) ) !== false ) {
@ -7703,6 +7703,7 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul
closedir( $handle ); closedir( $handle );
} }
} }
$directory_cache[ $cache_path ] = $size; $directory_cache[ $cache_path ] = $size;
// Only write the transient on the top level call and not on recursive calls. // Only write the transient on the top level call and not on recursive calls.

View File

@ -2629,6 +2629,7 @@ function get_space_used() {
* @param int|false $space_used The amount of used space, in megabytes. Default false. * @param int|false $space_used The amount of used space, in megabytes. Default false.
*/ */
$space_used = apply_filters( 'pre_get_space_used', false ); $space_used = apply_filters( 'pre_get_space_used', false );
if ( false === $space_used ) { if ( false === $space_used ) {
$upload_dir = wp_upload_dir(); $upload_dir = wp_upload_dir();
$space_used = get_dirsize( $upload_dir['basedir'] ) / MB_IN_BYTES; $space_used = get_dirsize( $upload_dir['basedir'] ) / MB_IN_BYTES;

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.6-beta4-49628'; $wp_version = '5.6-beta4-49629';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.