-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to enable/disable maintenance mode from cli. #8748
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2013 Robin Appelman <icewind@owncloud.com> | ||
* and Stephen Colebrook <scolebrook@mac.com> | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. | ||
* See the COPYING-README file. | ||
*/ | ||
|
||
namespace OC\Core\Command\Maintenance; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class Mode extends Command { | ||
|
||
protected function configure() { | ||
$this | ||
->setName('maintenance:mode') | ||
->setDescription('set maintenance mode') | ||
->addOption( | ||
'on', | ||
null, | ||
InputOption::VALUE_NONE, | ||
'enable maintenance mode' | ||
) | ||
->addOption( | ||
'off', | ||
null, | ||
InputOption::VALUE_NONE, | ||
'disable maintenance mode' | ||
); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) { | ||
if ($input->getOption('on')) { | ||
\OC_Config::setValue('maintenance', true); | ||
$output->writeln('Maintenance mode enabled'); | ||
} elseif ($input->getOption('off')) { | ||
\OC_Config::setValue('maintenance', false); | ||
$output->writeln('Maintenance mode disabled'); | ||
} else { | ||
if (\OC_Config::getValue('maintenance', false)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use elseif instead, which is one level less deep. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From a computation perspective it doesn't make any difference but I prefer this style. There are three available options, on, off and nothing. In the event of nothing, status is displayed which can have two possible values. So determining and returning that status is nested. Representing the 3 options as 4 parts of the same if block because one of the options can have two return values makes it a little less readable to my mind. |
||
$output->writeln('Maintenance mode is currently enabled'); | ||
} else { | ||
$output->writeln('Maintenance mode is currently disabled'); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2014?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the code was written in 2013 by Robin. This is just a cp of singleuser.php with a handful of changes for the different config option. So I left it. Should it be changed to 2014 or 2013-2014?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add another copyright line with 2014 and your name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming that you probably copied singleuser.php to mode.php and then swapped all the logic contained in the actually command class, I am not sure there is anything remaining that would have to attributed to robin.