diff options
author | Tonya Mork <hellofromtonya@git.wordpress.org> | 2024-09-27 19:58:49 +0000 |
---|---|---|
committer | Tonya Mork <hellofromtonya@git.wordpress.org> | 2024-09-27 19:58:49 +0000 |
commit | a51f2e45c4a76878dbd0ab90782d44a07b29d13a (patch) | |
tree | 50b6ce987bebc0c7f482011213b0577de92ef211 /tests/phpunit/includes | |
parent | 004379e56b561dfe7ec669a88e6a5124faf36f40 (diff) | |
download | wordpress-a51f2e45c4a76878dbd0ab90782d44a07b29d13a.tar.gz wordpress-a51f2e45c4a76878dbd0ab90782d44a07b29d13a.zip |
Code Modernization: Fix trigger_error() with E_USER_ERROR deprecation in TestXMLParser::parse().
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`.
As this is a test-only class, do not have to take BC-breaks into account.
Also, as this is a test helper, throwing a exception is the most appropriate solution.
Reference:
* https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error
Follow-up to [25002].
Props jrf.
See #62061.
git-svn-id: https://develop.svn.wordpress.org/trunk@59109 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'tests/phpunit/includes')
-rw-r--r-- | tests/phpunit/includes/utils.php | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/tests/phpunit/includes/utils.php b/tests/phpunit/includes/utils.php index 28299e6c14..fae2d73680 100644 --- a/tests/phpunit/includes/utils.php +++ b/tests/phpunit/includes/utils.php @@ -304,13 +304,12 @@ class TestXMLParser { public function parse( $in ) { $parse = xml_parse( $this->xml, $in, true ); if ( ! $parse ) { - trigger_error( + throw new Exception( sprintf( 'XML error: %s at line %d', xml_error_string( xml_get_error_code( $this->xml ) ), xml_get_current_line_number( $this->xml ) - ), - E_USER_ERROR + ) ); xml_parser_free( $this->xml ); } |