BUGFIX #4974: Improve accuracy of ManifestBuilder::parse_file() cache, to remove a source of upgrade bugs. (from r99738)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102877 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-14 05:36:56 +00:00
parent 1f5654ed19
commit 36d7efb95c

View File

@ -414,9 +414,12 @@ class ManifestBuilder {
if(!$file) return; if(!$file) return;
// We cache the parse results of each file, since only a few files will have changed between flushings // We cache the parse results of each file, since only a few files will have changed between flushings
// And, although it's accurate, TokenisedRegularExpression isn't particularly fast // And, although it's accurate, TokenisedRegularExpression isn't particularly fast.
$parseCacheFile = TEMP_FOLDER . "/manifestClassParse-" . str_replace(array("/",":", "\\"),"_", realpath($filename)); // We use an MD5 of the file as a part of the cache key because using datetime caused problems when users
if(!file_exists($parseCacheFile) || filemtime($parseCacheFile) < filemtime($filename)) { // were upgrading their sites
$fileMD5 = md5($file);
$parseCacheFile = TEMP_FOLDER . "/manifestClassParse-" . str_replace(array("/",":", "\\"),"_", realpath($filename)) . "-$fileMD5";
if(!file_exists($parseCacheFile)) {
$tokens = token_get_all($file); $tokens = token_get_all($file);
$classes = self::getClassDefParser()->findAll($tokens); $classes = self::getClassDefParser()->findAll($tokens);
$interfaces = self::getInterfaceDefParser()->findAll($tokens); $interfaces = self::getInterfaceDefParser()->findAll($tokens);