#61103 closed defect (bug) (fixed)
update all update_option calling in core to set the autoload option
Reported by: | pbearne | Owned by: | flixos90 |
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Options, Meta APIs | Keywords: | has-patch early |
Focuses: | performance | Cc: |
Description
Let's be set the autoload option so it is clear what is autoloadered
Let's not auto load option only needed in WP-admin or very often to reduce the number always loaded
Change History (34)
This ticket was mentioned in PR #6465 on WordPress/wordpress-develop by @pbearne.
5 months ago
#2
- Keywords has-patch added
This ticket was mentioned in Slack in #core-performance by pbearne. View the logs.
5 months ago
This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.
4 months ago
This ticket was mentioned in Slack in #core-performance by pbearne. View the logs.
4 months ago
#7
@
4 months ago
Why is this needed? Aren't the autoload flags for all these options already set correctly by default anyway? Is there a concern that the flag somehow changes so we have to fix it again?
#8
@
4 months ago
I feel it good practice to set the default to make clear that choice was made
And I feel that some should not be autoload eg admin email and maybe widgets
4 months ago
#9
I have replaced the on/off with booleans
As I have gone through these I have set any option that looks like it is wp-admin only to not autoload this should help the front-end load a little bit
#10
@
4 months ago
I thought it might help to list the options I propose, not to autoload, that are currently not unset in core.
update_option( 'auto_plugin_theme_update_emails', $past_failure_emails, false );
update_option( 'recently_activated', $recently_activated, false );
update_option( '_wp_suggested_policy_text_has_changed', $state, false );
update_option( $lock_option, time(), false );
update_option( 'dashboard_widget_options', $widget_options, false );
update_option( 'ftp_credentials', $stored_credentials, false );
update_option( 'recently_edited', $oldfiles, false );
update_option( 'adminhash', $new_admin_email, false );
update_option( 'nav_menu_options', $nav_menu_option, false );
update_option( 'active_plugins', $current, false );
update_option( 'uninstall_plugins', $uninstallable_plugins, false );
update_option( 'wp_force_deactivated_plugins', array(), false );
update_option( 'delete_blog_hash', $hash, false );
update_option( 'allowedthemes', $allowed_themes, false );
update_option( 'admin_email', $new_admin_detailsnewemail?, false );
update_option( 'recently_activated', $recent, false );
update_option( 'https_detection_errors', $support_errors->errors, false );
update_option( 'fresh_site', '0', false );
update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files", false );
update_option( 'admin_email', , false );
update_option( 'admin_email_lifespan', time() + $remind_interval, false );
src/wp-includes/class-wp-paused-extensions-storage.php
return update_option( $option_name, $paused_extensions, false );
src/wp-includes/class-wp-recovery-mode-key-service.php
return update_option( $this->option_name, $keys, false );
this is one that we may not want to set false
update_option( 'widget_' . $id_base, $widget, false );
Please review this list and comment if any of these need to be autoload (as needed by the front-end)
I hope we can get this change in, as this will free some memory.
#11
follow-up:
↓ 22
@
4 months ago
I feel it good practice to set the default to make clear that choice was made
I thought it might help to list the options I propose, not to autoload, that are currently not unset in core.
Can we achieve this with a one time database migration instead of (or in addition to) changing all update_option
calls.
#12
@
4 months ago
Not all of them can be done, as some are dynamic
But we could do most of them
I will work on the SQL/ update function to do this
This ticket was mentioned in Slack in #core-performance by pbearne. View the logs.
3 months ago
#15
@
3 months ago
- Keywords early added
- Milestone changed from Awaiting Review to 6.7
Hi there!
This ticket discussed in today's performance scrub.
Moving to 6.7 for early consideration.
Additional props: @joemcgill
#16
@
3 months ago
Note to self: use wp_prime_site_option_caches() for all the options not been autoloaded to be loaded in WP-admin
This ticket was mentioned in Slack in #core-performance by pbearne. View the logs.
8 weeks ago
7 weeks ago
#18
Could you fix your bot that keeps mentioning me? I'm getting dozens of notifications a month from this project. https://github.com/WordPress/wordpress-develop/pulls?q=sort%3Aupdated-desc+%22%40paul%22
@peterwilsoncc commented on PR #6465:
7 weeks ago
#19
Could you fix your bot that keeps mentioning me? I'm getting dozens of notifications a month from this project. https://github.com/WordPress/wordpress-develop/pulls?q=sort%3Aupdated-desc+%22%40paul%22
@pbearne Are you able to look at the details in your git config so the bot stops pinging the wrong Paul. It's currently set to paul bearne <paul>
which is causing the bot to be confused.
If you add pbearne@git.wordpress.org
to your GitHub profile and set that as the email address for WordPress-Develop the commits will be assigned correctly.
7 weeks ago
#20
If you add
pbearne@git.wordpress.org
to your GitHub profile and set that as the email address for WordPress-Develop the commits will be assigned correctly.
updated
This ticket was mentioned in Slack in #core-performance by pbearne. View the logs.
6 weeks ago
#22
in reply to:
↑ 11
;
follow-ups:
↓ 24
↓ 25
@
6 weeks ago
Replying to swissspidy:
Can we achieve this with a one time database migration instead of (or in addition to) changing all
update_option
calls.
Yeah, converting a few options to be non-autoloaded seems fine, but changing every update_option()
call in core to specify the default value seems redundant to me.
This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.
5 weeks ago
#24
in reply to:
↑ 22
@
5 weeks ago
Replying to SergeyBiryukov:
Replying to swissspidy:
Can we achieve this with a one time database migration instead of (or in addition to) changing all
update_option
calls.
Yeah, converting a few options to be non-autoloaded seems fine, but changing every
update_option()
call in core to specify the default value seems redundant to me.
This new sniff would require them all to be set https://github.com/WordPress/WordPress-Coding-Standards/issues/2473
#25
in reply to:
↑ 22
@
5 weeks ago
@swissspidy
Can we achieve this with a one time database migration instead of (or in addition to) changing all
update_option
calls.
I'm not sure. I guess the way that core uses options, in most cases update_option()
truly just updates the option (rather than inserting it), so in those cases it's fine to not pass it. But for new options it should be passed. For all the options that are prepopulated during WP installation and never deleted, a once-off migration would work.
@SergeyBiryukov
Yeah, converting a few options to be non-autoloaded seems fine, but changing every
update_option()
call in core to specify the default value seems redundant to me.
Per the above, I think it depends. I think the problem is when update_option()
falls through to add_option()
. For those cases, preferably the $autoload
value should always be explicitly specified.
@pbearne
This new sniff would require them all to be set https://github.com/WordPress/WordPress-Coding-Standards/issues/2473
FWIW, this would be in WordPress-Extra
so wouldn't necessarily apply to WordPress core. Most plugins use options differently than core: Core inserts almost all the options with their defaults upon install, and then update_option()
calls truly update them. Plugins on the other hand often don't "pre-populate" them in the database, but then use update_option()
as "update or add the option if it's not there yet". For the latter, passing $autoload
is more important.
#26
@
3 weeks ago
I just left a thorough review on the PR in https://github.com/WordPress/wordpress-develop/pull/6465#pullrequestreview-2261711999, where I reviewed each potentially modified option individually.
Summarizing here:
- We should only pass an explicit
$autoload
oftrue|false
toupdate_option()
if the option is not added to the database as part of the WordPress installation (and therefore always present when callingupdate_option()
. - For any arbitrary
update_option()
calls where$option
is a variable that could be anything, we should not provide a value either since we have no idea about whether or not to autoload the option. The default valuenull
works best in such cases. - The following options (which are not part of WordPress installation) are set by the PR to no longer be autoloaded, which make sense to me because all of them are only used in one specific admin screen or one specific process that doesn't run on regular page loads:
recently_activated
_wp_suggested_policy_text_has_changed
{upgradeLock}.lock
dashboard_widget_options
ftp_credentials
adminhash
nav_menu_options
wp_force_deactivated_plugins
delete_blog_hash
allowedthemes
{sessionId}_paused_extensions
recovery_keys
https_detection_errors
fresh_site
There are a few other options in the PR that are set to no longer autoload, which I think is risky and should therefore not be included. More complicated options can still be discussed in separate tickets for whether it makes sense to stop autoloading them.
I think once those changes are made, the PR will be in a good state to land.
This ticket was mentioned in Slack in #core-performance by joemcgill. View the logs.
3 weeks ago
This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.
3 weeks ago
#32
@
2 weeks ago
- Keywords changes-requested removed
- Owner changed from pbearne to flixos90
- Status changed from assigned to reviewing
@flixos90 commented on PR #6465:
2 weeks ago
#34
Committed in https://core.trac.wordpress.org/changeset/58975
Adding the
performance
keyword for visibility.