Make WordPress Core

Opened 22 months ago

Closed 22 months ago

Last modified 22 months ago

#57771 closed defect (bug) (fixed)

Editor: Fix `true` as the version when using wp_register_style().

Reported by: hellofromtonya's profile hellofromTonya Owned by: flixos90's profile 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)

#1 @hellofromTonya
22 months ago

Props to @flixos90 for discovering this issue.

Props @sabernhardt for raising the issue.

#2 follow-up: @flixos90
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 @hellofromTonya
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 @sabernhardt
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.

Trac 57771

#6 @sabernhardt
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.

#7 @flixos90
22 months ago

  • Owner set to flixos90
  • Status changed from new to reviewing

#8 @flixos90
22 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 55417:

Editor: Fix invalid parameters being passed to wp_register_style().

Boolean true is not a valid value for the $ver or $media parameters of wp_register_style().

Props sabernhardt, flixos90, hellofromtonya.
Fixes #57771. See #56990, #57688.

Note: See TracTickets for help on using tickets.