BUGFIX: Fixed file-write testing issues in requirements combined file generation (from r100982)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@111556 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-04 04:28:48 +00:00
parent 32038ab3ce
commit 2e66aff365

View File

@ -916,14 +916,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
@ -955,10 +964,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) {
@ -970,7 +975,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;
}
}