X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FConsole%2FMaintenance.php;h=076b89db828279fc8bc7d0b7c97370b5af777747;hb=d4a5a8051ad34a7be72238967afb3e6b140afdc8;hp=9633a50e9d124896f3cba31d971c6995bb811bb8;hpb=03038e7a3bb74bdab497d26b7f829a5c3036d1c2;p=friendica.git diff --git a/src/Console/Maintenance.php b/src/Console/Maintenance.php index 9633a50e9d..076b89db82 100644 --- a/src/Console/Maintenance.php +++ b/src/Console/Maintenance.php @@ -1,14 +1,31 @@ . + * + */ namespace Friendica\Console; use Friendica\App; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\Capability\IManageConfigValues; /** - * @brief Sets maintenance mode for this node - * - * @author Hypolite Petovan + * Sets maintenance mode for this node */ class Maintenance extends \Asika\SimpleConsole\Console { @@ -19,7 +36,7 @@ class Maintenance extends \Asika\SimpleConsole\Console */ private $appMode; /** - * @var IConfiguration + * @var IManageConfigValues */ private $config; @@ -52,7 +69,7 @@ HELP; return $help; } - public function __construct(App\Mode $appMode, IConfiguration $config, $argv = null) + public function __construct(App\Mode $appMode, IManageConfigValues $config, $argv = null) { parent::__construct($argv); @@ -60,7 +77,7 @@ HELP; $this->config = $config; } - protected function doExecute() + protected function doExecute(): int { if ($this->getOption('v')) { $this->out('Class: ' . __CLASS__); @@ -83,16 +100,20 @@ HELP; $enabled = intval($this->getArgument(0)); - $this->config->set('system', 'maintenance', $enabled); + $transactionConfig = $this->config->beginTransaction(); + + $transactionConfig->set('system', 'maintenance', $enabled); $reason = $this->getArgument(1); if ($enabled && $this->getArgument(1)) { - $this->config->set('system', 'maintenance_reason', $this->getArgument(1)); + $transactionConfig->set('system', 'maintenance_reason', $this->getArgument(1)); } else { - $this->config->set('system', 'maintenance_reason', ''); + $transactionConfig->delete('system', 'maintenance_reason'); } + $transactionConfig->commit(); + if ($enabled) { $mode_str = "maintenance mode"; } else {