Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#61602 closed defect (bug) (fixed)

site health - disk_free_space return error

Reported by: wbdv Owned by: SergeyBiryukov
Priority: normal Milestone: 6.7
Component: Site Health Version: 6.5.5
Severity: minor Keywords: has-patch
Cc: Focuses:

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 (6)

#1 @mi5t4n
2 years ago

Version 1, edited 2 years ago by mi5t4n (previous) (next) (diff)

#2 @wbdv
2 years 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.


2 years ago
#3

  • Keywords has-patch added

#4 @SergeyBiryukov
2 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → closed

In 58913:

Site Health: Correct the check for disk space available to safely perform updates.

The wp-content/upgrade directory does not exist initially after installation, so the Site Health check could not determine the available disk space until the directory was subsequently created during an update.

By testing WP_CONTENT_DIR instead, the check can complete successfully.

This also brings consistency with similar checks in _unzip_file_ziparchive() and _unzip_file_pclzip().

Follow-up to [55720], [56401].

Props wbdv, khokansardar, mi5t4n, SergeyBiryukov.
Fixes #61602.

#5 @SergeyBiryukov
2 years ago

  • Milestone Awaiting Review → 6.7

​@SergeyBiryukov commented on ​PR #7006:


2 years ago
#6

Thanks for the PR! Merged a slightly different approach in r58913.

Note: See TracTickets for help on using tickets.