Make WordPress Core

Ticket #54221: dirsize_expiration.patch

File dirsize_expiration.patch, 1.3 KB (added by nicomollet, 23 months ago)

Add 10 years expiration to dirsize_cache transient so that it is not autoloaded (except persistent object cache and installing)

  • wp-includes/functions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/wp-includes/functions.php b/wp-includes/functions.php
    a b  
    85828582
    85838583        // Only write the transient on the top level call and not on recursive calls.
    85848584        if ( $save_cache ) {
    8585                 set_transient( 'dirsize_cache', $directory_cache );
     8585                $expiration = ( wp_using_ext_object_cache() || wp_installing() ) ? 0 : 10 * YEAR_IN_SECONDS;
     8586                set_transient( 'dirsize_cache', $directory_cache, $expiration );
    85868587        }
    85878588
    85888589        return $size;
     
    86128613        }
    86138614
    86148615        $directory_cache = get_transient( 'dirsize_cache' );
     8616        $expiration = ( wp_using_ext_object_cache() || wp_installing() ) ? 0 : 10 * YEAR_IN_SECONDS;
    86158617
    86168618        if ( empty( $directory_cache ) ) {
    86178619                return;
     
    86228624                ! str_contains( $path, '\\' )
    86238625        ) {
    86248626                unset( $directory_cache[ $path ] );
    8625                 set_transient( 'dirsize_cache', $directory_cache );
     8627                set_transient( 'dirsize_cache', $directory_cache, $expiration );
    86268628                return;
    86278629        }
    86288630
     
    86418643                unset( $directory_cache[ $path ] );
    86428644        }
    86438645
    8644         set_transient( 'dirsize_cache', $directory_cache );
     8646        set_transient( 'dirsize_cache', $directory_cache, $expiration );
    86458647}
    86468648
    86478649/**