From: Michael M Slusarz Date: Tue, 23 Nov 2010 21:06:26 +0000 (-0700) Subject: Don't do mtime checking in Horde_Themes_Css X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7901770489342821b08935038153d7b885854a1b;p=horde.git Don't do mtime checking in Horde_Themes_Css --- diff --git a/framework/Core/lib/Horde/Themes/Cache.php b/framework/Core/lib/Horde/Themes/Cache.php index 52ee5af42..0473e5c37 100644 --- a/framework/Core/lib/Horde/Themes/Cache.php +++ b/framework/Core/lib/Horde/Themes/Cache.php @@ -36,6 +36,13 @@ class Horde_Themes_Cache implements Serializable protected $_app; /** + * The cache ID. + * + * @var string + */ + protected $_cacheid; + + /** * Theme data. * * @var array @@ -209,20 +216,26 @@ class Horde_Themes_Cache implements Serializable /** */ - protected function _getExpireId() + public function getCacheId() { - switch ($GLOBALS['config']['themescacheparams']['check']) { - case 'appversion': - default: - $id = array($GLOBALS['registry']->getVersion($this->_app)); - if ($this->_app != 'horde') { - $id[] = $GLOBALS['registry']->getVersion('horde'); - } - return 'v:' . implode('|', $id); + if (!isset($this->_cacheid)) { + switch ($GLOBALS['config']['themescacheparams']['check']) { + case 'appversion': + default: + $id = array($GLOBALS['registry']->getVersion($this->_app)); + if ($this->_app != 'horde') { + $id[] = $GLOBALS['registry']->getVersion('horde'); + } + $this->_cacheid = 'v:' . implode('|', $id); + break; - case 'none': - return ''; + case 'none': + $this->_cacheid = ''; + break; + } } + + return $this->_cacheid; } /* Serializable methods. */ @@ -232,7 +245,7 @@ class Horde_Themes_Cache implements Serializable public function serialize() { return serialize(array( - $this->_getExpireId(), + $this->getCacheId(), $this->_app, $this->_data, $this->_theme @@ -250,7 +263,7 @@ class Horde_Themes_Cache implements Serializable $this->_theme ) = unserialize($data); - if ($expire_id && ($expire_id != $this->_getExpireId())) { + if ($expire_id && ($expire_id != $this->getCacheId())) { throw new Exception('Cache invalidated'); } } diff --git a/framework/Core/lib/Horde/Themes/Css.php b/framework/Core/lib/Horde/Themes/Css.php index d82138c31..b027996b3 100644 --- a/framework/Core/lib/Horde/Themes/Css.php +++ b/framework/Core/lib/Horde/Themes/Css.php @@ -16,6 +16,13 @@ class Horde_Themes_Css { /** + * The theme cache ID. + * + * @var string + */ + protected $_cacheid; + + /** * A list of additional stylesheet files to add to the output. * * @var array @@ -54,7 +61,7 @@ class Horde_Themes_Css * Generate the stylesheet URLs needed to display the current page. * Honors configuration choices as to stylesheet caching. * - * @param array $options Additional options: + * @param array $opts Additional options: *
      * 'nohorde' - (boolean) If true, don't load files from Horde.
      * 'sub' - (string) A subdirectory containing additional CSS files to
@@ -67,14 +74,17 @@ class Horde_Themes_Css
      *
      * @return array  The list of URLs to display.
      */
-    public function getStylesheetUrls($options = array())
+    public function getStylesheetUrls(array $opts = array())
     {
         global $conf, $injector, $prefs, $registry;
 
         $themesfs = $registry->get('themesfs');
         $themesuri = $registry->get('themesuri');
 
-        $css = $this->getStylesheets(isset($options['theme']) ? $options['theme'] : $prefs->getValue('theme'), $options);
+        $theme = isset($opts['theme'])
+            ? $opts['theme']
+            : $prefs->getValue('theme');
+        $css = $this->getStylesheets($theme, $opts);
 
         $cache_type = empty($conf['cachecss'])
             ? 'none'
@@ -88,14 +98,8 @@ class Horde_Themes_Css
             return $css_out;
         }
 
-        $mtime = array(0);
         $out = '';
-
-        foreach ($css as $file) {
-            $mtime[] = filemtime($file['fs']);
-        }
-
-        $sig = hash('md5', serialize($css) . max($mtime));
+        $sig = hash('md5', serialize($css) . $this->_cacheid);
 
         switch ($cache_type) {
         case 'filesystem':
@@ -188,6 +192,7 @@ class Horde_Themes_Css
             : $opts['sub'];
 
         $build = $GLOBALS['injector']->getInstance('Horde_Core_Factory_ThemesCache')->create($curr_app, $theme);
+        $this->_cacheid = $build->getCacheId();
 
         foreach ($css_list as $css_name) {
             if (empty($opts['subonly'])) {