diff --git a/libraries/joomla/application/module/helper.php b/libraries/joomla/application/module/helper.php index 2ab0736cf5066..94d9968d0c2f4 100644 --- a/libraries/joomla/application/module/helper.php +++ b/libraries/joomla/application/module/helper.php @@ -405,7 +405,8 @@ public static function moduleCache($module, $moduleparams, $cacheparams) $cache->setCaching(false); } - $cache->setLifeTime($moduleparams->get('cache_time', $conf->get('cachetime') * 60)); + // module cache is set in seconds, global cache in minutes, setLifeTime works in minutes + $cache->setLifeTime($moduleparams->get('cache_time', $conf->get('cachetime') * 60) / 60); $wrkaroundoptions = array ( 'nopathway' => 1, @@ -454,4 +455,4 @@ public static function moduleCache($module, $moduleparams, $cacheparams) return $ret; } -} \ No newline at end of file +} diff --git a/libraries/joomla/cache/cache.php b/libraries/joomla/cache/cache.php index 65f7c59ff583a..4e9c7fc6f25a3 100644 --- a/libraries/joomla/cache/cache.php +++ b/libraries/joomla/cache/cache.php @@ -389,11 +389,16 @@ public function unlock($id,$group=null) * @since 11.1 */ public function &_getStorage() - { - if (!isset($this->_handler)) { - $this->_handler = JCacheStorage::getInstance($this->_options['storage'], $this->_options); - } - return $this->_handler; + { + $hash = md5(serialize($this->_options)); + + if (isset(self::$_handler[$hash])) { + return self::$_handler[$hash]; + } + + self::$_handler[$hash] = JCacheStorage::getInstance($this->_options['storage'], $this->_options); + + return self::$_handler[$hash]; } /** @@ -499,14 +504,30 @@ public static function setWorkarounds($data,$options=array()) // Document head data if ($loptions['nohead'] != 1) { - $cached['head'] = $document->getHeadData(); if ($loptions['modulemode'] == 1) { - unset($cached['head']['title']); - unset($cached['head']['description']); - unset($cached['head']['link']); - unset($cached['head']['metaTags']); + $headnow = $document->getHeadData(); + $unset = array('title', 'description', 'link', 'metaTags'); + + foreach ($unset AS $un) { + unset($headnow[$un]); + unset($options['headerbefore'][$un]); + } + + $cached['head'] = array(); + + // only store what this module has added + foreach ($headnow AS $now=>$value) { + $newvalue = array_diff_assoc($headnow[$now], isset($options['headerbefore'][$now]) ? $options['headerbefore'][$now] : array() ); + if (!empty($newvalue)) { + $cached['head'][$now] = $newvalue; + } + } + + } else { + $cached['head'] = $document->getHeadData(); } + } // Pathway data diff --git a/libraries/joomla/cache/controller/callback.php b/libraries/joomla/cache/controller/callback.php index 571f6a01206e7..4747ca5b43e71 100644 --- a/libraries/joomla/cache/controller/callback.php +++ b/libraries/joomla/cache/controller/callback.php @@ -121,6 +121,15 @@ public function get($callback, $args=array(), $id=false, $wrkarounds=false, $wop } if ($locktest->locked == false) $locktest = $this->cache->lock($id); + + if (isset($woptions['modulemode'])) { + $document = JFactory::getDocument(); + $coptions['modulemode'] = $woptions['modulemode']; + $coptions['headerbefore'] = $document->getHeadData(); + } else { + $coptions['modulemode'] = 0; + } + ob_start(); ob_implicit_flush(false); @@ -134,7 +143,6 @@ public function get($callback, $args=array(), $id=false, $wrkarounds=false, $wop $coptions['nopathway'] = isset($woptions['nopathway']) ? $woptions['nopathway'] : 1; $coptions['nohead'] = isset($woptions['nohead']) ? $woptions['nohead'] : 1; $coptions['nomodules'] = isset($woptions['nomodules']) ? $woptions['nomodules'] : 1; - $coptions['modulemode'] = isset($woptions['modulemode']) ? $woptions['modulemode'] : 0; $cached['output'] = ($wrkarounds == false) ? $output : JCache::setWorkarounds($output, $coptions); $cached['result'] = $result;