FIX TemplateManifest prevent cache collision

This commit is contained in:
Will Morgan 2014-05-02 17:51:43 +01:00 committed by Ingo Schommer
parent 4ea2d99cbf
commit 807755f002

View File

@ -38,11 +38,35 @@ class SS_TemplateManifest {
$cacheClass = defined('SS_MANIFESTCACHE') ? SS_MANIFESTCACHE : 'ManifestCache_File'; $cacheClass = defined('SS_MANIFESTCACHE') ? SS_MANIFESTCACHE : 'ManifestCache_File';
$this->cache = new $cacheClass('templatemanifest'.($includeTests ? '_tests' : '')); $this->cache = new $cacheClass('templatemanifest'.($includeTests ? '_tests' : ''));
$this->cacheKey = 'manifest'; $this->cacheKey = $this->getCacheKey($includeTests);
$this->forceRegen = $forceRegen; $this->forceRegen = $forceRegen;
} }
/**
* @return string
*/
public function getBase() {
return $this->base;
}
/**
* Generate a unique cache key to avoid manifest cache collisions.
* We compartmentalise based on the base path, the given project, and whether
* or not we intend to include tests.
* @param boolean $includeTests
* @return string
*/
public function getCacheKey($includeTests = false) {
return sha1(sprintf(
"manifest-%s-%s-%s",
$this->base,
$this->project,
(int) $includeTests // cast true to 1, false to 0
)
);
}
/** /**
* Returns a map of all template information. The map is in the following * Returns a map of all template information. The map is in the following
* format: * format: