Site Health: Check if directories exist before checking size.

Prevents the Site Health Debug tab from stalling when reporting directory sizes if the directory does not exist.

Props clorith, aristath, narenin, kowsar89, hellofromTonya, ironprogrammer, shailu25.
Fixes #61638.


git-svn-id: https://develop.svn.wordpress.org/trunk@58884 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson 2024-08-12 04:52:55 +00:00
parent 6cfec3b825
commit ac5fdb4660

View File

@ -1695,6 +1695,18 @@ class WP_Debug_Data {
'raw' => 0,
);
// If the directory does not exist, skip checking it, as it will skew the other results.
if ( ! is_dir( $path ) ) {
$all_sizes[ $name ] = array(
'path' => $path,
'raw' => 0,
'size' => __( 'The directory does not exist.' ),
'debug' => 'directory not found',
);
continue;
}
if ( microtime( true ) - WP_START_TIMESTAMP < $max_execution_time ) {
if ( 'wordpress_size' === $name ) {
$dir_size = recurse_dirsize( $path, $exclude, $max_execution_time );