Upgrade/Install: Check if the `disk_free_space()` function exists before calling it.
In PHP 8+, `@` no longer suppresses fatal errors: > The `@` operator will no longer silence fatal errors (`E_ERROR`, `E_CORE_ERROR`, `E_COMPILE_ERROR`, `E_USER_ERROR`, `E_RECOVERABLE_ERROR`, `E_PARSE`). Reference: [https://www.php.net/manual/en/migration80.incompatible.php PHP 8: Backward Incompatible Changes]. `disk_free_space()` may be disabled by hosts, which will throw a fatal error on a call to undefined function. This change prevents the fatal error, and falls back to `false` when `disk_free_space()` is unavailable. Follow-up to [25540], [25774], [25776], [25831], [25869]. Props costdev, jrf, swb1192, SergeyBiryukov. Fixes #54826. See #54730. Built from https://develop.svn.wordpress.org/trunk@52585 git-svn-id: http://core.svn.wordpress.org/trunk@52175 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c6829b3afc
commit
ab263f93e5
|
@ -1661,7 +1661,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
|
|||
* Require we have enough space to unzip the file and copy its contents, with a 10% buffer.
|
||||
*/
|
||||
if ( wp_doing_cron() ) {
|
||||
$available_space = @disk_free_space( WP_CONTENT_DIR );
|
||||
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false;
|
||||
|
||||
if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
|
||||
return new WP_Error(
|
||||
|
@ -1802,7 +1802,7 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
|
|||
* Require we have enough space to unzip the file and copy its contents, with a 10% buffer.
|
||||
*/
|
||||
if ( wp_doing_cron() ) {
|
||||
$available_space = @disk_free_space( WP_CONTENT_DIR );
|
||||
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false;
|
||||
|
||||
if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
|
||||
return new WP_Error(
|
||||
|
|
|
@ -1242,7 +1242,7 @@ function update_core( $from, $to ) {
|
|||
|
||||
// If we don't have enough free space, it isn't worth trying again.
|
||||
// Unlikely to be hit due to the check in unzip_file().
|
||||
$available_space = @disk_free_space( ABSPATH );
|
||||
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( ABSPATH ) : false;
|
||||
|
||||
if ( $available_space && $total_size >= $available_space ) {
|
||||
$result = new WP_Error( 'disk_full', __( 'There is not enough free disk space to complete the update.' ) );
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.0-alpha-52584';
|
||||
$wp_version = '6.0-alpha-52585';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue