From b16fb7bb4f3c3a37d8ef46c13a28f256cbf6ef08 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 10 Oct 2014 11:17:15 -0400 Subject: [PATCH] Fixed bug: caching broke CLI tools. --- config/application.config.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/config/application.config.php b/config/application.config.php index a67cd3e2043..10383a89dff 100644 --- a/config/application.config.php +++ b/config/application.config.php @@ -19,13 +19,24 @@ if ($localModules = getenv('VUFIND_LOCAL_MODULES')) { } } -// Set up cache directory: +// Set up cache directory (be sure to keep separate cache for CLI vs. web): $baseDir = ($local = getenv('VUFIND_LOCAL_DIR')) ? $local : 'data'; -$cacheDir = $baseDir . '/cache/configs'; +if (PHP_SAPI == 'cli') { + $cacheDir = $baseDir . '/cache/cli'; + if (!is_dir($cacheDir)) { + mkdir($cacheDir); + } + $cacheDir .= '/configs'; +} else { + $cacheDir = $baseDir . '/cache/configs'; +} if (!is_dir($cacheDir)) { mkdir($cacheDir); } +// Enable caching unless in dev mode or running tests: +$useCache = APPLICATION_ENV != 'development' && !defined('VUFIND_PHPUNIT_RUNNING'); + // Build configuration: return array( 'modules' => array_unique($modules), @@ -33,8 +44,8 @@ return array( 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.php', ), - 'config_cache_enabled' => (APPLICATION_ENV != 'development'), - 'module_map_cache_enabled' => (APPLICATION_ENV != 'development'), + 'config_cache_enabled' => $useCache, + 'module_map_cache_enabled' => $useCache, 'check_dependencies' => (APPLICATION_ENV == 'development'), 'cache_dir' => $cacheDir, 'module_paths' => array( -- GitLab