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
Introduce functions to set option autoload value independently in the database #5069
Introduce functions to set option autoload value independently in the database #5069
Conversation
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 really like this. Thanks, @felixarntz. I have a couple questions inline, but am also wondering if we could simplify things by making wp_set_option_autoload()
a wapper that passes a single value to wp_set_options_autoload()
and avoid duplicating the query logic in two places?
@joemcgill In 40714a4, I have updated |
…ep logic for populating caches centralized when values are updated.
…allows setting different autoload values per option.
@boonebgorges @joemcgill This is now ready for another full review. |
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.
This looks much cleaner after your updates, thanks @felixarntz!
*/ | ||
function wp_set_options_autoload( array $options, $autoload ) { | ||
return wp_set_option_autoload_values( | ||
array_fill_keys( $options, $autoload ) |
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.
Clever! ✨
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.
LGTM :)
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.
Thanks @felixarntz for the PR. Left nonblocking feedback.
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
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.
Thanks for the updates @felixarntz! A couple more thoughts:
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.
Thanks for the responses @felixarntz! That's all from me on this one 🙂
Committed in https://core.trac.wordpress.org/changeset/56508 |
Trac ticket: https://core.trac.wordpress.org/ticket/58964
This PR introduces
wp_set_option_autoload()
andwp_set_options_autoload()
functions, which allow updating theautoload
value for an option, or multiple using a single DB request.Both functions also handle updating the respective caches accordingly (
alloptions
vs individual option cache).This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.