mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
Hash WP_Theme cache keys to ensure long file paths don't overflow in object backends. see #20103.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20176 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d675c19762
commit
24cbb5d9c6
@ -128,6 +128,14 @@ final class WP_Theme implements ArrayAccess {
|
|||||||
*/
|
*/
|
||||||
private $textdomain_loaded;
|
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.
|
* 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->theme_root = $theme_root;
|
||||||
$this->stylesheet = $theme_dir;
|
$this->stylesheet = $theme_dir;
|
||||||
|
$this->cache_hash = md5( $this->theme_root . '/' . $this->stylesheet );
|
||||||
$theme_file = $this->stylesheet . '/style.css';
|
$theme_file = $this->stylesheet . '/style.css';
|
||||||
|
|
||||||
$cache = $this->cache_get( 'theme' );
|
$cache = $this->cache_get( 'theme' );
|
||||||
@ -440,7 +449,7 @@ final class WP_Theme implements ArrayAccess {
|
|||||||
* @return bool Return value from wp_cache_add()
|
* @return bool Return value from wp_cache_add()
|
||||||
*/
|
*/
|
||||||
private function cache_add( $key, $data ) {
|
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
|
* @return mixed Retrieved data
|
||||||
*/
|
*/
|
||||||
private function cache_get( $key ) {
|
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() {
|
public function cache_delete() {
|
||||||
foreach ( array( 'theme', 'screenshot', 'screenshot_count', 'files', 'headers' ) as $key )
|
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…
Reference in New Issue
Block a user