Make WordPress Core

Changeset 49629


Ignore:
Timestamp:
11/17/2020 03:42:57 PM (3 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r49628 r49629  
    76257625 */
    76267626function recurse_dirsize( $directory, $exclude = null, $max_execution_time = null, &$directory_cache = null ) {
    7627     $size = 0;
    7628 
    76297627    $directory  = untrailingslashit( $directory );
    76307628    $cache_path = untrailingslashit( str_replace( ABSPATH, '', $directory ) );
     
    76757673     * @since 5.6.0
    76767674     *
    7677      * @param int|false $space_used The amount of used space, in bytes. Default 0.
     7675     * @param int|false $space_used The amount of used space, in bytes. Default false.
    76787676     */
    7679     $size = apply_filters( 'calculate_current_dirsize', $size, $directory, $exclude, $max_execution_time, $directory_cache );
    7680 
    7681     if ( 0 === $size ) {
     7677    $size = apply_filters( 'pre_recurse_dirsize', false, $directory, $exclude, $max_execution_time, $directory_cache );
     7678
     7679    if ( false === $size ) {
     7680        $size = 0;
     7681
    76827682        $handle = opendir( $directory );
    76837683        if ( $handle ) {
     
    77047704        }
    77057705    }
     7706
    77067707    $directory_cache[ $cache_path ] = $size;
    77077708
  • trunk/src/wp-includes/ms-functions.php

    r49539 r49629  
    26302630     */
    26312631    $space_used = apply_filters( 'pre_get_space_used', false );
     2632
    26322633    if ( false === $space_used ) {
    26332634        $upload_dir = wp_upload_dir();
  • trunk/tests/phpunit/tests/multisite/cleanDirsizeCache.php

    r49628 r49629  
    220220         * @ticket 19879
    221221         */
    222         function test_recurse_dirsize_calculate_current_dirsize_filter() {
    223             add_filter( 'calculate_current_dirsize', array( $this, '_filter_calculate_current_dirsize' ) );
     222        function test_pre_recurse_dirsize_filter() {
     223            add_filter( 'pre_recurse_dirsize', array( $this, '_filter_pre_recurse_dirsize' ) );
    224224
    225225            $upload_dir = wp_upload_dir();
    226226            $this->assertSame( 1042, recurse_dirsize( $upload_dir['path'] ) );
    227227
    228             remove_filter( 'calculate_current_dirsize', array( $this, '_filter_calculate_current_dirsize' ) );
    229         }
    230 
    231         function _filter_calculate_current_dirsize() {
     228            remove_filter( 'pre_recurse_dirsize', array( $this, '_filter_pre_recurse_dirsize' ) );
     229        }
     230
     231        function _filter_pre_recurse_dirsize() {
    232232            return 1042;
    233233        }
Note: See TracChangeset for help on using the changeset viewer.