aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Updater.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/Updater.php')
-rw-r--r--application/Updater.php43
1 files changed, 42 insertions, 1 deletions
diff --git a/application/Updater.php b/application/Updater.php
index 6b92af3d..8552850c 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -142,6 +142,48 @@ class Updater
142 $this->linkDB->savedb($conf->get('config.PAGECACHE')); 142 $this->linkDB->savedb($conf->get('config.PAGECACHE'));
143 return true; 143 return true;
144 } 144 }
145
146 /**
147 * Move old configuration in PHP to the new config system in JSON format.
148 *
149 * Will rename 'config.php' into 'config.save.php' and create 'config.json'.
150 */
151 public function updateMethodConfigToJson()
152 {
153 $conf = ConfigManager::getInstance();
154
155 // JSON config already exists, nothing to do.
156 if ($conf->getConfigIO() instanceof ConfigJson) {
157 return true;
158 }
159
160 $configPhp = new ConfigPhp();
161 $configJson = new ConfigJson();
162 $oldConfig = $configPhp->read($conf::$CONFIG_FILE . '.php');
163 rename($conf->getConfigFile(), $conf::$CONFIG_FILE . '.save.php');
164 $conf->setConfigIO($configJson);
165 $conf->reload();
166
167 foreach (ConfigPhp::$ROOT_KEYS as $key) {
168 $conf->set($key, $oldConfig[$key]);
169 }
170
171 // Set sub config keys (config and plugins)
172 $subConfig = array('config', 'plugins');
173 foreach ($subConfig as $sub) {
174 foreach ($oldConfig[$sub] as $key => $value) {
175 $conf->set($sub .'.'. $key, $value);
176 }
177 }
178
179 try{
180 $conf->write($this->isLoggedIn);
181 return true;
182 } catch (IOException $e) {
183 error_log($e->getMessage());
184 return false;
185 }
186 }
145} 187}
146 188
147/** 189/**
@@ -199,7 +241,6 @@ class UpdaterException extends Exception
199 } 241 }
200} 242}
201 243
202
203/** 244/**
204 * Read the updates file, and return already done updates. 245 * Read the updates file, and return already done updates.
205 * 246 *