@@ -128,6 +128,14 @@ final class WP_Theme implements ArrayAccess {
128128 */
129129 private $ textdomain_loaded ;
130130
131+ /**
132+ * Stores an md5 hash of the theme root, to function as the cache key.
133+ *
134+ * @access private
135+ * @var string
136+ */
137+ private $ cache_hash ;
138+
131139 /**
132140 * Flag for whether the themes cache bucket should be persistently cached.
133141 *
@@ -171,6 +179,7 @@ public function __construct( $theme_dir, $theme_root, $child = null ) {
171179
172180 $ this ->theme_root = $ theme_root ;
173181 $ this ->stylesheet = $ theme_dir ;
182+ $ this ->cache_hash = md5 ( $ this ->theme_root . '/ ' . $ this ->stylesheet );
174183 $ theme_file = $ this ->stylesheet . '/style.css ' ;
175184
176185 $ cache = $ this ->cache_get ( 'theme ' );
@@ -440,7 +449,7 @@ public function parent() {
440449 * @return bool Return value from wp_cache_add()
441450 */
442451 private function cache_add ( $ key , $ data ) {
443- return wp_cache_add ( $ key . '- ' . $ this ->theme_root . ' / ' . $ this -> stylesheet , $ data , 'themes ' , self ::$ cache_expiration );
452+ return wp_cache_add ( $ key . '- ' . $ this ->cache_hash , $ data , 'themes ' , self ::$ cache_expiration );
444453 }
445454
446455 /**
@@ -455,7 +464,7 @@ private function cache_add( $key, $data ) {
455464 * @return mixed Retrieved data
456465 */
457466 private function cache_get ( $ key ) {
458- return wp_cache_get ( $ key . '- ' . $ this ->theme_root . ' / ' . $ this -> stylesheet , 'themes ' );
467+ return wp_cache_get ( $ key . '- ' . $ this ->cache_hash , 'themes ' );
459468 }
460469
461470 /**
@@ -466,7 +475,7 @@ private function cache_get( $key ) {
466475 */
467476 public function cache_delete () {
468477 foreach ( array ( 'theme ' , 'screenshot ' , 'screenshot_count ' , 'files ' , 'headers ' ) as $ key )
469- wp_cache_delete ( $ key . '- ' . $ this ->theme_root . ' / ' . $ this -> stylesheet , 'themes ' );
478+ wp_cache_delete ( $ key . '- ' . $ this ->cache_hash , 'themes ' );
470479 }
471480
472481 /**
0 commit comments