[wp-trac] [WordPress Trac] #58964: Introduce dedicated function to set autoload value of an option already in the database
WordPress Trac
noreply at wordpress.org
Wed Aug 2 22:18:34 UTC 2023
#58964: Introduce dedicated function to set autoload value of an option already in
the database
--------------------------------+-----------------------------
Reporter: flixos90 | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version:
Severity: normal | Keywords:
Focuses: performance |
--------------------------------+-----------------------------
As outlined with more context in #42441 and #58962, "excessive
autoloading" (i.e. autoloading too many options) can lead to performance
problems, in some cases huge ones that even cause bugs.
Part of the problem comes from options which are autoloaded unnecessarily,
often from stale plugins that were once used on a site but then
deactivated or deleted. While plugins are encouraged to provide
uninstaller routines, deleting all plugin data in itself is problematic in
the way that WordPress handles it (see e.g. #20578 and #31136), and even
then it's not always desired by the end user. However, there is an
argument to make that, as soon as a plugin gets deactivated, the options
that it has added make no sense to be autoloaded anymore, as they will not
be in use at all.
A limitation with that is today WordPress only allows to modify the
`autoload` field of an option by also updating (or adding) the option
value, which is not exactly useful in this context. Therefore this ticket
proposes adding a new function (or potentially set of functions)
specifically to set the `autoload` value of an option - for example
something like `wp_set_option_autoload( $option, $autoload )`. This
provides a single-purpose low-level function that fits directly with other
WordPress option functions.
A somewhat related proposal is found in #55584, however there is an
argument to make that the Settings API is not the right approach for that
(see #55942), since not every plugin using options is using or has to use
the Settings API.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58964>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list