From 0f39b4f4cdd60f4af5f85d656ed08698e86287ea Mon Sep 17 00:00:00 2001 From: Thomas Bruederli <thomas@roundcube.net> Date: Fri, 28 Jun 2013 16:27:30 -0400 Subject: [PATCH] Enable legacy mode: allow running with old config files and log warnings every no and then --- program/lib/Roundcube/rcube_config.php | 52 +++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 41 insertions(+), 11 deletions(-) diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php index 2190dc4..90bb853 100644 --- a/program/lib/Roundcube/rcube_config.php +++ b/program/lib/Roundcube/rcube_config.php @@ -43,6 +43,8 @@ 'reply_mode' => 'top_posting', 'refresh_interval' => 'keep_alive', 'min_refresh_interval' => 'min_keep_alive', + 'messages_cache_ttl' => 'message_cache_lifetime', + 'redundant_attachments_cache_ttl' => 'redundant_attachments_memcache_ttl', ); @@ -67,13 +69,22 @@ */ private function load() { - // load main config file - if (!$this->load_from_file(RCUBE_CONFIG_DIR . 'main.inc.php')) - $this->errors[] = 'main.inc.php was not found.'; + // Load default settings + if (!$this->load_from_file(RCUBE_CONFIG_DIR . 'defaults.inc.php')) { + $this->errors[] = 'defaults.inc.php was not found.'; + } - // load database config - if (!$this->load_from_file(RCUBE_CONFIG_DIR . 'db.inc.php')) - $this->errors[] = 'db.inc.php was not found.'; + // load main config file + if (!$this->load_from_file(RCUBE_CONFIG_DIR . 'config.inc.php')) { + // Old configuration files + if (!$this->load_from_file(RCUBE_CONFIG_DIR . 'main.inc.php') || + !$this->load_from_file(RCUBE_CONFIG_DIR . 'db.inc.php')) { + $this->errors[] = 'config.inc.php was not found.'; + } + else if (rand(1,100) == 10) { // log warning on every 100th request (average) + trigger_error("config.inc.php was not found. Please migrate your config by running bin/update.sh", E_USER_WARNING); + } + } // load host-specific configuration $this->load_host_config(); @@ -173,8 +184,13 @@ include($fpath); ob_end_clean(); - if (is_array($rcmail_config)) { - $this->prop = array_merge($this->prop, $rcmail_config, $this->userprefs); + if (is_array($config)) { + $this->merge($config); + return true; + } + // deprecated name of config variable + else if (is_array($rcmail_config)) { + $this->merge($rcmail_config); return true; } } @@ -194,9 +210,6 @@ { if (isset($this->prop[$name])) { $result = $this->prop[$name]; - } - else if (isset($this->legacy_props[$name])) { - return $this->get($this->legacy_props[$name], $def); } else { $result = $def; @@ -241,6 +254,7 @@ public function merge($prefs) { $this->prop = array_merge($this->prop, $prefs, $this->userprefs); + $this->fix_legacy_props(); } @@ -272,6 +286,8 @@ $this->userprefs = $prefs; $this->prop = array_merge($this->prop, $prefs); + + $this->fix_legacy_props(); // override timezone settings with client values if ($this->prop['timezone'] == 'auto') { @@ -435,4 +451,18 @@ return date_default_timezone_get(); } + /** + * Convert legacy options into new ones + */ + private function fix_legacy_props() + { + foreach ($this->legacy_props as $new => $old) { + if (isset($this->prop[$old])) { + if (!isset($this->prop[$new])) { + $this->prop[$new] = $this->prop[$old]; + } + unset($this->prop[$old]); + } + } + } } -- Gitblit v1.9.1