[wp-trac] [WordPress Trac] #43228: register_theme_directory() needs to delete the `theme_roots` transient

WordPress Trac noreply at wordpress.org
Mon Feb 5 11:40:45 UTC 2018


#43228: register_theme_directory() needs to delete the `theme_roots` transient
--------------------------+------------------------------------------
 Reporter:  johnbillion   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Themes        |    Version:
 Severity:  normal        |   Keywords:  needs-patch needs-unit-tests
  Focuses:                |
--------------------------+------------------------------------------
 Calling `register_theme_directory( '/path/to/themes' )` adds an element to
 the global `$wp_theme_directories` array.

 When WordPress attempts to load the active theme, it ultimately calls
 `get_theme_roots()` which first checks for a cached value in the
 `theme_roots` transient before looking at the `$wp_theme_directories`
 global. This transient does not get deleted when
 `register_theme_directory()` is called, therefore if `get_theme_roots()`
 gets called before `register_theme_directory()` then the theme directory
 registration will silently fail due to the use of a stale cache of
 registered theme directories.

 `get_theme_roots()` is ultimately called by several theme-related
 functions, such as `wp_get_themes()` and `wp_get_theme()`, so it's
 reasonable to expect that `get_theme_roots()` might get called before
 `register_theme_directory()`.

 `register_theme_directory()` should delete the `theme_roots` cache in
 order to avoid this problem.

 This bug has manifested itself in the WP-CLI theme test scaffolding
 command, which calls `register_theme_directory()` on the
 `muplugins_loaded` hook, which means the `theme_roots` transient has
 already been populated with registered theme directories.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43228>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list