WordPress.org

Make WordPress Core

Changeset 42788


Ignore:
Timestamp:
03/05/2018 10:13:36 PM (3 years ago)
Author:
johnbillion
Message:

Themes: Ensure the theme roots cache is cleared when registering a theme directory.

Props soulseekah, johnbillion

Fixes #43228

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r42707 r42788  
    413413        $wp_theme_directories[] = $untrailed;
    414414    }
     415
     416    wp_clean_themes_cache();
    415417
    416418    return true;
  • trunk/tests/phpunit/tests/theme/themeDir.php

    r42343 r42788  
    294294        rmdir( WP_CONTENT_DIR . '/themes/foo-themes' );
    295295    }
     296
     297    /**
     298     * @ticket 43228
     299     */
     300    function test_theme_dir_caches() {
     301        @mkdir( WP_CONTENT_DIR . '/themes/foo' );
     302        @mkdir( WP_CONTENT_DIR . '/themes/foo/bar' );
     303
     304        $old_roots = get_theme_roots();
     305
     306        register_theme_directory( WP_CONTENT_DIR . '/themes/foo' );
     307
     308        $new_roots = get_theme_roots();
     309
     310        rmdir( WP_CONTENT_DIR . '/themes/foo/bar' );
     311        rmdir( WP_CONTENT_DIR . '/themes/foo' );
     312
     313        $this->assertNotEquals( $new_roots, $old_roots );
     314        $this->assertArrayHasKey( 'foo', $new_roots );
     315    }
    296316}
Note: See TracChangeset for help on using the changeset viewer.