Skip to content

Commit e7625e5

Browse files
hellofromtonyapull[bot]
authored andcommitted
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
1 parent 2918bed commit e7625e5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/wp-includes/class-wp-user-query.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,8 @@ public function __get( $name ) {
11221122
return $this->$name;
11231123
}
11241124

1125-
trigger_error(
1125+
wp_trigger_error(
1126+
__METHOD__,
11261127
"The property `{$name}` is not declared. Getting a dynamic property is " .
11271128
'deprecated since version 6.4.0! Instead, declare the property on the class.',
11281129
E_USER_DEPRECATED
@@ -1145,7 +1146,8 @@ public function __set( $name, $value ) {
11451146
return;
11461147
}
11471148

1148-
trigger_error(
1149+
wp_trigger_error(
1150+
__METHOD__,
11491151
"The property `{$name}` is not declared. Setting a dynamic property is " .
11501152
'deprecated since version 6.4.0! Instead, declare the property on the class.',
11511153
E_USER_DEPRECATED
@@ -1166,7 +1168,8 @@ public function __isset( $name ) {
11661168
return isset( $this->$name );
11671169
}
11681170

1169-
trigger_error(
1171+
wp_trigger_error(
1172+
__METHOD__,
11701173
"The property `{$name}` is not declared. Checking `isset()` on a dynamic property " .
11711174
'is deprecated since version 6.4.0! Instead, declare the property on the class.',
11721175
E_USER_DEPRECATED
@@ -1188,7 +1191,8 @@ public function __unset( $name ) {
11881191
return;
11891192
}
11901193

1191-
trigger_error(
1194+
wp_trigger_error(
1195+
__METHOD__,
11921196
"A property `{$name}` is not declared. Unsetting a dynamic property is " .
11931197
'deprecated since version 6.4.0! Instead, declare the property on the class.',
11941198
E_USER_DEPRECATED

tests/phpunit/tests/user/query.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,6 +2253,7 @@ public function test_should_throw_deprecation_when_getting_dynamic_property() {
22532253

22542254
$this->expectDeprecation();
22552255
$this->expectDeprecationMessage(
2256+
'WP_User_Query::__get(): ' .
22562257
'The property `undefined_property` is not declared. Getting a dynamic property is ' .
22572258
'deprecated since version 6.4.0! Instead, declare the property on the class.'
22582259
);
@@ -2285,6 +2286,7 @@ public function test_should_throw_deprecation_when_setting_dynamic_property() {
22852286

22862287
$this->expectDeprecation();
22872288
$this->expectDeprecationMessage(
2289+
'WP_User_Query::__set(): ' .
22882290
'The property `undefined_property` is not declared. Setting a dynamic property is ' .
22892291
'deprecated since version 6.4.0! Instead, declare the property on the class.'
22902292
);
@@ -2321,6 +2323,7 @@ public function test_should_throw_deprecation_when_isset_of_dynamic_property() {
23212323

23222324
$this->expectDeprecation();
23232325
$this->expectDeprecationMessage(
2326+
'WP_User_Query::__isset(): ' .
23242327
'The property `undefined_property` is not declared. Checking `isset()` on a dynamic property ' .
23252328
'is deprecated since version 6.4.0! Instead, declare the property on the class.'
23262329
);
@@ -2352,6 +2355,7 @@ public function test_should_throw_deprecation_when_unset_of_dynamic_property() {
23522355

23532356
$this->expectDeprecation();
23542357
$this->expectDeprecationMessage(
2358+
'WP_User_Query::__unset(): ' .
23552359
'A property `undefined_property` is not declared. Unsetting a dynamic property is ' .
23562360
'deprecated since version 6.4.0! Instead, declare the property on the class.'
23572361
);

0 commit comments

Comments
 (0)