WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 3 months ago

#53502 closed defect (bug) (fixed)

Twenty Twenty-One: Remove use of `filemtime()`

Reported by: desrosj Owned by: desrosj
Milestone: 5.8 Priority: normal
Severity: normal Version: 5.6
Component: Bundled Theme Keywords: good-first-bug has-patch commit
Focuses: Cc:

Description

In Twenty Twenty-One, there are two instances of filemtime() to create a version number for a CSS or JS asset.

This should be removed in favor of wp_get_theme()->get( 'Version' ).

Change History (11)

#1 @joyously
3 months ago

I think that was supposed to be temporary...

#2 @SergeyBiryukov
3 months ago

Since there will be a new version of the theme released with WordPress 5.8, would it make sense to include this too, rather than wait for 5.8.1?

This ticket was mentioned in Slack in #core by desrosj. View the logs.


3 months ago

#4 @desrosj
3 months ago

No objection here! Only put it into 5.8.1 to try and allow a newer contributor some time to grab it!

I just shared the ticket in #core on Slack. Let's see if anyone is able to create a patch!

#5 follow-up: @ryelle
3 months ago

Out of curiosity, is there a reason to not use filemtime, or just that it's stable now and should use wp_get_theme()->get( 'Version' )?

This ticket was mentioned in PR #1432 on WordPress/wordpress-develop by peterwilsoncc.


3 months ago

  • Keywords has-patch added; needs-patch removed

#8 in reply to: ↑ 5 @peterwilsoncc
3 months ago

Replying to ryelle:

Out of curiosity, is there a reason to not use filemtime, or just that it's stable now and should use wp_get_theme()->get( 'Version' )?

In certain set ups or using some deployment techniques the file's modified time can change more frequently than the file is modified so browser and proxy caches end up getting broken more often than needed.

#9 @aristath
3 months ago

Makes sense to change it to use the theme-version.

#10 @desrosj
3 months ago

  • Keywords commit added
  • Milestone changed from 5.8.1 to 5.8

#11 @desrosj
3 months ago

  • Owner set to desrosj
  • Resolution set to fixed
  • Status changed from new to closed

In 51236:

Twenty Twenty-One: Use the theme version when enqueueing theme assets.

This avoids having to interact with the filesystem and ensures browser and proxy caches are only cleared when the file is actually updated.

Props peterwilsoncc, ryelle, aristath, SergeyBiryukov.
Fixes #53502.

Note: See TracTickets for help on using tickets.