<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
namespace Friendica\Console;
use Friendica\App;
-use Friendica\Core\Config\IConfig;
+use Friendica\Core\Config\Capability\IManageConfigValues;
/**
* Sets maintenance mode for this node
*/
private $appMode;
/**
- * @var IConfig
+ * @var IManageConfigValues
*/
private $config;
return $help;
}
- public function __construct(App\Mode $appMode, IConfig $config, $argv = null)
+ public function __construct(App\Mode $appMode, IManageConfigValues $config, $argv = null)
{
parent::__construct($argv);
$this->config = $config;
}
- protected function doExecute()
+ protected function doExecute(): int
{
if ($this->getOption('v')) {
$this->out('Class: ' . __CLASS__);
$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 {