Skip to content

Commit e9aea8f

Browse files
committed
RestrictedFunctions: remove user_meta related errors
Includes: * Removing severity changes related to these 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 288ad35 commit e9aea8f

File tree

7 files changed

+20
-50
lines changed

7 files changed

+20
-50
lines changed

WordPress-VIP-Go/ruleset-test.inc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,17 @@ if ( isset( $_GET['migSource'] ) && wp_verify_nonce( sanitize_text_field( $_GET[
284284
$test = sanitize_text_field( $_GET['migSource'] ); // Ok.
285285
}
286286

287-
// WordPressVIPMinimum.Functions.RestrictedFunctions.user_meta_add_user_meta
288-
add_user_meta( 123, $foo, $bar ); // Ok.
289287

290-
// WordPressVIPMinimum.Functions.RestrictedFunctions.user_meta_delete_user_meta
291-
delete_user_meta( $foo, $bar, '123' ); // Ok.
292288

293-
// WordPressVIPMinimum.Functions.RestrictedFunctions.user_meta_get_user_meta
294-
get_user_meta(); // Ok.
295289

296-
// WordPressVIPMinimum.Functions.RestrictedFunctions.user_meta_update_user_meta
297-
update_user_meta( $bar, '123', $foo ); // Ok.
290+
291+
292+
293+
294+
295+
296+
297+
298298

299299
// WordPressVIPMinimum.Variables.RestrictedVariables.user_meta__wpdb__usermeta
300300
$query = "SELECT * FROM $wpdb->usermeta"; // Ok.

WordPress-VIP-Go/ruleset.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,18 +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.Functions.RestrictedFunctions.user_meta_add_user_meta">
265-
<severity>0</severity>
266-
</rule>
267-
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.user_meta_delete_user_meta">
268-
<severity>0</severity>
269-
</rule>
270-
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.user_meta_get_user_meta">
271-
<severity>0</severity>
272-
</rule>
273-
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.user_meta_update_user_meta">
274-
<severity>0</severity>
275-
</rule>
276264
<rule ref="WordPressVIPMinimum.Variables.RestrictedVariables.user_meta__wpdb__usermeta">
277265
<severity>0</severity>
278266
</rule>

WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,6 @@ public function getGroups() {
111111
'add_role',
112112
],
113113
],
114-
'user_meta' => [
115-
'type' => 'error',
116-
'message' => '%s() usage is highly discouraged on WordPress.com VIP due to it being a multisite, please see https://lobby.vip.wordpress.com/wordpress-com-documentation/code-review-what-we-look-for/#wp_users-and-user_meta.',
117-
'functions' => [
118-
'get_user_meta',
119-
'update_user_meta',
120-
'delete_user_meta',
121-
'add_user_meta',
122-
],
123-
],
124114
'term_exists' => [
125115
'type' => 'error',
126116
'message' => '%s() is highly discouraged due to not being cached; please use wpcom_vip_term_exists() instead.',

WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.inc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ $y = Bar::add_role(); // Ok - calling static function of another class and not a
7575
add_role( 'test' ); // Error.
7676
\add_role(); // Error.
7777

78-
get_post_meta( 123, 'test' ); // Ok - not using get_user_meta().
79-
update_post_meta( 1234, 'test', $test ); // Ok - not using update_user_meta().
80-
delete_post_meta( $int, $test ); // Ok - not using delete_user_meta().
81-
add_post_meta( $int, $test, $test ); // Ok - not using add_user_meta().
82-
get_user_meta(); // Error.
83-
update_user_meta(); // Error.
84-
delete_user_meta(); // Error.
85-
add_user_meta(); // Error.
78+
79+
80+
81+
82+
83+
84+
85+
8686

8787
wpcom_vip_term_exists(); // Ok - VIP recommended version of term_exists().
8888
term_exists(); // Error.

WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ public function getErrorList() {
4343
62 => 1,
4444
75 => 1,
4545
76 => 1,
46-
82 => 1,
47-
83 => 1,
48-
84 => 1,
49-
85 => 1,
5046
88 => 1,
5147
91 => 1,
5248
94 => 1,

WordPressVIPMinimum/ruleset-test.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,10 @@ switch_to_blog( $blogid ); // Error.
325325
get_page_by_title( $page_title ); // Error.
326326
url_to_postid( $url ); // Error.
327327
\add_role(); // Error.
328-
get_user_meta(); // Error.
329-
update_user_meta(); // Error.
330-
delete_user_meta(); // Error.
331-
add_user_meta(); // Error.
328+
329+
330+
331+
332332
term_exists(); // Error.
333333
count_user_posts(); // Error.
334334
wp_old_slug_redirect(); // Error.

WordPressVIPMinimum/ruleset-test.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@
9797
325 => 1,
9898
326 => 1,
9999
327 => 1,
100-
328 => 1,
101-
329 => 1,
102-
330 => 1,
103-
331 => 1,
104100
332 => 1,
105101
333 => 1,
106102
334 => 1,

0 commit comments

Comments
 (0)