[wp-trac] [WordPress Trac] #54826: PHP 8.0: Fatal errors are no longer suppressed by `@`.

WordPress Trac noreply at wordpress.org
Sat Jan 15 05:56:07 UTC 2022

#54826: PHP 8.0: Fatal errors are no longer suppressed by `@`.
 Reporter:  costdev         |      Owner:  (none)
     Type:  task (blessed)  |     Status:  new
 Priority:  normal          |  Milestone:  6.0
Component:  General         |    Version:
 Severity:  normal          |   Keywords:  php8
  Focuses:                  |

 From [https://www.php.net/manual/en/migration80.incompatible.php PHP 8:
 Backward Incompatible Changes]:

  The @ operator will no longer silence fatal errors (E_ERROR,

 **Example case**

 Initially reported by @swb1192 on Slack, a Fatal Error was thrown when
 `disk_free_space()` was called during a plugin update. `disk_free_space()`
 had been disabled by the host.

 In earlier versions of PHP, if a function was unavailable (i.e. disabled
 via `php.ini`), this would silently fail. In PHP 8+, the Fatal Error is

 **Typical fix**

 This is typically fixed by using `function_exists()` before calling the
 function that may be unavailable. If the check fails, return the
 function's documented failure value. In the case of `disk_free_space()`,
 this value is `false`.


 - `disk_free_space()` was reported on a popular plugin which also used the
 function. The issue was resolved by using the fix noted above. Other
 plugins have also used this fix for the same reason.
 - I have reached out in the #hosting-community Slack channel to request
 functions that are commonly disabled on hosting platforms so that we can
 target these functions ahead of other instances being reported.
 - Efforts are ongoing to reduce the use of `@` in Core. However, until
 such time as that has been achieved, the fix above can be used, when
 appropriate, at least as a stop-gap fix.
 - Other occurrences of Fatal Errors when using `@` should be reported here
 so that we can target these, or related tickets linked in the comments
 - There are currently ~269 uses of `@`. 239 of these occur in Core, and 30
 occur upstream.

Ticket URL: <https://core.trac.wordpress.org/ticket/54826>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list