[wp-trac] [WordPress Trac] #22501: class-wp-upgrader.php is using the wrong theme directory

WordPress Trac noreply at wordpress.org
Mon Nov 19 04:15:57 UTC 2012


#22501: class-wp-upgrader.php is using the wrong theme directory
-----------------------------+-----------------------------
 Reporter:  toscho           |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Upgrade/Install
  Version:  trunk            |   Severity:  normal
 Keywords:  has-patch        |
-----------------------------+-----------------------------
 There are multiple places in `class-wp-upgrader.php` with a hard coded
 path to `WP_CONTENT_DIR . '/themes'`. Upgrades will fail if the theme
 directory is actually in another place.

 If there is still a `wp-content/themes` directory, the theme will be
 installed into that, but the old theme is used and the upgrade nag doesn’t
 go away.

 If there is no such directory the upgrader dies with an error.

 In both cases the user is stuck with an outdated theme and no ability to
 the new one.

 Test plugin to reproduce this bug:


 {{{
 <?php
 /* Plugin Name: Local Theme Roots */

 add_filter( 'theme_root_uri', 't5_switch_theme_root' );
 add_filter( 'theme_root',     't5_switch_theme_root' );

 /**
  * Create a custom theme directory.
  *
  * @wp-hook theme_root
  * @wp-hook theme_root_uri
  * @author  Thomas Scholz, http://toscho.de
  * @param   string $in URL or path
  * @return  string
  */
 function t5_switch_theme_root( $in )
 {
         if ( 'theme_root_uri' === current_filter() )
                 return 'http://trunk-themes.wp';

         // If we made it so far we are in the 'theme_root' filter.
         $new_root = 'F:\wp.trunk.themes';
         register_theme_directory( $new_root );
         return $new_root;
 }
 }}}


 The solution is to use `get_theme_root()` instead of a fixed path.

 The attached patch does exactly that. Tested on latest Trunk.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22501>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list