Make WordPress Core

Changeset 59106


Ignore:
Timestamp:
09/27/2024 06:17:07 PM (less than one hour ago)
Author:
hellofromTonya
Message:

Code Modernization: Fix trigger_error() with E_USER_ERROR deprecation in Text_Diff_Op::reverse().

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.

As trigger_error() call looks to be a remnant of the PHP 4 era before a class could be declared as abstract, fixed by making both the method as well as the class abstract and removing the call to trigger_error().

Ref:

Follow-up to [7747].

Props jrf.
See #62061.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/Text/Diff.php

    r59105 r59106  
    351351 * @access private
    352352 */
    353 class Text_Diff_Op {
     353abstract class Text_Diff_Op {
    354354
    355355    var $orig;
    356356    var $final;
    357357
    358     function &reverse()
    359     {
    360         trigger_error('Abstract method', E_USER_ERROR);
    361     }
     358    abstract function &reverse();
    362359
    363360    function norig()
Note: See TracChangeset for help on using the changeset viewer.