#61939 closed defect (bug) (fixed)
Stop using 'yes' and 'no' for autoloading in favor of recommended boolean
Reported by: | flixos90 | Owned by: | flixos90 |
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Options, Meta APIs | Keywords: | has-patch has-unit-tests commit |
Focuses: | performance | Cc: |
Description
As of WordPress 6.6, add_option()
and update_option()
encourage using a boolean for the $autoload
parameter rather than strings 'yes'
and 'no'
.
#61929 makes the same update to the more recently introduced option autoloading functions from WordPress 6.4.
While the old values remain supported for backward compatibility, it makes sense for core to no longer use strings for the $autoload
parameter of the various function calls.
Note: Also related is #61103, however that ticket is focused on explicitly setting an autoload values where previously none was provided, which is a different purpose (and certainly a more complex one than this right here).
Change History (8)
This ticket was mentioned in PR #7251 on WordPress/wordpress-develop by @flixos90.
5 months ago
#1
- Keywords has-patch has-unit-tests added; needs-patch removed
#2
follow-up:
↓ 3
@
5 months ago
Just noting that changing these values in the upgrade routine and the existing unit tests were an intentional omission when the values were updated in #61045.
I believe that my thinking at the time was that upgrade routines should remain compatible with the version of Core being upgraded by that routine in case something fails during upgrades, and the previous unit tests should stay unchanged to ensure that the changes we made to those APIs were still backwards compatible for folks using the long-established "yes"/"no" values.
In retrospect, I don't think the caution with upgrade routines is warranted since upgrades are being executed using the functions as defined in the version being upgraded to. For the PHPUnit tests, as long as we have other unit tests in place to ensure backwards compatibility for "yes"/"no" values, I see no reason not to update the rest of the unit tests here.
#3
in reply to:
↑ 2
@
5 months ago
Replying to joemcgill:
Just noting that changing these values in the upgrade routine and the existing unit tests were an intentional omission when the values were updated in #61045.
Thanks for raising that. Looking at that changeset [58105], it looks like some of the Update: Never mind, it looks like those were already fixed in another subsequent changeset. :)add_option()
/ update_option()
calls were updated to use 'on'|'off'
, which doesn't look right. They should probably be updated here too to use the booleans. 'on'|'off'
should only be used when dealing with the database values directly. I'll update the PR https://github.com/WordPress/wordpress-develop/pull/7251 to replace the relevant 'on'|'off'
as well.
[...]
In retrospect, I don't think the caution with upgrade routines is warranted since upgrades are being executed using the functions as defined in the version being upgraded to.
Agreed. This is a good point, though the boolean values true|false
have always been supported, so like you're saying this change is still compatible with those older versions.
For the PHPUnit tests, as long as we have other unit tests in place to ensure backwards compatibility for "yes"/"no" values, I see no reason not to update the rest of the unit tests here.
+1, that's what I was thinking and what I've done so far in https://github.com/WordPress/wordpress-develop/pull/7251.
This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.
5 months ago
@flixos90 commented on PR #7251:
5 months ago
#7
Committed in https://core.trac.wordpress.org/changeset/58945
This PR includes no functional changes. All it does change
'yes'
totrue
and'no'
tofalse
in the various function calls where an$autoload
parameter is passed. The only places where'yes'
and'no'
continue to be used is in some PHPUnit tests that are more explicitly about these values (now for backward compatibility).Trac ticket: https://core.trac.wordpress.org/ticket/61939