WordPress.org

Make WordPress Core

Changeset 20176


Ignore:
Timestamp:
03/14/12 22:49:36 (2 years ago)
Author:
nacin
Message:

Hash WP_Theme cache keys to ensure long file paths don't overflow in object backends. see #20103.

File:
1 edited

Legend:

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

    r20173 r20176  
    130130 
    131131    /** 
     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 
     139    /** 
    132140     * Flag for whether the themes cache bucket should be persistently cached. 
    133141     * 
     
    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 
     
    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 
     
    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 
     
    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 
Note: See TracChangeset for help on using the changeset viewer.