]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/Updater.php
Replace $GLOBALS configuration with the configuration manager in the whole code base
[github/shaarli/Shaarli.git] / application / Updater.php
index 58c13c07796ca44ada886b061b0b163e2321e302..6b92af3d2d294164235f0feac77c53354051d8b6 100644 (file)
@@ -12,11 +12,6 @@ class Updater
      */
     protected $doneUpdates;
 
-    /**
-     * @var array Shaarli's configuration array.
-     */
-    protected $config;
-
     /**
      * @var LinkDB instance.
      */
@@ -36,14 +31,12 @@ class Updater
      * Object constructor.
      *
      * @param array   $doneUpdates Updates which are already done.
-     * @param array   $config      Shaarli's configuration array.
      * @param LinkDB  $linkDB      LinkDB instance.
      * @param boolean $isLoggedIn  True if the user is logged in.
      */
-    public function __construct($doneUpdates, $config, $linkDB, $isLoggedIn)
+    public function __construct($doneUpdates, $linkDB, $isLoggedIn)
     {
         $this->doneUpdates = $doneUpdates;
-        $this->config = $config;
         $this->linkDB = $linkDB;
         $this->isLoggedIn = $isLoggedIn;
 
@@ -114,19 +107,21 @@ class Updater
      */
     public function updateMethodMergeDeprecatedConfigFile()
     {
-        $config_file = $this->config['config']['CONFIG_FILE'];
+        $conf = ConfigManager::getInstance();
 
-        if (is_file($this->config['config']['DATADIR'].'/options.php')) {
-            include $this->config['config']['DATADIR'].'/options.php';
+        if (is_file($conf->get('config.DATADIR') . '/options.php')) {
+            include $conf->get('config.DATADIR') . '/options.php';
 
             // Load GLOBALS into config
+            $allowedKeys = array_merge(ConfigPhp::$ROOT_KEYS);
+            $allowedKeys[] = 'config';
             foreach ($GLOBALS as $key => $value) {
-                $this->config[$key] = $value;
+                if (in_array($key, $allowedKeys)) {
+                    $conf->set($key, $value);
+                }
             }
-            $this->config['config']['CONFIG_FILE'] = $config_file;
-            writeConfig($this->config, $this->isLoggedIn);
-
-            unlink($this->config['config']['DATADIR'].'/options.php');
+            $conf->write($this->isLoggedIn);
+            unlink($conf->get('config.DATADIR').'/options.php');
         }
 
         return true;
@@ -137,13 +132,14 @@ class Updater
      */
     public function updateMethodRenameDashTags()
     {
+        $conf = ConfigManager::getInstance();
         $linklist = $this->linkDB->filterSearch();
         foreach ($linklist as $link) {
             $link['tags'] = preg_replace('/(^| )\-/', '$1', $link['tags']);
             $link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true)));
             $this->linkDB[$link['linkdate']] = $link;
         }
-        $this->linkDB->savedb($this->config['config']['PAGECACHE']);
+        $this->linkDB->savedb($conf->get('config.PAGECACHE'));
         return true;
     }
 }