X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FConsole%2FMaintenance.php;h=076b89db828279fc8bc7d0b7c97370b5af777747;hb=d4a5a8051ad34a7be72238967afb3e6b140afdc8;hp=080eb092b75856557677375e5cbb76fe7a52ab82;hpb=8010ccdc216fc9caf308346ab750386caa7946e1;p=friendica.git diff --git a/src/Console/Maintenance.php b/src/Console/Maintenance.php index 080eb092b7..076b89db82 100644 --- a/src/Console/Maintenance.php +++ b/src/Console/Maintenance.php @@ -1,18 +1,45 @@ . + * + */ namespace Friendica\Console; -use Friendica\Core; +use Friendica\App; +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 { protected $helpOptions = ['h', 'help', '?']; + /** + * @var App\Mode + */ + private $appMode; + /** + * @var IManageConfigValues + */ + private $config; + protected function getHelp() { $help = <<appMode = $appMode; + $this->config = $config; + } + protected function doExecute(): int + { if ($this->getOption('v')) { $this->out('Class: ' . __CLASS__); $this->out('Arguments: ' . var_export($this->args, true)); @@ -61,22 +94,26 @@ HELP; throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments'); } - if ($a->getMode()->isInstall()) { + if ($this->appMode->isInstall()) { throw new \RuntimeException('Database isn\'t ready or populated yet'); } $enabled = intval($this->getArgument(0)); - Core\Config::set('system', 'maintenance', $enabled); + $transactionConfig = $this->config->beginTransaction(); + + $transactionConfig->set('system', 'maintenance', $enabled); $reason = $this->getArgument(1); if ($enabled && $this->getArgument(1)) { - Core\Config::set('system', 'maintenance_reason', $this->getArgument(1)); + $transactionConfig->set('system', 'maintenance_reason', $this->getArgument(1)); } else { - Core\Config::set('system', 'maintenance_reason', ''); + $transactionConfig->delete('system', 'maintenance_reason'); } + $transactionConfig->commit(); + if ($enabled) { $mode_str = "maintenance mode"; } else {