Skip to content

Commit 2918bed

Browse files
hellofromtonyapull[bot]
authored andcommitted
Code Modernization: Use wp_trigger_error() in WP_List_Table magic methods.
Replaces `trigger_error()` with `wp_trigger_error()` in each of the `WP_List_Table` magic methods. [56349] 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 [56349], [56356], [56530]. See #58896, #57686. git-svn-id: https://develop.svn.wordpress.org/trunk@56542 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6e72a03 commit 2918bed

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/wp-admin/includes/class-wp-list-table.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ public function __get( $name ) {
186186
return $this->$name;
187187
}
188188

189-
trigger_error(
189+
wp_trigger_error(
190+
__METHOD__,
190191
"The property `{$name}` is not declared. Getting a dynamic property is " .
191192
'deprecated since version 6.4.0! Instead, declare the property on the class.',
192193
E_USER_DEPRECATED
@@ -209,7 +210,8 @@ public function __set( $name, $value ) {
209210
return;
210211
}
211212

212-
trigger_error(
213+
wp_trigger_error(
214+
__METHOD__,
213215
"The property `{$name}` is not declared. Setting a dynamic property is " .
214216
'deprecated since version 6.4.0! Instead, declare the property on the class.',
215217
E_USER_DEPRECATED
@@ -230,7 +232,8 @@ public function __isset( $name ) {
230232
return isset( $this->$name );
231233
}
232234

233-
trigger_error(
235+
wp_trigger_error(
236+
__METHOD__,
234237
"The property `{$name}` is not declared. Checking `isset()` on a dynamic property " .
235238
'is deprecated since version 6.4.0! Instead, declare the property on the class.',
236239
E_USER_DEPRECATED
@@ -252,7 +255,8 @@ public function __unset( $name ) {
252255
return;
253256
}
254257

255-
trigger_error(
258+
wp_trigger_error(
259+
__METHOD__,
256260
"A property `{$name}` is not declared. Unsetting a dynamic property is " .
257261
'deprecated since version 6.4.0! Instead, declare the property on the class.',
258262
E_USER_DEPRECATED

tests/phpunit/tests/admin/wpListTable.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ public function test_should_get_compat_fields( $property_name, $expected ) {
389389
public function test_should_throw_deprecation_when_getting_dynamic_property() {
390390
$this->expectDeprecation();
391391
$this->expectDeprecationMessage(
392+
'WP_List_Table::__get(): ' .
392393
'The property `undeclared_property` is not declared. Getting a dynamic property is ' .
393394
'deprecated since version 6.4.0! Instead, declare the property on the class.'
394395
);
@@ -418,6 +419,7 @@ public function test_should_set_compat_fields_defined_property( $property_name )
418419
public function test_should_throw_deprecation_when_setting_dynamic_property() {
419420
$this->expectDeprecation();
420421
$this->expectDeprecationMessage(
422+
'WP_List_Table::__set(): ' .
421423
'The property `undeclared_property` is not declared. Setting a dynamic property is ' .
422424
'deprecated since version 6.4.0! Instead, declare the property on the class.'
423425
);
@@ -450,6 +452,7 @@ public function test_should_isset_compat_fields( $property_name, $expected ) {
450452
public function test_should_throw_deprecation_when_isset_of_dynamic_property() {
451453
$this->expectDeprecation();
452454
$this->expectDeprecationMessage(
455+
'WP_List_Table::__isset(): ' .
453456
'The property `undeclared_property` is not declared. Checking `isset()` on a dynamic property ' .
454457
'is deprecated since version 6.4.0! Instead, declare the property on the class.'
455458
);
@@ -477,6 +480,7 @@ public function test_should_unset_compat_fields_defined_property( $property_name
477480
public function test_should_throw_deprecation_when_unset_of_dynamic_property() {
478481
$this->expectDeprecation();
479482
$this->expectDeprecationMessage(
483+
'WP_List_Table::__unset(): ' .
480484
'A property `undeclared_property` is not declared. Unsetting a dynamic property is ' .
481485
'deprecated since version 6.4.0! Instead, declare the property on the class.'
482486
);

0 commit comments

Comments
 (0)