Make WordPress Core

#59662 closed defect (bug) (invalid)

Clear block theme file caches when editing the theme in the Theme File Editor

Reported by: flixos90's profile flixos90 Owned by: flixos90's profile flixos90
Milestone: Priority: normal
Severity: normal Version:
Component: Themes Keywords:
Focuses: performance Cc:

Description

As originally reported as part of https://core.trac.wordpress.org/ticket/59633#comment:7: Certain data from block theme files is being cached (either via object cache or transient, in different use-cases).

Any of these caches should be programmatically invalidated when editing the theme via the built-in Theme File Editor.

While for regular theme development the WP_DEVELOPMENT_MODE constant (with a value of "theme") should be used, it is not reasonable to expect end users of WordPress that exclusively make use of the Theme File Editor to know about that.

Whenever files of a theme are being edited via the Theme File Editor, any of these caches (introduced between WordPress 6.2 and 6.4 so far) should be invalidated / cleared.

Change History (5)

#1 @joemcgill
16 months ago

As of [56978], these caches will now only be persistent on environments using an object cache (e.g. Redis, Memcached) and will be cleared by a typical flush of the object cache. As we work on ways to extend this type of theme file caching for block themes (see: #59600), we will need to ensure editing these files via the Theme File Editor clears those caches.

#2 @flixos90
16 months ago

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

This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.


14 months ago

#4 @spacedmonkey
14 months ago

Can you sure it doesn't?

When wp_edit_theme_plugin_file is called, it calls $theme->cache_delete();. See these lines.

cache_delete method calls delete_pattern_cache. See the code.

I did check this when implementing this feature.

#5 @flixos90
13 months ago

  • Keywords needs-patch needs-unit-tests removed
  • Milestone 6.5 deleted
  • Resolution set to invalid
  • Status changed from assigned to closed
  • Version 6.2 deleted

Thanks @spacedmonkey, you're indeed right. I reviewed and tested this to verify: When editing a theme file, any cached data related to the theme are deleted (via WP_Theme::cache_delete() method).

The only theme related cache not covered by this is the theme_json object cache group. However, as this is a non-persistent group and doesn't operate on a specific theme but rather applies to whatever the current theme is, it is neither necessary nor appropriate to clear that cache when editing a theme file.

Per the above, I'll close this ticket as invalid (as it was already addressed before it was opened).

Note: See TracTickets for help on using tickets.