From ca1f5903515426c3c0472d0deebac0c7d51230a6 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Mon, 3 Jul 2017 10:20:08 -0400 Subject: [PATCH] Remove hard-coded path for public cache files. - Respect the VUFIND_LOCAL_CACHE constant. - Resolves VUFIND-1234. --- config/vufind/httpd-vufind.conf | 1 + .../src/VuFindTheme/View/Helper/ConcatTrait.php | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/config/vufind/httpd-vufind.conf b/config/vufind/httpd-vufind.conf index ddbb03a2878..c79d6d3dba8 100644 --- a/config/vufind/httpd-vufind.conf +++ b/config/vufind/httpd-vufind.conf @@ -75,6 +75,7 @@ Alias /vufind /usr/local/vufind/public # encounter unexpected side effects -- while this directory may be outside of the # local settings directory, there should be exactly one separate cache location per # local settings directory. + # If you adjust this, be sure to change the public cache AliasMatch above to match. #SetEnv VUFIND_CACHE_DIR /usr/local/vufind/local/cache # This line specifies additional Zend Framework 2 modules to load after the standard VuFind module. diff --git a/module/VuFindTheme/src/VuFindTheme/View/Helper/ConcatTrait.php b/module/VuFindTheme/src/VuFindTheme/View/Helper/ConcatTrait.php index db948a36f30..1934722c442 100644 --- a/module/VuFindTheme/src/VuFindTheme/View/Helper/ConcatTrait.php +++ b/module/VuFindTheme/src/VuFindTheme/View/Helper/ConcatTrait.php @@ -192,7 +192,12 @@ trait ConcatTrait */ protected function getResourceCacheDir() { - return $this->themeInfo->getBaseDir() . '/../local/cache/public/'; + if (!defined('LOCAL_CACHE_DIR')) { + throw new \Exception( + 'Asset pipeline feature depends on the LOCAL_CACHE_DIR constant.' + ); + } + return LOCAL_CACHE_DIR . '/public/'; } /** @@ -291,8 +296,13 @@ trait ConcatTrait protected function isPipelineActive() { if ($this->usePipeline) { - $cacheDir = $this->getResourceCacheDir(); - if (!is_writable($cacheDir)) { + try { + $cacheDir = $this->getResourceCacheDir(); + } catch (\Exception $e) { + $this->usePipeline = $cacheDir = false; + error_log($e->getMessage()); + } + if ($cacheDir && !is_writable($cacheDir)) { $this->usePipeline = false; error_log("Cannot write to $cacheDir; disabling asset pipeline."); } -- GitLab