diff options
author | Joas Schilling <coding@schilljs.com> | 2020-06-26 15:12:11 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-06-26 15:12:11 +0200 |
commit | d7c0b9cced2dff16e4e05507ac58cf8664a6aafc (patch) | |
tree | bb136f0e797986da6e789bf2bf5e9f0370002d26 /apps/user_ldap/lib | |
parent | ab21d69903c4360cbce59741624b6e765e3bd35f (diff) | |
download | nextcloud-server-d7c0b9cced2dff16e4e05507ac58cf8664a6aafc.tar.gz nextcloud-server-d7c0b9cced2dff16e4e05507ac58cf8664a6aafc.zip |
Also always return in app commands
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/Command/CheckUser.php | 6 | ||||
-rw-r--r-- | apps/user_ldap/lib/Command/CreateEmptyConfig.php | 3 | ||||
-rw-r--r-- | apps/user_ldap/lib/Command/DeleteConfig.php | 4 | ||||
-rw-r--r-- | apps/user_ldap/lib/Command/Search.php | 3 | ||||
-rw-r--r-- | apps/user_ldap/lib/Command/SetConfig.php | 5 | ||||
-rw-r--r-- | apps/user_ldap/lib/Command/ShowConfig.php | 5 | ||||
-rw-r--r-- | apps/user_ldap/lib/Command/ShowRemnants.php | 3 | ||||
-rw-r--r-- | apps/user_ldap/lib/Command/TestConfig.php | 6 |
8 files changed, 23 insertions, 12 deletions
diff --git a/apps/user_ldap/lib/Command/CheckUser.php b/apps/user_ldap/lib/Command/CheckUser.php index 9b2c6d93de3..5314cac365a 100644 --- a/apps/user_ldap/lib/Command/CheckUser.php +++ b/apps/user_ldap/lib/Command/CheckUser.php @@ -87,7 +87,7 @@ class CheckUser extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { try { $uid = $input->getArgument('ocName'); $this->isAllowed($input->getOption('force')); @@ -98,15 +98,17 @@ class CheckUser extends Command { if ($input->getOption('update')) { $this->updateUser($uid, $output); } - return; + return 0; } $this->dui->markUser($uid); $output->writeln('The user does not exists on LDAP anymore.'); $output->writeln('Clean up the user\'s remnants by: ./occ user:delete "' . $uid . '"'); + return 0; } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage(). '</error>'); + return 1; } } diff --git a/apps/user_ldap/lib/Command/CreateEmptyConfig.php b/apps/user_ldap/lib/Command/CreateEmptyConfig.php index 3f42020c1e9..4d88bf80c5e 100644 --- a/apps/user_ldap/lib/Command/CreateEmptyConfig.php +++ b/apps/user_ldap/lib/Command/CreateEmptyConfig.php @@ -58,7 +58,7 @@ class CreateEmptyConfig extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $configPrefix = $this->helper->getNextServerConfigurationPrefix(); $configHolder = new Configuration($configPrefix); $configHolder->saveConfiguration(); @@ -68,5 +68,6 @@ class CreateEmptyConfig extends Command { $prose = 'Created new configuration with configID '; } $output->writeln($prose . "{$configPrefix}"); + return 0; } } diff --git a/apps/user_ldap/lib/Command/DeleteConfig.php b/apps/user_ldap/lib/Command/DeleteConfig.php index 43a5055e8ad..c76ba6f296b 100644 --- a/apps/user_ldap/lib/Command/DeleteConfig.php +++ b/apps/user_ldap/lib/Command/DeleteConfig.php @@ -57,15 +57,17 @@ class DeleteConfig extends Command { } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $configPrefix = $input->getArgument('configID'); $success = $this->helper->deleteServerConfiguration($configPrefix); if ($success) { $output->writeln("Deleted configuration with configID '{$configPrefix}'"); + return 0; } else { $output->writeln("Cannot delete configuration with configID '{$configPrefix}'"); + return 1; } } } diff --git a/apps/user_ldap/lib/Command/Search.php b/apps/user_ldap/lib/Command/Search.php index 1389f2eca52..f19c11a4666 100644 --- a/apps/user_ldap/lib/Command/Search.php +++ b/apps/user_ldap/lib/Command/Search.php @@ -105,7 +105,7 @@ class Search extends Command { } } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $helper = new Helper($this->ocConfig); $configPrefixes = $helper->getServerConfigurationPrefixes(true); $ldapWrapper = new LDAP(); @@ -141,5 +141,6 @@ class Search extends Command { $line = $name . ($printID ? ' ('.$id.')' : ''); $output->writeln($line); } + return 0; } } diff --git a/apps/user_ldap/lib/Command/SetConfig.php b/apps/user_ldap/lib/Command/SetConfig.php index 53a480c652d..2b2fdfe5c8b 100644 --- a/apps/user_ldap/lib/Command/SetConfig.php +++ b/apps/user_ldap/lib/Command/SetConfig.php @@ -59,13 +59,13 @@ class SetConfig extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $helper = new Helper(\OC::$server->getConfig()); $availableConfigs = $helper->getServerConfigurationPrefixes(); $configID = $input->getArgument('configID'); if (!in_array($configID, $availableConfigs)) { $output->writeln("Invalid configID"); - return; + return 1; } $this->setValue( @@ -73,6 +73,7 @@ class SetConfig extends Command { $input->getArgument('configKey'), $input->getArgument('configValue') ); + return 0; } /** diff --git a/apps/user_ldap/lib/Command/ShowConfig.php b/apps/user_ldap/lib/Command/ShowConfig.php index cbd94287f9b..80af5718dcb 100644 --- a/apps/user_ldap/lib/Command/ShowConfig.php +++ b/apps/user_ldap/lib/Command/ShowConfig.php @@ -66,20 +66,21 @@ class ShowConfig extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $availableConfigs = $this->helper->getServerConfigurationPrefixes(); $configID = $input->getArgument('configID'); if (!is_null($configID)) { $configIDs[] = $configID; if (!in_array($configIDs[0], $availableConfigs)) { $output->writeln("Invalid configID"); - return; + return 1; } } else { $configIDs = $availableConfigs; } $this->renderConfigs($configIDs, $output, $input->getOption('show-password')); + return 0; } /** diff --git a/apps/user_ldap/lib/Command/ShowRemnants.php b/apps/user_ldap/lib/Command/ShowRemnants.php index 034168cbd3f..4722bf76ce1 100644 --- a/apps/user_ldap/lib/Command/ShowRemnants.php +++ b/apps/user_ldap/lib/Command/ShowRemnants.php @@ -75,7 +75,7 @@ class ShowRemnants extends Command { * * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { /** @var \Symfony\Component\Console\Helper\Table $table */ $table = new Table($output); $table->setHeaders([ @@ -103,5 +103,6 @@ class ShowRemnants extends Command { $table->setRows($rows); $table->render($output); } + return 0; } } diff --git a/apps/user_ldap/lib/Command/TestConfig.php b/apps/user_ldap/lib/Command/TestConfig.php index 0973e6245b3..b588a8380d0 100644 --- a/apps/user_ldap/lib/Command/TestConfig.php +++ b/apps/user_ldap/lib/Command/TestConfig.php @@ -47,13 +47,13 @@ class TestConfig extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $helper = new Helper(\OC::$server->getConfig()); $availableConfigs = $helper->getServerConfigurationPrefixes(); $configID = $input->getArgument('configID'); if (!in_array($configID, $availableConfigs)) { $output->writeln("Invalid configID"); - return; + return 1; } $result = $this->testConfig($configID); @@ -61,11 +61,13 @@ class TestConfig extends Command { $output->writeln('The configuration is valid and the connection could be established!'); } elseif ($result === 1) { $output->writeln('The configuration is invalid. Please have a look at the logs for further details.'); + return 1; } elseif ($result === 2) { $output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.'); } else { $output->writeln('Your LDAP server was kidnapped by aliens.'); } + return 0; } /** |