mirror of
git://develop.git.wordpress.org/
synced 2025-02-28 02:22:25 +01:00
Hash WP_Theme cache keys to ensure long file paths don't overflow in object backends. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20176 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
02e1841cc4
commit
fe96ac4e95
@ -128,6 +128,14 @@ final class WP_Theme implements ArrayAccess {
|
||||
*/
|
||||
private $textdomain_loaded;
|
||||
|
||||
/**
|
||||
* Stores an md5 hash of the theme root, to function as the cache key.
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $cache_hash;
|
||||
|
||||
/**
|
||||
* Flag for whether the themes cache bucket should be persistently cached.
|
||||
*
|
||||
@ -171,6 +179,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
|
||||
$this->theme_root = $theme_root;
|
||||
$this->stylesheet = $theme_dir;
|
||||
$this->cache_hash = md5( $this->theme_root . '/' . $this->stylesheet );
|
||||
$theme_file = $this->stylesheet . '/style.css';
|
||||
|
||||
$cache = $this->cache_get( 'theme' );
|
||||
@ -440,7 +449,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
* @return bool Return value from wp_cache_add()
|
||||
*/
|
||||
private function cache_add( $key, $data ) {
|
||||
return wp_cache_add( $key . '-' . $this->theme_root . '/' . $this->stylesheet, $data, 'themes', self::$cache_expiration );
|
||||
return wp_cache_add( $key . '-' . $this->cache_hash, $data, 'themes', self::$cache_expiration );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -455,7 +464,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
* @return mixed Retrieved data
|
||||
*/
|
||||
private function cache_get( $key ) {
|
||||
return wp_cache_get( $key . '-' . $this->theme_root . '/' . $this->stylesheet, 'themes' );
|
||||
return wp_cache_get( $key . '-' . $this->cache_hash, 'themes' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -466,7 +475,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
*/
|
||||
public function cache_delete() {
|
||||
foreach ( array( 'theme', 'screenshot', 'screenshot_count', 'files', 'headers' ) as $key )
|
||||
wp_cache_delete( $key . '-' . $this->theme_root . '/' . $this->stylesheet, 'themes' );
|
||||
wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user