summaryrefslogtreecommitdiffstats
path: root/core/command
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2014-04-15 17:30:43 +0200
committerAndreas Fischer <bantu@owncloud.com>2014-04-15 17:49:28 +0200
commitd2c7a8ee59d57be1441f771ff00350d5f677999f (patch)
treea2a2d14ad12ba0afb8ee88220aa2f4a99ee4f782 /core/command
parent8e758513c8f7a28300d006fd8b46a1bd01264606 (diff)
downloadnextcloud-server-d2c7a8ee59d57be1441f771ff00350d5f677999f.tar.gz
nextcloud-server-d2c7a8ee59d57be1441f771ff00350d5f677999f.zip
Do not ask for password before input parameter validation.
Diffstat (limited to 'core/command')
-rw-r--r--core/command/db/converttype.php45
1 files changed, 30 insertions, 15 deletions
diff --git a/core/command/db/converttype.php b/core/command/db/converttype.php
index 3382ebb0179..8f3047b8a0b 100644
--- a/core/command/db/converttype.php
+++ b/core/command/db/converttype.php
@@ -43,20 +43,6 @@ class ConvertType extends Command {
parent::__construct();
}
- protected function interact(InputInterface $input, OutputInterface $output) {
- parent::interact($input, $output);
- if (!$input->getOption('password')) {
- /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
- $dialog = $this->getHelperSet()->get('dialog');
- $password = $dialog->askHiddenResponse(
- $output,
- '<question>What is the database password?</question>',
- false
- );
- $input->setOption('password', $password);
- }
- }
-
protected function configure() {
$this
->setName('db:convert-type')
@@ -91,7 +77,7 @@ class ConvertType extends Command {
'password',
null,
InputOption::VALUE_REQUIRED,
- 'the password of the database to convert to. Will be asked when not specified'
+ 'the password of the database to convert to. Will be asked when not specified. Can also be passed via stdin.'
)
->addOption(
'clear-schema',
@@ -131,12 +117,41 @@ class ConvertType extends Command {
}
}
+ protected function readPassword(InputInterface $input, OutputInterface $output) {
+ // Explicitly specified password
+ if ($input->getOption('password')) {
+ return;
+ }
+
+ // Read from stdin
+ $password = file_get_contents('php://stdin');
+ if (trim($password) !== '') {
+ $input->setOption('password', $password);
+ return;
+ }
+
+ // Read password by interacting
+ if ($input->isInteractive()) {
+ /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
+ $dialog = $this->getHelperSet()->get('dialog');
+ $password = $dialog->askHiddenResponse(
+ $output,
+ '<question>What is the database password?</question>',
+ false
+ );
+ $input->setOption('password', $password);
+ return;
+ }
+ }
+
protected function execute(InputInterface $input, OutputInterface $output) {
$inputError = $this->validateInput($input, $output);
if ($inputError) {
return $inputError;
}
+ $this->readPassword($input, $output);
+
$fromDB = \OC_DB::getConnection();
$toDB = $this->getToDBConnection($input, $output);