From a5eddeab2d4caf625a4a336af8dd2a30228dafd8 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Thu, 7 Sep 2023 20:43:48 +0000 Subject: [PATCH] Code Modernization: Use wp_trigger_error() in WP_User_Query magic methods. Replaces `trigger_error()` with `wp_trigger_error()` in each of the `WP_User_Query` magic methods. [56353] added the dynamic properties deprecation messages to the `__get()`, `__set()`, `__isset()`, `__unset()` magic methods. Since that commit, `wp_trigger_error()` was introduced (see [56530]) as a wrapper for `trigger_error()`. Follow-up to [56353], [56530]. See #58897, #57686. git-svn-id: https://develop.svn.wordpress.org/trunk@56543 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-user-query.php | 12 ++++++++---- tests/phpunit/tests/user/query.php | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php index c5d66404ea..b8b4733cf0 100644 --- a/src/wp-includes/class-wp-user-query.php +++ b/src/wp-includes/class-wp-user-query.php @@ -1122,7 +1122,8 @@ class WP_User_Query { return $this->$name; } - trigger_error( + wp_trigger_error( + __METHOD__, "The property `{$name}` is not declared. Getting a dynamic property is " . 'deprecated since version 6.4.0! Instead, declare the property on the class.', E_USER_DEPRECATED @@ -1145,7 +1146,8 @@ class WP_User_Query { return; } - trigger_error( + wp_trigger_error( + __METHOD__, "The property `{$name}` is not declared. Setting a dynamic property is " . 'deprecated since version 6.4.0! Instead, declare the property on the class.', E_USER_DEPRECATED @@ -1166,7 +1168,8 @@ class WP_User_Query { return isset( $this->$name ); } - trigger_error( + wp_trigger_error( + __METHOD__, "The property `{$name}` is not declared. Checking `isset()` on a dynamic property " . 'is deprecated since version 6.4.0! Instead, declare the property on the class.', E_USER_DEPRECATED @@ -1188,7 +1191,8 @@ class WP_User_Query { return; } - trigger_error( + wp_trigger_error( + __METHOD__, "A property `{$name}` is not declared. Unsetting a dynamic property is " . 'deprecated since version 6.4.0! Instead, declare the property on the class.', E_USER_DEPRECATED diff --git a/tests/phpunit/tests/user/query.php b/tests/phpunit/tests/user/query.php index 6be692af97..4132d1c904 100644 --- a/tests/phpunit/tests/user/query.php +++ b/tests/phpunit/tests/user/query.php @@ -2253,6 +2253,7 @@ class Tests_User_Query extends WP_UnitTestCase { $this->expectDeprecation(); $this->expectDeprecationMessage( + 'WP_User_Query::__get(): ' . 'The property `undefined_property` is not declared. Getting a dynamic property is ' . 'deprecated since version 6.4.0! Instead, declare the property on the class.' ); @@ -2285,6 +2286,7 @@ class Tests_User_Query extends WP_UnitTestCase { $this->expectDeprecation(); $this->expectDeprecationMessage( + 'WP_User_Query::__set(): ' . 'The property `undefined_property` is not declared. Setting a dynamic property is ' . 'deprecated since version 6.4.0! Instead, declare the property on the class.' ); @@ -2321,6 +2323,7 @@ class Tests_User_Query extends WP_UnitTestCase { $this->expectDeprecation(); $this->expectDeprecationMessage( + 'WP_User_Query::__isset(): ' . 'The property `undefined_property` is not declared. Checking `isset()` on a dynamic property ' . 'is deprecated since version 6.4.0! Instead, declare the property on the class.' ); @@ -2352,6 +2355,7 @@ class Tests_User_Query extends WP_UnitTestCase { $this->expectDeprecation(); $this->expectDeprecationMessage( + 'WP_User_Query::__unset(): ' . 'A property `undefined_property` is not declared. Unsetting a dynamic property is ' . 'deprecated since version 6.4.0! Instead, declare the property on the class.' );