Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove site_option related sniffs/groupings #615

Closed
rebeccahum opened this issue Jan 11, 2021 · 4 comments · Fixed by #639
Closed

Remove site_option related sniffs/groupings #615

rebeccahum opened this issue Jan 11, 2021 · 4 comments · Fixed by #639
Milestone

Comments

@rebeccahum
Copy link
Contributor

Since VIP Go allows multisites, there's no reason to flag for the usage:

'site_option' => [
'type' => 'error',
'message' => '%s() will overwrite network option values, please use the `*_option()` equivalent instead (e.g. `update_option()`).',
'functions' => [
'add_site_option',
'update_site_option',
'delete_site_option',
],
],

It's silenced anyways on WordPress-VIP-Go:

<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.site_option_delete_site_option">
<severity>0</severity>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.site_option_update_site_option">
<severity>0</severity>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.site_option_add_site_option">
<severity>0</severity>
</rule>

@rebeccahum rebeccahum modified the milestone: 3.x Jan 11, 2021
@jrfnl
Copy link
Collaborator

jrfnl commented Mar 2, 2021

Same as for #614:

Loosely related to #600.

The difference between #600 and these changes, is that these are not breaking changes as no sniffs are removed, only error codes (and groups).

This means that this change might make some inline ignore annotations redundant and possibly make some values in custom properties in rulesets redundant, but other than that, it will not break rulesets and it will not break runs.

In other words, these changes are "allowed" to go into a next minor and don't need to wait for the next major (though a choice can be made to let this wait for the next major anyway).

@jrfnl
Copy link
Collaborator

jrfnl commented Mar 2, 2021

Open question - there are more multisite related restricted functions, should those be allowed now as well ?

'get_super_admins' => [
'type' => 'error',
'message' => '`%s` is prohibited on the WordPress.com VIP platform.',
'functions' => [
'get_super_admins',
],
],

// @link WordPress.com: https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#switch_to_blog
// @link VIP Go: https://wpvip.com/documentation/vip-go/code-review-blockers-warnings-notices/#switch_to_blog
'switch_to_blog' => [
'type' => 'error',
'message' => '%s() is not something you should ever need to do in a VIP theme context. Instead use an API (XML-RPC, REST) to interact with other sites if needed.',
'functions' => [
'switch_to_blog',
],
],

@jrfnl
Copy link
Collaborator

jrfnl commented Mar 2, 2021

Just saw #616 which answers the first part of the question (removing get_super_admins restriction).

@rebeccahum
Copy link
Contributor Author

For the switch_to_blog, we have a custom error message for it at:

<message>Switch to blog 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. This means that filters or hooks that the blog you are switching to uses will not run.</message>

I think we can change the type to warning and the message directly on the sniff?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants