#57771 closed defect (bug) (fixed)
Editor: Fix `true` as the version when using wp_register_style().
Reported by: | hellofromTonya | Owned by: | flixos90 |
---|---|---|---|
Milestone: | 6.2 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | has-patch |
Focuses: | Cc: |
Description
In wp-includes/script-loader.php
and wp-includes/block-supports/duotone.php
, there are multiple instances registering a style via wp_register_style()
where the version number is set to true
.
What's the problem?
true
is not a valid version number. Why? It's type juggled to a value of 1
. Therefore, the version never changes from release-to-release. Thus, there's no cache busting.
What's the default value?
The default value for the $ver
parameter is false
. When false
, the version number is automatically generated to be the current installed WordPress version.
This ticket proposes to review each instance in Core to determine what version number should be used and then fix each instance accordingly.
Change History (9)
#2
follow-up:
↓ 3
@
22 months ago
Thanks for opening a ticket for this @hellofromTonya!
Unless there is a reasonable way to get a version number specifically for this file (reasonable in terms of maintenance effort), we should just use the default value of false
which will lead to the current WordPress version to be used which is a standard practice for many core assets.
#3
in reply to:
↑ 2
@
22 months ago
Replying to flixos90:
Thanks for opening a ticket for this @hellofromTonya!
Unless there is a reasonable way to get a version number specifically for this file (reasonable in terms of maintenance effort), we should just use the default value of
false
which will lead to the current WordPress version to be used which is a standard practice for many core assets.
Unless there's a specific reason to have a unique version number for a specific stylesheet, I agree with you @flixos90 that Core should use its false
default.
#4
@
22 months ago
I prefer a string for the classic-themes
file because it is on the front end and theme-related, though other stylesheets in that category use the modified date (my 6.2
suggestion would be inconsistent).
Setting to false
would update the version number with every major and minor release, and hopefully there will not be a need to adjust the styles in this file again. On the other hand, false
is more reliable, and minor releases are still not highly frequent to worry much about unnecessarily reloading a small stylesheet already in browser cache.
This ticket was mentioned in PR #4120 on WordPress/wordpress-develop by @sabernhardt.
22 months ago
#5
- Keywords has-patch added; needs-patch removed
The $ver
and $media
values should not be true
, and the default $deps
value is already an empty array. This trims each of the register functions to the two important arguments.
#6
@
22 months ago
I changed all to the default false
. The classic theme CSS is still in the middle of other block stylesheets that use the current WordPress version number.
@flixos90 commented on PR #4120:
22 months ago
#9
Committed in https://core.trac.wordpress.org/changeset/55417.
Props to @flixos90 for discovering this issue.
Props @sabernhardt for raising the issue.