-
Notifications
You must be signed in to change notification settings - Fork 22
'FOR UPDATE' check in is_write_query()
#112
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
base: trunk
Are you sure you want to change the base?
Conversation
…'s 2FA implementation
Kudos, SonarCloud Quality Gate passed! |
This causes coupon usage count queries to fail in Woocommerce as well |
…'s 2FA implementation
One downside of this PR is that EDIT: After commenting, I realise HyperDB does support Transactions, but requires a specific comment to specify the data-set, if that comment is specified, although Potentially what is needed here instead, is detecting a transaction starting and then treating all future queries until transaction end as a write query, even if it's a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve this pull request. It fixes an important issue. Tested this solution in my own project and fixed the problem caused by SELECT FOR UPDATE queries.
Apparently my approval means nothing, but if someone with proper permission could approve this, that would be great. HyperDB 1.9 is unusable without this change in my case, and many others.
|
Circling back to this. It's still an issue in latest code, so I've updated the branch to make it merge-able again. |
This change adds `FOR\s+UPDATE` to the regular expression check that is used to determine if a query is trying to write to a database. This better supports queries from other plugins (like Woo or Wordfence) that rely on this MySQL feature. See also: Automattic/HyperDB#112 (comment) Fixes #127.
…that expects `wpdb->query()` to return false on db errors.
…that expects `wpdb->query()` to return false on db errors.
…suppress_errors`.
…spect-suppress-errors
Update from upstream
|
When using Wordfence's 2FA implementation together with HyperDB, the
SELECT ... FOR UPDATE
queries are currently getting interpreted as "not a write query", which causes user authentication to fail on read-only database replicas. My understanding is thatSELECT ... FOR UPDATE
is a write lock solution, so it requires a write-able instance.Here's Wordfence's code, for reference, from
wordfence/modules/login-security/classes/controller/totp.php:54
:I assume Wordfence isn't the only plugin to use write locks like this, so it seems like this "quick and dirty"
is_write_query()
is due for an upgrade. This fix appears to be working for me in production.