Skip to content

Commit

Permalink
Merge pull request #25 from klas/master
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisLandry committed Jun 30, 2011
2 parents e3402bf + 89e2cb6 commit c6d66ef
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 13 deletions.
5 changes: 3 additions & 2 deletions libraries/joomla/application/module/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -454,4 +455,4 @@ public static function moduleCache($module, $moduleparams, $cacheparams)

return $ret;
}
}
}
41 changes: 31 additions & 10 deletions libraries/joomla/cache/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

/**
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion libraries/joomla/cache/controller/callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down

0 comments on commit c6d66ef

Please sign in to comment.