From 1f9622d88cf413282aefc92ddb0214d08a596082 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 31 Aug 2016 12:49:28 +0200 Subject: [PATCH 1/8] [3rparty] Bump symfony/console --- 3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty b/3rdparty index 1b3ecc4859..cb417c7c77 160000 --- a/3rdparty +++ b/3rdparty @@ -1 +1 @@ -Subproject commit 1b3ecc4859174daf3ea39400d689db87e0672e31 +Subproject commit cb417c7c7795fe2f8b1be5c1d13c0a1b378a033a From 8a5af2d335da21c8f12b9f08773e95982572d40d Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 31 Aug 2016 13:52:26 +0200 Subject: [PATCH 2/8] Fix tests * hasParameterOption has an additional default value which we must match in the return map * Fix deprecated getMock calls --- tests/Core/Command/Config/App/GetConfigTest.php | 4 ++-- .../Core/Command/Config/System/GetConfigTest.php | 4 ++-- tests/Core/Command/User/SettingTest.php | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/Core/Command/Config/App/GetConfigTest.php b/tests/Core/Command/Config/App/GetConfigTest.php index 2fac1572e3..7ea3fbb587 100644 --- a/tests/Core/Command/Config/App/GetConfigTest.php +++ b/tests/Core/Command/Config/App/GetConfigTest.php @@ -138,8 +138,8 @@ class GetConfigTest extends TestCase { $this->consoleInput->expects($this->any()) ->method('hasParameterOption') ->willReturnMap([ - ['--output', true], - ['--default-value', $hasDefault], + ['--output', false, true], + ['--default-value', false, $hasDefault], ]); if ($expectedMessage !== null) { diff --git a/tests/Core/Command/Config/System/GetConfigTest.php b/tests/Core/Command/Config/System/GetConfigTest.php index 943cc4cfa4..fd5db69fec 100644 --- a/tests/Core/Command/Config/System/GetConfigTest.php +++ b/tests/Core/Command/Config/System/GetConfigTest.php @@ -147,8 +147,8 @@ class GetConfigTest extends TestCase { $this->consoleInput->expects($this->any()) ->method('hasParameterOption') ->willReturnMap([ - ['--output', true], - ['--default-value', $hasDefault], + ['--output', false, true], + ['--default-value', false,$hasDefault], ]); if ($expectedMessage !== null) { diff --git a/tests/Core/Command/User/SettingTest.php b/tests/Core/Command/User/SettingTest.php index 56db670657..784183c72c 100644 --- a/tests/Core/Command/User/SettingTest.php +++ b/tests/Core/Command/User/SettingTest.php @@ -99,14 +99,14 @@ class SettingTest extends TestCase { [ [['uid', 'username'], ['key', 'configkey']], [['ignore-missing-user', true]], - [['--default-value', true]], + [['--default-value', false, true]], false, false, ], [ [['uid', 'username'], ['key', '']], [['ignore-missing-user', true]], - [['--default-value', true]], + [['--default-value', false, true]], false, 'The "default-value" option can only be used when specifying a key.', ], @@ -128,7 +128,7 @@ class SettingTest extends TestCase { [ [['uid', 'username'], ['key', 'configkey'], ['value', '']], [['ignore-missing-user', true]], - [['--default-value', true]], + [['--default-value', false, true]], false, 'The value argument can not be used together with "default-value".', ], @@ -164,7 +164,7 @@ class SettingTest extends TestCase { [ [['uid', 'username'], ['key', 'configkey']], [['ignore-missing-user', true], ['delete', true]], - [['--default-value', true]], + [['--default-value', false, true]], false, 'The "delete" option can not be used together with "default-value".', ], @@ -283,8 +283,8 @@ class SettingTest extends TestCase { $this->consoleInput->expects($this->atLeastOnce()) ->method('hasParameterOption') ->willReturnMap([ - ['--delete', true], - ['--error-if-not-exists', $errorIfNotExists], + ['--delete', false, true], + ['--error-if-not-exists', false, $errorIfNotExists], ]); if ($expectedLine === null) { @@ -349,7 +349,7 @@ class SettingTest extends TestCase { $this->consoleInput->expects($this->atLeastOnce()) ->method('hasParameterOption') ->willReturnMap([ - ['--update-only', $updateOnly], + ['--update-only', false, $updateOnly], ]); if ($expectedLine === null) { @@ -423,7 +423,7 @@ class SettingTest extends TestCase { $this->consoleInput->expects($this->atLeastOnce()) ->method('hasParameterOption') ->willReturnMap([ - ['--default-value', true], + ['--default-value', false, true], ]); $this->consoleInput->expects($this->once()) ->method('getOption') From 1ec5e8a1abfd71b1b587ebba5acdf7d8aaf1d913 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 6 Sep 2016 20:35:10 +0200 Subject: [PATCH 3/8] Switch user:report from deprecated tablehelper to table --- core/Command/User/Report.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/Command/User/Report.php b/core/Command/User/Report.php index 01eb51f17f..9a3bd9e590 100644 --- a/core/Command/User/Report.php +++ b/core/Command/User/Report.php @@ -27,6 +27,7 @@ namespace OC\Core\Command\User; use OCP\IUserManager; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -49,8 +50,7 @@ class Report extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { - /** @var \Symfony\Component\Console\Helper\TableHelper $table */ - $table = $this->getHelperSet()->get('table'); + $table = new Table($output); $table->setHeaders(array('User Report', '')); $userCountArray = $this->countUsers(); if(!empty($userCountArray)) { @@ -72,7 +72,7 @@ class Report extends Command { $rows[] = array('user directories', $userDirectoryCount); $table->setRows($rows); - $table->render($output); + $table->render(); } private function countUsers() { From a9c6c351cb5a83196ce3baff3c47f3ba957566ff Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 6 Sep 2016 20:48:22 +0200 Subject: [PATCH 4/8] Move to question helper --- core/Command/User/Add.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/core/Command/User/Add.php b/core/Command/User/Add.php index a0ca331515..368f06cba8 100644 --- a/core/Command/User/Add.php +++ b/core/Command/User/Add.php @@ -28,6 +28,7 @@ use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -94,18 +95,16 @@ class Add extends Command { return 1; } } elseif ($input->isInteractive()) { - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); - $password = $dialog->askHiddenResponse( - $output, - 'Enter password: ', - false - ); - $confirm = $dialog->askHiddenResponse( - $output, - 'Confirm password: ', - false - ); + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); + + $question = new Question('Enter password: '); + $question->setHidden(true); + $password = $helper->ask($input, $output, $question); + + $question = new Question('Confirm password: '); + $question->setHidden(true); + $confirm = $helper->ask($input, $output,$question); if ($password !== $confirm) { $output->writeln("Passwords did not match!"); From 25546b6c832526e9a96eb4031205a9a65d1df60a Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 6 Sep 2016 21:00:10 +0200 Subject: [PATCH 5/8] Convert resetpassword to question helper --- core/Command/User/ResetPassword.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/core/Command/User/ResetPassword.php b/core/Command/User/ResetPassword.php index ed8cf53b99..cf8c894d7a 100644 --- a/core/Command/User/ResetPassword.php +++ b/core/Command/User/ResetPassword.php @@ -29,10 +29,13 @@ namespace OC\Core\Command\User; use OCP\IUserManager; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\ConfirmationQuestion; +use Symfony\Component\Console\Question\Question; class ResetPassword extends Command { @@ -79,28 +82,27 @@ class ResetPassword extends Command { return 1; } } elseif ($input->isInteractive()) { - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); if (\OCP\App::isEnabled('encryption')) { $output->writeln( 'Warning: Resetting the password when using encryption will result in data loss!' ); - if (!$dialog->askConfirmation($output, 'Do you want to continue?', true)) { + + $question = new ConfirmationQuestion('Do you want to continue?'); + if (!$helper->ask($input, $output, $question)) { return 1; } } - $password = $dialog->askHiddenResponse( - $output, - 'Enter a new password: ', - false - ); - $confirm = $dialog->askHiddenResponse( - $output, - 'Confirm the new password: ', - false - ); + $question = new Question('Enter a new password: '); + $question->setHidden(true); + $password = $helper->ask($input, $output, $question); + + $question = new Question('Conform the new password: '); + $question->setHidden(true); + $confirm = $helper->ask($input, $output, $question); if ($password !== $confirm) { $output->writeln("Passwords did not match!"); From b57a1063a3a2cb26ac909488fc27db65fde6e544 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 6 Sep 2016 21:08:08 +0200 Subject: [PATCH 6/8] Move install over to QuestionHelper --- core/Command/Maintenance/Install.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php index 4e84becf77..4b76a1f608 100644 --- a/core/Command/Maintenance/Install.php +++ b/core/Command/Maintenance/Install.php @@ -31,9 +31,11 @@ use InvalidArgumentException; use OC\Setup; use OCP\IConfig; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\Question; class Install extends Command { @@ -138,24 +140,22 @@ class Install extends Command { throw new InvalidArgumentException("Database name not provided."); } if (is_null($dbPass)) { - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); - $dbPass = $dialog->askHiddenResponse( - $output, - "What is the password to access the database with user <$dbUser>?", - false - ); + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); + $question = new Question('What is the password to access the database with user <'.$dbUser.'>?'); + $question->setHidden(true); + $question->setHiddenFallback(false); + $dbPass = $helper->ask($input, $output, $question); } } if (is_null($adminPassword)) { - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); - $adminPassword = $dialog->askHiddenResponse( - $output, - "What is the password you like to use for the admin account <$adminLogin>?", - false - ); + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); + $question = new Question('What is the password you like to use for the admin account <'.$adminLogin.'>?'); + $question->setHidden(true); + $question->setHiddenFallback(false); + $adminPassword = $helper->ask($input, $output, $question); } $options = [ From 4b8de8ba8e764f43c758fe1c789a5ea48560b48a Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 6 Sep 2016 21:18:51 +0200 Subject: [PATCH 7/8] Fix dbconvert --- core/Command/Db/ConvertType.php | 37 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index ccf5c0685c..f8367f7586 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -32,10 +32,14 @@ use \OCP\IConfig; use OC\DB\Connection; use OC\DB\ConnectionFactory; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\ProgressBar; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\ConfirmationQuestion; +use Symfony\Component\Console\Question\Question; class ConvertType extends Command { /** @@ -158,13 +162,12 @@ class ConvertType extends Command { // Read password by interacting if ($input->isInteractive()) { - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); - $password = $dialog->askHiddenResponse( - $output, - 'What is the database password?', - false - ); + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); + $question = new Question('What is the database password?'); + $question->setHidden(true); + $question->setHiddenFallback(false); + $password = $helper->ask($input, $output, $question); $input->setOption('password', $password); return; } @@ -195,13 +198,12 @@ class ConvertType extends Command { $output->writeln('Please note that tables belonging to available but currently not installed apps'); $output->writeln('can be included by specifying the --all-apps option.'); } - /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); - if (!$dialog->askConfirmation( - $output, - 'Continue with the conversion (y/n)? [n] ', - false - )) { + + /** @var QuestionHelper $helper */ + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false); + + if (!$helper->ask($input, $output, $question)) { return; } } @@ -256,9 +258,6 @@ class ConvertType extends Command { protected function copyTable(Connection $fromDB, Connection $toDB, $table, InputInterface $input, OutputInterface $output) { $chunkSize = $input->getOption('chunk-size'); - /** @var $progress \Symfony\Component\Console\Helper\ProgressHelper */ - $progress = $this->getHelperSet()->get('progress'); - $query = $fromDB->getQueryBuilder(); $query->automaticTablePrefix(false); $query->selectAlias($query->createFunction('COUNT(*)'), 'num_entries') @@ -272,11 +271,11 @@ class ConvertType extends Command { $output->writeln('chunked query, ' . $numChunks . ' chunks'); } - $progress->start($output, $count); + $progress = new ProgressBar($output, $count); + $progress->start(); $redraw = $count > $chunkSize ? 100 : ($count > 100 ? 5 : 1); $progress->setRedrawFrequency($redraw); - $query = $fromDB->getQueryBuilder(); $query->automaticTablePrefix(false); $query->select('*') From 59e5ebf330777f39ea9f1e9a12b3a50af1859ed6 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 6 Sep 2016 21:36:03 +0200 Subject: [PATCH 8/8] Cleanup files_external command imports --- apps/files_external/lib/Command/Backends.php | 6 ------ apps/files_external/lib/Command/Config.php | 4 ---- apps/files_external/lib/Command/Export.php | 4 ---- 3 files changed, 14 deletions(-) diff --git a/apps/files_external/lib/Command/Backends.php b/apps/files_external/lib/Command/Backends.php index b5c1b7f7a5..d05b9fa4a9 100644 --- a/apps/files_external/lib/Command/Backends.php +++ b/apps/files_external/lib/Command/Backends.php @@ -27,14 +27,8 @@ use OCA\Files_External\Lib\Auth\AuthMechanism; use OCA\Files_External\Lib\Backend\Backend; use OCA\Files_External\Lib\DefinitionParameter; use OCA\Files_External\Service\BackendService; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Helper\Table; -use Symfony\Component\Console\Helper\TableHelper; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\Input; use Symfony\Component\Console\Output\OutputInterface; class Backends extends Base { diff --git a/apps/files_external/lib/Command/Config.php b/apps/files_external/lib/Command/Config.php index cd1c9244d1..362f0a0f2b 100644 --- a/apps/files_external/lib/Command/Config.php +++ b/apps/files_external/lib/Command/Config.php @@ -27,12 +27,8 @@ use OC\Core\Command\Base; use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\NotFoundException; use OCA\Files_External\Service\GlobalStoragesService; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Helper\Table; -use Symfony\Component\Console\Helper\TableHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Config extends Base { diff --git a/apps/files_external/lib/Command/Export.php b/apps/files_external/lib/Command/Export.php index 9e586609d6..722ba38fee 100644 --- a/apps/files_external/lib/Command/Export.php +++ b/apps/files_external/lib/Command/Export.php @@ -22,14 +22,10 @@ namespace OCA\Files_External\Command; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Helper\Table; -use Symfony\Component\Console\Helper\TableHelper; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\Input; use Symfony\Component\Console\Output\OutputInterface; class Export extends ListCommand {