1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-09 15:46:34 +02:00

missing file notice implemented for groups

This commit is contained in:
Steve Clay
2011-09-03 21:09:43 -04:00
parent 9a1f306305
commit c8e903e24b

View File

@@ -35,7 +35,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
unset($options['minApp']); unset($options['minApp']);
$sources = array(); $sources = array();
$this->selectionId = ''; $this->selectionId = '';
$missingUri = ''; $firstMissingResource = null;
if (isset($_GET['g'])) { if (isset($_GET['g'])) {
// add group(s) // add group(s)
@@ -71,9 +71,16 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
$sources[] = $this->_getFileSource($realpath, $cOptions); $sources[] = $this->_getFileSource($realpath, $cOptions);
} else { } else {
$this->log("The path \"{$file}\" (realpath \"{$realpath}\") could not be found (or was not a file)"); $this->log("The path \"{$file}\" (realpath \"{$realpath}\") could not be found (or was not a file)");
if (null === $firstMissingResource) {
$firstMissingResource = basename($file);
continue;
} else {
$secondMissingResource = basename($file);
$this->log("More than one file was missing: '$firstMissingResource', '$secondMissingResource'");
return $options; return $options;
} }
} }
}
if ($sources) { if ($sources) {
try { try {
$this->checkType($sources[0]); $this->checkType($sources[0]);
@@ -136,11 +143,12 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
$realpath = realpath($path); $realpath = realpath($path);
if (false === $realpath || ! is_file($realpath)) { if (false === $realpath || ! is_file($realpath)) {
$this->log("The path \"{$path}\" (realpath \"{$realpath}\") could not be found (or was not a file)"); $this->log("The path \"{$path}\" (realpath \"{$realpath}\") could not be found (or was not a file)");
if (! $missingUri) { if (null === $firstMissingResource) {
$missingUri = $uri; $firstMissingResource = $uri;
continue; continue;
} else { } else {
$this->log("More than one file was missing: '$missingUri', '$uri'"); $secondMissingResource = $uri;
$this->log("More than one file was missing: '$firstMissingResource', '$secondMissingResource`'");
return $options; return $options;
} }
} }
@@ -160,11 +168,13 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
$this->selectionId .= implode(',', $basenames) . $ext; $this->selectionId .= implode(',', $basenames) . $ext;
} }
if ($sources) { if ($sources) {
if ($missingUri) { if (null !== $firstMissingResource) {
array_unshift($sources, new Minify_Source(array( array_unshift($sources, new Minify_Source(array(
'id' => 'missingFile' 'id' => 'missingFile'
// should not cause cache invalidation
,'lastModified' => 0 ,'lastModified' => 0
,'content' => "/* Minify: missing file '" . ltrim($missingUri, '/') . "' */\n" // due to caching, filename is unreliable.
,'content' => "/* Minify: at least one missing file. See " . Minify::URL_DEBUG . " */\n"
,'minifier' => '' ,'minifier' => ''
))); )));
} }