aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Updater.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-05-29 16:10:32 +0200
committerArthurHoaro <arthur@hoa.ro>2016-06-11 09:30:56 +0200
commitda10377b3c263d96a46cf9101c202554343d2cd0 (patch)
treed91d1fcdbd79367418007add4d135d3f84e57a04 /application/Updater.php
parenteeea1c3daa87f133c57c96fa17ed26b02c392636 (diff)
downloadShaarli-da10377b3c263d96a46cf9101c202554343d2cd0.tar.gz
Shaarli-da10377b3c263d96a46cf9101c202554343d2cd0.tar.zst
Shaarli-da10377b3c263d96a46cf9101c202554343d2cd0.zip
Rename configuration keys and fix GLOBALS in templates
Diffstat (limited to 'application/Updater.php')
-rw-r--r--application/Updater.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/application/Updater.php b/application/Updater.php
index 8552850c..31630ff5 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -109,8 +109,8 @@ class Updater
109 { 109 {
110 $conf = ConfigManager::getInstance(); 110 $conf = ConfigManager::getInstance();
111 111
112 if (is_file($conf->get('config.DATADIR') . '/options.php')) { 112 if (is_file($conf->get('path.data_dir') . '/options.php')) {
113 include $conf->get('config.DATADIR') . '/options.php'; 113 include $conf->get('path.data_dir') . '/options.php';
114 114
115 // Load GLOBALS into config 115 // Load GLOBALS into config
116 $allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS); 116 $allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS);
@@ -121,7 +121,7 @@ class Updater
121 } 121 }
122 } 122 }
123 $conf->write($this->isLoggedIn); 123 $conf->write($this->isLoggedIn);
124 unlink($conf->get('config.DATADIR').'/options.php'); 124 unlink($conf->get('path.data_dir').'/options.php');
125 } 125 }
126 126
127 return true; 127 return true;
@@ -139,14 +139,15 @@ class Updater
139 $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true))); 139 $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true)));
140 $this->linkDB[$link['linkdate']] = $link; 140 $this->linkDB[$link['linkdate']] = $link;
141 } 141 }
142 $this->linkDB->savedb($conf->get('config.PAGECACHE')); 142 $this->linkDB->savedb($conf->get('path.page_cache'));
143 return true; 143 return true;
144 } 144 }
145 145
146 /** 146 /**
147 * Move old configuration in PHP to the new config system in JSON format. 147 * Move old configuration in PHP to the new config system in JSON format.
148 * 148 *
149 * Will rename 'config.php' into 'config.save.php' and create 'config.json'. 149 * Will rename 'config.php' into 'config.save.php' and create 'config.json.php'.
150 * It will also convert legacy setting keys to the new ones.
150 */ 151 */
151 public function updateMethodConfigToJson() 152 public function updateMethodConfigToJson()
152 { 153 {
@@ -164,15 +165,21 @@ class Updater
164 $conf->setConfigIO($configJson); 165 $conf->setConfigIO($configJson);
165 $conf->reload(); 166 $conf->reload();
166 167
168 $legacyMap = array_flip(ConfigPhp::$LEGACY_KEYS_MAPPING);
167 foreach (ConfigPhp::$ROOT_KEYS as $key) { 169 foreach (ConfigPhp::$ROOT_KEYS as $key) {
168 $conf->set($key, $oldConfig[$key]); 170 $conf->set($legacyMap[$key], $oldConfig[$key]);
169 } 171 }
170 172
171 // Set sub config keys (config and plugins) 173 // Set sub config keys (config and plugins)
172 $subConfig = array('config', 'plugins'); 174 $subConfig = array('config', 'plugins');
173 foreach ($subConfig as $sub) { 175 foreach ($subConfig as $sub) {
174 foreach ($oldConfig[$sub] as $key => $value) { 176 foreach ($oldConfig[$sub] as $key => $value) {
175 $conf->set($sub .'.'. $key, $value); 177 if (isset($legacyMap[$sub .'.'. $key])) {
178 $configKey = $legacyMap[$sub .'.'. $key];
179 } else {
180 $configKey = $sub .'.'. $key;
181 }
182 $conf->set($configKey, $value);
176 } 183 }
177 } 184 }
178 185