[wp-trac] [WordPress Trac] #20919: Live Preview post-installation fails with multiple theme directories

WordPress Trac wp-trac at lists.automattic.com
Tue Jun 12 15:41:46 UTC 2012


#20919: Live Preview post-installation fails with multiple theme directories
------------------------------+------------------------
 Reporter:  duck_             |       Owner:  nacin
     Type:  defect (bug)      |      Status:  reviewing
 Priority:  normal            |   Milestone:  3.4
Component:  Themes            |     Version:  3.4
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |
------------------------------+------------------------

Comment (by nacin):

 While the issue that [attachment:20919.diff] is a bug, that block of code
 should not be hit here.

 Rather, when a theme is installed or updated, we should be flushing the
 theme cache. We attempt to do this like so:
 {{{
 // Force refresh of theme update information
 delete_site_transient('update_themes');
 foreach ( wp_get_themes() as $theme )
         $theme->cache_delete();
 }}}

 While wp_get_themes() here has been called after the theme is installed,
 it was already called on the page thanks to wp_update_themes(). Thus,
 we're clearing the cache for individual themes, but not for the theme
 roots.

 To allow for testing, we implemented a $force argument to
 search_theme_directories(), which means it skips its local cache. We also
 use this in get_theme_roots() to regenerate the transient if it does not
 exist. So, two options:
  1. Call delete_site_transient( 'theme_roots' ) and let core regenerate it
 on the next call to wp_get_themes().
  2. Forcibly update the theme root transient by calling
 search_theme_directories( true ).

 They are functionally equivalent, but 2 seems like a better option, given
 our intention to force-clear all cache.

 [attachment:20919.2.diff] implements this. Tested.

 ----

 I stuck this at the top of wp_get_themes() for testing:
 {{{
 error_log( 'We have run wp_get_themes()' . "\n    " . remove_query_arg(
 null ) . "\n    Arguments: " . serialize( $args ) . "\n    Backtrace: " .
 wp_debug_backtrace_summary() );
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20919#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list