Skip to content

Commit fda4656

Browse files
committed
RestrictedVariables: remove usermeta related errors
Includes: * Removing severity change related to this from the VIP Go ruleset. * Removing the sniff tests related to these. * Removing the ruleset tests related to these. Partially fixes 614 Note: "removed" test lines have replaced with blank lines to prevent having to adjust the line numbers for all test after it in the "expected errors/warnings" arrays.
1 parent e9aea8f commit fda4656

File tree

5 files changed

+7
-13
lines changed

5 files changed

+7
-13
lines changed

WordPress-VIP-Go/ruleset-test.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ if ( isset( $_GET['migSource'] ) && wp_verify_nonce( sanitize_text_field( $_GET[
296296

297297

298298

299-
// WordPressVIPMinimum.Variables.RestrictedVariables.user_meta__wpdb__usermeta
300-
$query = "SELECT * FROM $wpdb->usermeta"; // Ok.
299+
300+
301301

302302
// WordPressVIPMinimum.Functions.RestrictedFunctions.site_option_delete_site_option
303303
delete_site_option( $foo ); // Ok.

WordPress-VIP-Go/ruleset.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,6 @@
261261
<!-- We are silencing this one because VIP Go does not use Batcache-->
262262
<severity>0</severity>
263263
</rule>
264-
<rule ref="WordPressVIPMinimum.Variables.RestrictedVariables.user_meta__wpdb__usermeta">
265-
<severity>0</severity>
266-
</rule>
267264
<rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound">
268265
<severity>0</severity>
269266
</rule>

WordPressVIPMinimum/Sniffs/Variables/RestrictedVariablesSniff.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ public function getGroups() {
3939
return [
4040
'user_meta' => [
4141
'type' => 'error',
42-
'message' => 'Usage of users/usermeta tables is highly discouraged in VIP context, For storing user additional user metadata, you should look at User Attributes.',
42+
'message' => 'Usage of users tables is highly discouraged in VIP context',
4343
'object_vars' => [
4444
'$wpdb->users',
45-
'$wpdb->usermeta',
4645
],
4746
],
4847
'session' => [

WordPressVIPMinimum/Tests/Variables/RestrictedVariablesUnitTest.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ $query = "SELECT * FROM $wpdb->users"; // Error.
44

55
$wp_db->update( $wpdb->users, array( 'displayname' => 'Kanobe!' ), array( 'ID' => 1 ) ); // Error.
66

7-
$query = "SELECT * FROM $wpdb->usermeta"; // Error.
87

9-
$wp_db->update( $wpdb->usermeta, array( 'meta_value' => 'bar!' ), array( 'user_id' => 1, 'meta_key' => 'foo' ) ); // Error.
8+
9+
1010

1111
$query = "SELECT * FROM $wpdb->posts"; // Ok.
1212

@@ -20,7 +20,7 @@ $y = $_SERVER['REQUEST_URI']; // Ok.
2020

2121
// Error.
2222
$query = <<<EOD
23-
SELECT * FROM $wpdb->usermeta
23+
SELECT * FROM $wpdb->users
2424
EOD;
2525

2626
// Warning
@@ -29,7 +29,7 @@ Your user-agent is {$_SERVER['HTTP_USER_AGENT']}
2929
EOD;
3030

3131
// phpcs:set WordPressVIPMinimum.Variables.RestrictedVariables exclude[] user_meta
32-
$query = "SELECT * FROM $wpdb->usermeta"; // Ok, excluded.
32+
$query = "SELECT * FROM $wpdb->users"; // Ok, excluded.
3333

3434
// phpcs:set WordPressVIPMinimum.Functions.RestrictedFunctions exclude[]
3535

WordPressVIPMinimum/Tests/Variables/RestrictedVariablesUnitTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ public function getErrorList() {
3030
return [
3131
3 => 1,
3232
5 => 1,
33-
7 => 1,
34-
9 => 1,
3533
23 => 1,
3634
36 => 1,
3735
37 => 1,

0 commit comments

Comments
 (0)