Skip to content

Commit 004379e

Browse files
Code Modernization: Fix trigger_error() with E_USER_ERROR deprecation in WP_Test_Stream::open().
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 [49230]. Props jrf. See #62061. git-svn-id: https://develop.svn.wordpress.org/trunk@59108 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b0e35ec commit 004379e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/phpunit/includes/class-wp-test-stream.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private function open( $url ) {
5757
$this->file = $components['path'] ? $components['path'] : '/';
5858

5959
if ( empty( $this->bucket ) ) {
60-
trigger_error( 'Cannot use an empty bucket name', E_USER_ERROR );
60+
throw new Exception( 'Cannot use an empty bucket name' );
6161
}
6262

6363
if ( ! isset( WP_Test_Stream::$data[ $this->bucket ] ) ) {

0 commit comments

Comments
 (0)