ClassicPress
ClassicPress copied to clipboard
WP-r52585: Check if the disk_free_space() exists
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: PHP 8: Backward Incompatible Changes.
Fixes #901
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.
@bahiirwa - can you address the conflict?
Done some tests after the discussion on Slack.
In PHP < 8 when disk_free_space
is disabled a warning is triggered (PHP Warning: disk_free_space() has been disabled for security reasons
) and it returns null
.
In PHP 8 it's a fatal error: PHP Fatal error: Uncaught Error: Call to undefined function disk_free_space()
, and the execution is stopped.
This mean that in PHP < 8 if disk_free_space
is disabled the upgrade will continue.
This mean that in PHP 8 if disk_free_space
is disabled the upgrade will stop.
With this PR the behavior is consistent in all PHP versions. Also it's ok for SEMVER because the prior behavior can be considered a bug.