]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Support sending config as serialized array for older version
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 19 Nov 2017 17:24:56 +0000 (18:24 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Sun, 19 Nov 2017 17:25:17 +0000 (18:25 +0100)
gui/baculum/protected/API/Pages/API/Config.php

index 0ecdb0c842a330899f489ce633707aa37a401dd0..f1c04d248c019ae2ebe9b9bb3ca89ee5a39a3f08 100644 (file)
@@ -36,7 +36,12 @@ class Config extends BaculumAPIServer {
        public function set($id, $params) {
                $config = (array)$params;
                if (array_key_exists('config', $config)) {
-                       $config = json_decode($config['config'], true);
+                       if ($this->getClientVersion() <= 0.2) {
+                               // old way sending config as serialized array
+                               $config = unserialize($config['config']);
+                       } else {
+                               $config = json_decode($config['config'], true);
+                       }
                } else {
                        $config = array();
                }
@@ -51,7 +56,6 @@ class Config extends BaculumAPIServer {
                } else if ($result['is_valid'] === false) {
                        $this->output = BaculaConfigError::MSG_ERROR_CONFIG_VALIDATION_ERROR . print_r($result['result'], true);
                        $this->error = BaculaConfigError::ERROR_CONFIG_VALIDATION_ERROR;
-
                } else {
                        $this->output = BaculaConfigError::MSG_ERROR_WRITE_TO_CONFIG_ERROR . print_r($result['result'], true);
                        $this->error = BaculaConfigError::ERROR_WRITE_TO_CONFIG_ERROR;