Skip to content
Snippets Groups Projects
Commit b9b61426 authored by Ere Maijala's avatar Ere Maijala Committed by Demian Katz
Browse files

Make sure not to concatenate non-existent files. (#1308)

- Logs an error message when missing files are encountered.
parent 3432d0ec
No related merge requests found
...@@ -145,10 +145,10 @@ trait ConcatTrait ...@@ -145,10 +145,10 @@ trait ConcatTrait
/** /**
* Initialize class properties related to concatenation of resources. * Initialize class properties related to concatenation of resources.
* All of the elements to be concatenated into ($this->concatItems) * All of the elements to be concatenated into groups and
* and those that need to remain on their own ($this->otherItems). * and those that need to remain on their own special group 'other'.
* *
* @return void * @return bool True if there are items
*/ */
protected function filterItems() protected function filterItems()
{ {
...@@ -167,10 +167,23 @@ trait ConcatTrait ...@@ -167,10 +167,23 @@ trait ConcatTrait
continue; continue;
} }
$path = $this->getFileType() . '/' . $this->getResourceFilePath($item);
$details = $this->themeInfo->findContainingTheme( $details = $this->themeInfo->findContainingTheme(
$this->getFileType() . '/' . $this->getResourceFilePath($item), $path,
ThemeInfo::RETURN_ALL_DETAILS ThemeInfo::RETURN_ALL_DETAILS
); );
// Deal with special case: $path was not found in any theme.
if (null === $details) {
$errorMsg = "Could not find file '$path' in theme files";
method_exists($this, 'logError')
? $this->logError($errorMsg) : error_log($errorMsg);
$this->groups[] = [
'other' => true,
'item' => $item
];
$groupTypes[] = 'other';
continue;
}
$type = $this->getType($item); $type = $this->getType($item);
$index = array_search($type, $groupTypes); $index = array_search($type, $groupTypes);
......
...@@ -39,8 +39,10 @@ use VuFindTheme\ThemeInfo; ...@@ -39,8 +39,10 @@ use VuFindTheme\ThemeInfo;
* @link https://vufind.org/wiki/development Wiki * @link https://vufind.org/wiki/development Wiki
*/ */
class HeadLink extends \Zend\View\Helper\HeadLink class HeadLink extends \Zend\View\Helper\HeadLink
implements \Zend\Log\LoggerAwareInterface
{ {
use ConcatTrait; use ConcatTrait;
use \VuFind\Log\LoggerAwareTrait;
/** /**
* Theme information service * Theme information service
......
...@@ -39,10 +39,12 @@ use VuFindTheme\ThemeInfo; ...@@ -39,10 +39,12 @@ use VuFindTheme\ThemeInfo;
* @link https://vufind.org/wiki/development Wiki * @link https://vufind.org/wiki/development Wiki
*/ */
class HeadScript extends \Zend\View\Helper\HeadScript class HeadScript extends \Zend\View\Helper\HeadScript
implements \Zend\Log\LoggerAwareInterface
{ {
use ConcatTrait { use ConcatTrait {
getMinifiedData as getBaseMinifiedData; getMinifiedData as getBaseMinifiedData;
} }
use \VuFind\Log\LoggerAwareTrait;
/** /**
* Theme information service * Theme information service
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment