Permalink
Browse files

BUGFIX #5157 If paths are longer than 255 characters, fopen() produce…

…s an "Invalid argument" error, shorten the paths by using basename() instead of realpath() on the manifest filename when producing the cache path in ManifestBuilder (from r100861)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@108814 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent c57728a commit ccda3bbc20aa0e64415579e7ff7d9edfa247e8db Andreas Piening committed Aug 3, 2010
Showing with 3 additions and 2 deletions.
  1. +3 −2 core/ManifestBuilder.php
View
5 core/ManifestBuilder.php
@@ -418,7 +418,7 @@ private static function parse_file($filename) {
// 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 @@ private static function parse_file($filename) {
$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);
}

0 comments on commit ccda3bb

Please sign in to comment.