BUGFIX: Fixed file-write testing issues in requirements combined file generation

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@100982 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-03-13 02:54:08 +00:00
parent f057d60adc
commit 3f3c2b2fe9

View File

@ -911,14 +911,23 @@ class Requirements_Backend {
// Process the combined files
$base = Director::baseFolder() . '/';
foreach(array_diff_key($combinedFiles, $this->blocked) as $combinedFile => $dummy) {
if(!is_writable($base . $combinedFile)) {
user_error("Requirements_Backend::process_combined_files(): Couldn't create '$base$combinedFile'", E_USER_WARNING);
continue;
}
$fileList = $this->combine_files[$combinedFile];
$combinedFilePath = $base . $this->combinedFilesFolder . '/' . $combinedFile;
// Make the folder if necessary
if(!file_exists(dirname($combinedFilePath))) {
Filesystem::makeFolder(dirname($combinedFilePath));
}
// If the file isn't writebale, don't even bother trying to make the combined file
// Complex test because is_writable fails if the file doesn't exist yet.
if((file_exists($combinedFilePath) && !is_writable($combinedFilePath)) ||
(!file_exists($combinedFilePath) && !is_writable(dirname($combinedFilePath)))) {
user_error("Requirements_Backend::process_combined_files(): Couldn't create '$combinedFilePath'", E_USER_WARNING);
continue;
}
// Determine if we need to build the combined include
if(file_exists($combinedFilePath) && !isset($_GET['flush'])) {
// file exists, check modification date of every contained file
@ -950,10 +959,6 @@ class Requirements_Backend {
$combinedData .= "/****** FILE: $file *****/\n" . $fileContent . "\n".($isJS ? ';' : '')."\n";
}
if(!file_exists(dirname($combinedFilePath))) {
Filesystem::makeFolder(dirname($combinedFilePath));
}
$successfulWrite = false;
$fh = fopen($combinedFilePath, 'wb');
if($fh) {
@ -965,7 +970,7 @@ class Requirements_Backend {
// Unsuccessful write - just include the regular JS files, rather than the combined one
if(!$successfulWrite) {
user_error("Requirements_Backend::process_combined_files(): Couldn't create '$combinedFilePath'", E_USER_WARNING);
return;
continue;
}
}