From b1a1f51ea8003ae2b4a039787fbcbf6bd71c43c6 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 26 Sep 2014 09:02:18 -0400
Subject: [PATCH] New configuration to optimize production performance.

---
 config/application.config.php              | 57 +++++++++++++---------
 module/VuFind/src/VuFind/Cache/Manager.php |  2 +-
 2 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/config/application.config.php b/config/application.config.php
index f12766dcdef..a67cd3e2043 100644
--- a/config/application.config.php
+++ b/config/application.config.php
@@ -1,14 +1,42 @@
 <?php
-$config = array(
-    'modules' => array(
-        'VuFindHttp', 'VuFindTheme', 'VuFindSearch', 'VuFind', 'VuFindAdmin'
-    ),
+
+// Set up modules:
+$modules = array(
+    'VuFindHttp', 'VuFindTheme', 'VuFindSearch', 'VuFind', 'VuFindAdmin'
+);
+if (PHP_SAPI == 'cli' && !defined('VUFIND_PHPUNIT_RUNNING')) {
+    $modules[] = 'VuFindConsole';
+}
+if (APPLICATION_ENV == 'development') {
+    $modules[] = 'VuFindDevTools';
+}
+if ($localModules = getenv('VUFIND_LOCAL_MODULES')) {
+    $localModules = array_map('trim', explode(',', $localModules));
+    foreach ($localModules as $current) {
+        if (!empty($current)) {
+            $modules[] = $current;
+        }
+    }
+}
+
+// Set up cache directory:
+$baseDir = ($local = getenv('VUFIND_LOCAL_DIR')) ? $local : 'data';
+$cacheDir = $baseDir . '/cache/configs';
+if (!is_dir($cacheDir)) {
+    mkdir($cacheDir);
+}
+
+// Build configuration:
+return array(
+    'modules' => array_unique($modules),
     'module_listener_options' => array(
         'config_glob_paths'    => array(
             'config/autoload/{,*.}{global,local}.php',
         ),
-        'config_cache_enabled' => false,
-        'cache_dir'            => 'data/cache',
+        'config_cache_enabled' => (APPLICATION_ENV != 'development'),
+        'module_map_cache_enabled' => (APPLICATION_ENV != 'development'),
+        'check_dependencies' => (APPLICATION_ENV == 'development'),
+        'cache_dir'            => $cacheDir,
         'module_paths' => array(
             './module',
             './vendor',
@@ -19,19 +47,4 @@ $config = array(
         'factories'    => array(
         ),
     ),
-);
-if (PHP_SAPI == 'cli' && !defined('VUFIND_PHPUNIT_RUNNING')) {
-    $config['modules'][] = 'VuFindConsole';
-}
-if (APPLICATION_ENV == 'development') {
-    $config['modules'][] = 'VuFindDevTools';
-}
-if ($localModules = getenv('VUFIND_LOCAL_MODULES')) {
-    $localModules = array_map('trim', explode(',', $localModules));
-    foreach ($localModules as $current) {
-        if (!empty($current) && !in_array($current, $config['modules'])) {
-            $config['modules'][] = $current;
-        }
-    }
-}
-return $config;
+);
\ No newline at end of file
diff --git a/module/VuFind/src/VuFind/Cache/Manager.php b/module/VuFind/src/VuFind/Cache/Manager.php
index b0cb6c8d018..6e2f344b9b4 100644
--- a/module/VuFind/src/VuFind/Cache/Manager.php
+++ b/module/VuFind/src/VuFind/Cache/Manager.php
@@ -89,7 +89,7 @@ class Manager
         $cacheBase = $this->getCacheDir();
 
         // Set up standard file-based caches:
-        foreach (array('cover', 'language', 'object') as $cache) {
+        foreach (array('config', 'cover', 'language', 'object') as $cache) {
             $this->createFileCache($cache, $cacheBase . $cache . 's');
         }
 
-- 
GitLab