Skip to content

Commit 8b2ae7d

Browse files
committed
Downgrade switch_to_blog to warning at sniff level
1 parent d672f98 commit 8b2ae7d

File tree

6 files changed

+5
-6
lines changed

6 files changed

+5
-6
lines changed

WordPress-VIP-Go/ruleset.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@
244244
<severity>1</severity>
245245
</rule>
246246
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.switch_to_blog_switch_to_blog">
247-
<type>warning</type>
248247
<severity>3</severity>
249248
</rule>
250249
<rule ref="WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn">

WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getGroups() {
9797
],
9898
// @link https://docs.wpvip.com/technical-references/code-review/vip-notices/#h-switch_to_blog
9999
'switch_to_blog' => [
100-
'type' => 'error',
100+
'type' => 'warning',
101101
'message' => '%s() may not work as expected since it only changes the database context for the blog and does not load the plugins or theme of that site. Filters or hooks on the blog you are switching to will not run.',
102102
'functions' => [
103103
'switch_to_blog',

WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ db_delta(); // Ok - similarly-named function to dbDelta().
5353
dbDelta(); // Error.
5454

5555
switch_blog(); // Ok - similarly-named function to switch_to_blog().
56-
switch_to_blog( $blogid ); // Error.
56+
switch_to_blog( $blogid ); // Warning.
5757

5858
wpcom_vip_get_page_by_title(); // Ok - VIP recommended version of get_page_by_title().
5959
get_page_by_title( $page_title ); // Error.

WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public function getErrorList() {
4040
46 => 1,
4141
50 => 1,
4242
53 => 1,
43-
56 => 1,
4443
59 => 1,
4544
62 => 1,
4645
75 => 1,
@@ -120,6 +119,7 @@ public function getErrorList() {
120119
*/
121120
public function getWarningList() {
122121
return [
122+
56 => 1,
123123
110 => 1,
124124
111 => 1,
125125
114 => 1,

WordPressVIPMinimum/ruleset-test.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ flush_rewrite_rules(); // Error.
321321
$wp_rewrite->flush_rules(); // Error.
322322
attachment_url_to_postid( $url ); // Error.
323323
dbDelta(); // Error.
324-
switch_to_blog( $blogid ); // Error.
324+
switch_to_blog( $blogid ); // Warning.
325325
get_page_by_title( $page_title ); // Error.
326326
url_to_postid( $url ); // Error.
327327
\add_role(); // Error.

WordPressVIPMinimum/ruleset-test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
321 => 1,
9696
322 => 1,
9797
323 => 1,
98-
324 => 1,
9998
325 => 1,
10099
326 => 1,
101100
327 => 1,
@@ -261,6 +260,7 @@
261260
288 => 1,
262261
293 => 1,
263262
294 => 1,
263+
324 => 1,
264264
396 => 1,
265265
397 => 1,
266266
398 => 1,

0 commit comments

Comments
 (0)