From 70aa7f9607e123848b3bd24807607e4f5a0c0d10 Mon Sep 17 00:00:00 2001 From: nacin Date: Fri, 30 Mar 2012 14:39:05 +0000 Subject: [PATCH] Clear theme cache after editing. Reduce default cache persistence to 1800. (Could go lower.) see #20331. git-svn-id: http://svn.automattic.com/wordpress/trunk@20328 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/theme-editor.php | 1 + wp-includes/class-wp-theme.php | 5 ++++- wp-includes/theme.php | 5 ++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php index 5f29a408b0..a84aebeb31 100644 --- a/wp-admin/theme-editor.php +++ b/wp-admin/theme-editor.php @@ -94,6 +94,7 @@ case 'update': fwrite( $f, $newcontent ); fclose( $f ); $location .= '&updated=true'; + $theme->cache_delete(); } } wp_redirect( $location ); diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index c5eea5c24a..85b4584afc 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -154,7 +154,7 @@ final class WP_Theme implements ArrayAccess { * @access private * @var bool */ - private static $cache_expiration = 7200; + private static $cache_expiration = 1800; /** * Constructor for WP_Theme. @@ -503,6 +503,9 @@ final class WP_Theme implements ArrayAccess { public function cache_delete() { foreach ( array( 'theme', 'screenshot', 'screenshot_count', 'files', 'headers', 'page_templates' ) as $key ) wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' ); + $this->template = $this->textdomain_loaded = $this->theme_root_uri = $this->parent = $this->errors = $this->headers_sanitized = $this->name_translated = null; + $this->headers = array(); + $this->__construct( $this->stylesheet, $this->theme_root ); } /** diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 40cb5b4bb7..8bfdd74a52 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -351,10 +351,9 @@ function search_theme_directories( $force = false ) { return $found_themes; } if ( ! is_int( $cache_expiration ) ) - $cache_expiration = 7200; + $cache_expiration = 1800; // half hour } else { - // Two hours is the default. - $cache_expiration = 7200; + $cache_expiration = 1800; // half hour } /* Loop the registered theme directories and extract all themes */