Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#61602 new defect (bug)

site health - disk_free_space return error

Reported by: wbdv's profile wbdv Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 6.5.5
Component: Site Health Keywords: has-patch
Focuses: Cc:

Description

disk_free_space return error if there is no directory WP_CONTENT_DIR . '/upgrade/' (and by default, there is no wp-contents/upgrade directory)

Function return false and site health give an error about disk space.

Solution is simple, try to create directory WP_CONTENT_DIR.'/upgrade/' before disk_free_space.

Change History (3)

#1 @mi5t4n
4 weeks ago

I tested this but could not replicate the issue. The disk_free_space function is suppressed and returns false on failure.

<?php
File: src\wp-admin\includes\class-wp-site-health.php
1820:           $available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR . '/upgrade/' ) : false;

If you could tell us what is your environment like PHP version and WP version, that will help use replicate the issue.

Last edited 4 weeks ago by mi5t4n (previous) (diff)

#2 @wbdv
4 weeks ago

As you said, if wp-content/upgrade/ directory does not exists, disk_free_space() will return false. But this false means an error message in site health section of WordPress:

file: wp-admin/includes/class-wp-site-health.php
line: 1952
<?php
               if ( false === $available_space ) {
                        $result['description'] = __( 'Could not determine available disk space for updates.' );
                        $result['status']      = 'recommended';

To avoid this message, first try to create the wp-content/upgrade/ then check the disk free space. By default, wp-content/upgrade/ does not exists in wordpress (latest) and it needs to be created.

file: wp-admin/includes/class-wp-site-health.php
line: 1933
<?php
        public function get_test_available_updates_disk_space() {
+               global $wp_filesystem;
+               $wp_filesystem->mkdir( WP_CONTENT_DIR . '/upgrade/', FS_CHMOD_DIR );
                $available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR . '/upgrade/' ) : false;

This ticket was mentioned in PR #7006 on WordPress/wordpress-develop by @khokansardar.


4 weeks ago
#3

  • Keywords has-patch added
Note: See TracTickets for help on using tickets.