Skip to content

Commit

Permalink
FIX TemplateManifest prevent cache collision
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Morgan authored and chillu committed Jul 27, 2014
1 parent 4ea2d99 commit 807755f
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion core/manifest/TemplateManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,35 @@ public function __construct($base, $project, $includeTests = false, $forceRegen
$cacheClass = defined('SS_MANIFESTCACHE') ? SS_MANIFESTCACHE : 'ManifestCache_File';

$this->cache = new $cacheClass('templatemanifest'.($includeTests ? '_tests' : ''));
$this->cacheKey = 'manifest';
$this->cacheKey = $this->getCacheKey($includeTests);

$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
* format:
Expand Down

0 comments on commit 807755f

Please sign in to comment.