-
Notifications
You must be signed in to change notification settings - Fork 40
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
Add sniff to delete_option() + add_option #637
Comments
Do you have any examples on what would be considered in scope? |
Within the same function or method call. |
Starting to work on this one roughly... E.g. the sniff would not flag this as a race condition:
Or this one:
|
Can certainly start with looking at the calls being in consecutive statements. |
What problem would the enhancement address for VIP?
As explained at woocommerce/woocommerce#27696 there is a race condition when
delete_option('foo')
is followed byadd_option('foo', '...')
.Describe the solution you'd like
Having a sniff that looked for a
delete_option()
call followed by anadd_option()
immediatelyor at some point within the same scope, for the same option key, could flag this race condition and suggest using
update_option()
instead.What code should be reported as a violation?
Likely to need some consideration of an option key that is using a variable.
What code should not be reported as a violation?
add_option()
in a different scope.The text was updated successfully, but these errors were encountered: