[wp-trac] [WordPress Trac] #62061: Prepare for PHP 8.4
WordPress Trac
noreply at wordpress.org
Fri Sep 27 17:52:06 UTC 2024
#62061: Prepare for PHP 8.4
---------------------------------------------+-----------------------------
Reporter: jrf | Owner: (none)
Type: task (blessed) | Status: new
Priority: normal | Milestone: 6.7
Component: General | Version:
Severity: normal | Resolution:
Keywords: php-84 has-patch has-unit-tests | Focuses: php-
| compatibility
---------------------------------------------+-----------------------------
Comment (by hellofromTonya):
In [changeset:"59105" 59105]:
{{{
#!CommitTicketReference repository="" revision="59105"
Code Modernization: Fix trigger_error() with E_USER_ERROR deprecation in
Text_Diff::_check().
PHP 8.4 deprecates the use of `trigger_errror()` with `E_USER_ERROR` as
the error level, as there are a number of gotchas to this way of creating
a `Fatal Error` (`finally` blocks not executing, destructors not
executing). The recommended replacements are either to use exceptions or
to do a hard `exit`.
This is an unmaintained external dependency; thus, the fix is made in the
WP specific copy of the dependency.
Now, there were basically three options:
* Silence the deprecation until PHP 9.0 and delay properly solving this
until then.
This would lead to an awkward solution, as prior to PHP 8.0, error
silencing would apply to all errors, while, as of PHP 8.0, it will no
longer apply to fatal errors.
It also would only buy us some time and wouldn't actually solve
anything.
* Use `exit($status)`.
This would make the code untestable and would disable handling of
these errors via custom error handlers, which makes this an undesirable
solution.
* Throw an exception.
This makes for the most elegant solution with the least BC-breaking
impact.
The third option is implemented which:
* Introduces a new `Text_Exception` class.
* Starts using that in the `Text_Diff::_check()` method in all applicable
places.
* Adds tests for the first two error conditions.
References:
*
https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error
* https://www.php.net/manual/en/migration80.incompatible.php
Follow-up to [59070], [52978], [7747].
Props jrf.
See #62061.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62061#comment:39>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list