BUGFIX #5157 If paths are longer than 255 characters, fopen() produces an "Invalid argument" error, shorten the paths by using basename() instead of realpath() on the manifest filename when producing the cache path in ManifestBuilder

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@100861 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-03-11 03:02:44 +00:00 committed by Sam Minnee
parent 3705809ce6
commit 12d1ea9edb

View File

@ -418,7 +418,7 @@ class ManifestBuilder {
// We use an MD5 of the file as a part of the cache key because using datetime caused problems when users
// were upgrading their sites
$fileMD5 = md5($file);
$parseCacheFile = TEMP_FOLDER . "/manifestClassParse-" . str_replace(array("/",":", "\\"),"_", realpath($filename)) . "-$fileMD5";
$parseCacheFile = TEMP_FOLDER . "/manifestClassParse-" . str_replace(array("/", ":", "\\", "."), "_", basename($filename)) . "-$fileMD5";
if(!file_exists($parseCacheFile)) {
$tokens = token_get_all($file);
$classes = self::getClassDefParser()->findAll($tokens);
@ -427,7 +427,8 @@ class ManifestBuilder {
$cacheContent = '<?php
$classes = ' . var_export($classes,true) . ';
$interfaces = ' . var_export($interfaces,true) . ';';
if($fh = fopen($parseCacheFile,'w')) {
if($fh = fopen($parseCacheFile,'wb')) {
fwrite($fh, $cacheContent);
fclose($fh);
}