diff --git a/module/VuFindTheme/src/VuFindTheme/View/Helper/ConcatTrait.php b/module/VuFindTheme/src/VuFindTheme/View/Helper/ConcatTrait.php index 48aac650f07..853e89602c1 100644 --- a/module/VuFindTheme/src/VuFindTheme/View/Helper/ConcatTrait.php +++ b/module/VuFindTheme/src/VuFindTheme/View/Helper/ConcatTrait.php @@ -227,7 +227,7 @@ protected function filterItems() /** * Get the path to the directory where we can cache files generated by - * this trait. + * this trait. The directory will be created if it does not already exist. * * @return string */ @@ -238,7 +238,14 @@ protected function getResourceCacheDir() 'Asset pipeline feature depends on the LOCAL_CACHE_DIR constant.' ); } - return LOCAL_CACHE_DIR . '/public/'; + // TODO: it might be better to use \VuFind\Cache\Manager here. + $cacheDir = LOCAL_CACHE_DIR . '/public/'; + if (!is_dir($cacheDir) && !file_exists($cacheDir)) { + if (!mkdir($cacheDir)) { + throw new \Exception("Unexpected problem creating cache directory: $cacheDir"); + } + } + return $cacheDir; } /**