[wp-trac] [WordPress Trac] #61103: update all update_option calling in core to set the autoload option
WordPress Trac
noreply at wordpress.org
Wed Aug 14 17:43:15 UTC 2024
#61103: update all update_option calling in core to set the autoload option
--------------------------------+--------------------------
Reporter: pbearne | Owner: pbearne
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.7
Component: Options, Meta APIs | Version:
Severity: normal | Resolution:
Keywords: has-patch early | Focuses: performance
--------------------------------+--------------------------
Comment (by flixos90):
@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.
@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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61103#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list