diff --git a/apps/dav/lib/Command/CreateAddressBook.php b/apps/dav/lib/Command/CreateAddressBook.php index 317b356772e19556edc9bc4b3c545f1e45f2f459..6bd175f91d3949a6e3d95856923371a1e7ab4f4b 100644 --- a/apps/dav/lib/Command/CreateAddressBook.php +++ b/apps/dav/lib/Command/CreateAddressBook.php @@ -64,7 +64,7 @@ class CreateAddressBook extends Command { 'Name of the addressbook'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $user = $input->getArgument('user'); if (!$this->userManager->userExists($user)) { throw new \InvalidArgumentException("User <$user> in unknown."); @@ -72,5 +72,6 @@ class CreateAddressBook extends Command { $name = $input->getArgument('name'); $this->cardDavBackend->createAddressBook("principals/users/$user", $name, []); + return 0; } } diff --git a/apps/dav/lib/Command/CreateCalendar.php b/apps/dav/lib/Command/CreateCalendar.php index 81a8773957ae1ac0bd78cef39d35ae7466a9ce71..d03b573e4abe06ad86ff81b48bf30ce06a953967 100644 --- a/apps/dav/lib/Command/CreateCalendar.php +++ b/apps/dav/lib/Command/CreateCalendar.php @@ -73,7 +73,7 @@ class CreateCalendar extends Command { 'Name of the calendar'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $user = $input->getArgument('user'); if (!$this->userManager->userExists($user)) { throw new \InvalidArgumentException("User <$user> in unknown."); @@ -94,5 +94,6 @@ class CreateCalendar extends Command { $name = $input->getArgument('name'); $caldav = new CalDavBackend($this->dbConnection, $principalBackend, $this->userManager, $this->groupManager, $random, $logger, $dispatcher); $caldav->createCalendar("principals/users/$user", $name, []); + return 0; } } diff --git a/apps/dav/lib/Command/ListCalendars.php b/apps/dav/lib/Command/ListCalendars.php index 85aa25be946e4293cb384c6bf32537f6b35491fc..422202d922796cb1a9a723b60a57929115c8e50e 100644 --- a/apps/dav/lib/Command/ListCalendars.php +++ b/apps/dav/lib/Command/ListCalendars.php @@ -62,7 +62,7 @@ class ListCalendars extends Command { 'User for whom all calendars will be listed'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $user = $input->getArgument('uid'); if (!$this->userManager->userExists($user)) { throw new \InvalidArgumentException("User <$user> is unknown."); @@ -101,5 +101,6 @@ class ListCalendars extends Command { } else { $output->writeln("<info>User <$user> has no calendars</info>"); } + return 0; } } diff --git a/apps/dav/lib/Command/MoveCalendar.php b/apps/dav/lib/Command/MoveCalendar.php index d40f46007450ffd445481b351df87fe24494121b..b89c64d7ba7d91561c12079d8bf40d7603f8d7e6 100644 --- a/apps/dav/lib/Command/MoveCalendar.php +++ b/apps/dav/lib/Command/MoveCalendar.php @@ -106,7 +106,7 @@ class MoveCalendar extends Command { ->addOption('force', 'f', InputOption::VALUE_NONE, "Force the migration by removing existing shares"); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $userOrigin = $input->getArgument('sourceuid'); $userDestination = $input->getArgument('destinationuid'); @@ -137,6 +137,7 @@ class MoveCalendar extends Command { $this->calDav->moveCalendar($name, self::URI_USERS . $userOrigin, self::URI_USERS . $userDestination); $this->io->success("Calendar <$name> was moved from user <$userOrigin> to <$userDestination>"); + return 0; } /** diff --git a/apps/dav/lib/Command/RemoveInvalidShares.php b/apps/dav/lib/Command/RemoveInvalidShares.php index 71644456f67b8badde3a8f624df7537e7b4332a0..0129191c18b2857491c72dbfee95ef675a053964 100644 --- a/apps/dav/lib/Command/RemoveInvalidShares.php +++ b/apps/dav/lib/Command/RemoveInvalidShares.php @@ -57,7 +57,7 @@ class RemoveInvalidShares extends Command { ->setDescription('Remove invalid dav shares'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $query = $this->connection->getQueryBuilder(); $result = $query->selectDistinct('principaluri') ->from('dav_shares') @@ -72,6 +72,7 @@ class RemoveInvalidShares extends Command { } $result->closeCursor(); + return 0; } /** diff --git a/apps/dav/lib/Command/SendEventReminders.php b/apps/dav/lib/Command/SendEventReminders.php index 8313f265bfc92b6368ff1742d17b497e3097f283..3eb7f1a56eeac221f39e3a22e2844ec62fd54636 100644 --- a/apps/dav/lib/Command/SendEventReminders.php +++ b/apps/dav/lib/Command/SendEventReminders.php @@ -67,19 +67,20 @@ class SendEventReminders extends Command { * @param InputInterface $input * @param OutputInterface $output */ - protected function execute(InputInterface $input, OutputInterface $output):void { + protected function execute(InputInterface $input, OutputInterface $output): int { if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') { $output->writeln('<error>Sending event reminders disabled!</error>'); $output->writeln('<info>Please run "php occ config:app:set dav sendEventReminders --value yes"'); - return; + return 1; } if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'occ') { $output->writeln('<error>Sending event reminders mode set to background-job!</error>'); $output->writeln('<info>Please run "php occ config:app:set dav sendEventRemindersMode --value occ"'); - return; + return 1; } $this->reminderService->processReminders(); + return 0; } } diff --git a/apps/dav/lib/Command/SyncBirthdayCalendar.php b/apps/dav/lib/Command/SyncBirthdayCalendar.php index 0addbc08a73d36993be1c017b2812f51035db624..6536f8439a4c18f966bb376e174214adfcd1ca01 100644 --- a/apps/dav/lib/Command/SyncBirthdayCalendar.php +++ b/apps/dav/lib/Command/SyncBirthdayCalendar.php @@ -73,7 +73,7 @@ class SyncBirthdayCalendar extends Command { * @param InputInterface $input * @param OutputInterface $output */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $this->verifyEnabled(); $user = $input->getArgument('user'); @@ -91,7 +91,7 @@ class SyncBirthdayCalendar extends Command { $output->writeln("Start birthday calendar sync for $user"); $this->birthdayService->syncUser($user); - return; + return 0; } $output->writeln("Start birthday calendar sync for all users ..."); $p = new ProgressBar($output); @@ -111,6 +111,7 @@ class SyncBirthdayCalendar extends Command { $p->finish(); $output->writeln(''); + return 0; } protected function verifyEnabled() { diff --git a/apps/dav/lib/Command/SyncSystemAddressBook.php b/apps/dav/lib/Command/SyncSystemAddressBook.php index 26cb0aa64394bd42f358dd2b68136cbc814e5c35..9fabc6de883e6c906650ce3eb08861a54c1fea0c 100644 --- a/apps/dav/lib/Command/SyncSystemAddressBook.php +++ b/apps/dav/lib/Command/SyncSystemAddressBook.php @@ -53,7 +53,7 @@ class SyncSystemAddressBook extends Command { * @param InputInterface $input * @param OutputInterface $output */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln('Syncing users ...'); $progress = new ProgressBar($output); $progress->start(); @@ -63,5 +63,6 @@ class SyncSystemAddressBook extends Command { $progress->finish(); $output->writeln(''); + return 0; } } diff --git a/apps/encryption/lib/Command/DisableMasterKey.php b/apps/encryption/lib/Command/DisableMasterKey.php index 319286bc926be5dc1500e50b4d111e848f04e73c..fa0572c5fb8ddbabdcf68c0f44e638636321e0b1 100644 --- a/apps/encryption/lib/Command/DisableMasterKey.php +++ b/apps/encryption/lib/Command/DisableMasterKey.php @@ -63,7 +63,7 @@ class DisableMasterKey extends Command { ->setDescription('Disable the master key and use per-user keys instead. Only available for fresh installations with no existing encrypted data! There is no way to enable it again.'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $isMasterKeyEnabled = $this->util->isMasterKeyEnabled(); if (!$isMasterKeyEnabled) { @@ -80,7 +80,9 @@ class DisableMasterKey extends Command { $output->writeln('Master key successfully disabled.'); } else { $output->writeln('aborted.'); + return 1; } } + return 0; } } diff --git a/apps/encryption/lib/Command/EnableMasterKey.php b/apps/encryption/lib/Command/EnableMasterKey.php index 4b1a5219c11ee52e94853ec6cc91cfcf4334ee6a..b1e7319384a98a5a87f1dcc4125b3354449c07f4 100644 --- a/apps/encryption/lib/Command/EnableMasterKey.php +++ b/apps/encryption/lib/Command/EnableMasterKey.php @@ -62,7 +62,7 @@ class EnableMasterKey extends Command { ->setDescription('Enable the master key. Only available for fresh installations with no existing encrypted data! There is also no way to disable it again.'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $isAlreadyEnabled = $this->util->isMasterKeyEnabled(); if ($isAlreadyEnabled) { @@ -76,7 +76,9 @@ class EnableMasterKey extends Command { $output->writeln('Master key successfully enabled.'); } else { $output->writeln('aborted.'); + return 1; } } + return 0; } } diff --git a/apps/encryption/lib/Command/RecoverUser.php b/apps/encryption/lib/Command/RecoverUser.php index fd702bc0313b77374c4be9df26971da46824c0ab..642182dbf5968519b1d2cf379859c0cdc39c0431 100644 --- a/apps/encryption/lib/Command/RecoverUser.php +++ b/apps/encryption/lib/Command/RecoverUser.php @@ -73,25 +73,25 @@ class RecoverUser extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $isMasterKeyEnabled = $this->util->isMasterKeyEnabled(); if ($isMasterKeyEnabled) { $output->writeln('You use the master key, no individual user recovery needed.'); - return; + return 0; } $uid = $input->getArgument('user'); $userExists = $this->userManager->userExists($uid); if ($userExists === false) { $output->writeln('User "' . $uid . '" unknown.'); - return; + return 1; } $recoveryKeyEnabled = $this->util->isRecoveryEnabledForUser($uid); if ($recoveryKeyEnabled === false) { $output->writeln('Recovery key is not enabled for: ' . $uid); - return; + return 1; } $question = new Question('Please enter the recovery key password: '); @@ -107,5 +107,6 @@ class RecoverUser extends Command { $output->write('Start to recover users files... This can take some time...'); $this->userManager->get($uid)->setPassword($newLoginPassword, $recoveryPassword); $output->writeln('Done.'); + return 0; } } diff --git a/apps/federation/lib/Command/SyncFederationAddressBooks.php b/apps/federation/lib/Command/SyncFederationAddressBooks.php index 48f8895c1d795fd3b61dabe94a4d43f937583f8e..05c24bdcb81ad8ce98dad5cfa6187d68e7cf6e28 100644 --- a/apps/federation/lib/Command/SyncFederationAddressBooks.php +++ b/apps/federation/lib/Command/SyncFederationAddressBooks.php @@ -56,7 +56,7 @@ class SyncFederationAddressBooks extends Command { * @param OutputInterface $output * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $progress = new ProgressBar($output); $progress->start(); $this->syncService->syncThemAll(function ($url, $ex) use ($progress, $output) { diff --git a/apps/files/lib/Command/DeleteOrphanedFiles.php b/apps/files/lib/Command/DeleteOrphanedFiles.php index 167d679e3c84d4aed4491ec564a777c475e0d979..c8ce9729ef7ed90bb8359dc22ff3265d251409c6 100644 --- a/apps/files/lib/Command/DeleteOrphanedFiles.php +++ b/apps/files/lib/Command/DeleteOrphanedFiles.php @@ -51,7 +51,7 @@ class DeleteOrphanedFiles extends Command { ->setDescription('cleanup filecache'); } - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { $deletedEntries = 0; $query = $this->connection->getQueryBuilder(); @@ -78,5 +78,6 @@ class DeleteOrphanedFiles extends Command { } $output->writeln("$deletedEntries orphaned file cache entries deleted"); + return 0; } } diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php index c75073e428f16d91a42d0a28951085fb48ee13c6..aea6003417d62ec5354f393e2b2f2e67291df689 100644 --- a/apps/files/lib/Command/Scan.php +++ b/apps/files/lib/Command/Scan.php @@ -169,7 +169,7 @@ class Scan extends Base { return substr_count($mountPoint->getMountPoint(), '/') <= 3; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $inputPath = $input->getOption('path'); if ($inputPath) { $inputPath = '/' . trim($inputPath, '/'); @@ -190,7 +190,7 @@ class Scan extends Base { $users_total = count($users); if ($users_total === 0) { $output->writeln('<error>Please specify the user id to scan, --all to scan for all users or --path=...</error>'); - return; + return 1; } $this->initTools(); @@ -219,6 +219,7 @@ class Scan extends Base { } $this->presentStats($output); + return 0; } /** diff --git a/apps/files/lib/Command/ScanAppData.php b/apps/files/lib/Command/ScanAppData.php index 47cd81e6b4e4e1b6950022b078899c86261ca2cf..47a153d3895e04e758b6d157773236c41f7bb948 100644 --- a/apps/files/lib/Command/ScanAppData.php +++ b/apps/files/lib/Command/ScanAppData.php @@ -149,7 +149,7 @@ class ScanAppData extends Base { } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { # restrict the verbosity level to VERBOSITY_VERBOSE if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) { $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); diff --git a/apps/files/lib/Command/TransferOwnership.php b/apps/files/lib/Command/TransferOwnership.php index b1d90452c237f01c983c48df7233dc60d595c6f0..92d8fba8f27707d8d3fcd4a12fd1cd7368c96259 100644 --- a/apps/files/lib/Command/TransferOwnership.php +++ b/apps/files/lib/Command/TransferOwnership.php @@ -86,7 +86,7 @@ class TransferOwnership extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $sourceUserObject = $this->userManager->get($input->getArgument('source-user')); $destinationUserObject = $this->userManager->get($input->getArgument('destination-user')); diff --git a/apps/files_external/lib/Command/Applicable.php b/apps/files_external/lib/Command/Applicable.php index 81d7f972f463aab4a568be4672918ae9a19627ae..bec312bdcb2c182118c0d23a0fc402e7411370dc 100644 --- a/apps/files_external/lib/Command/Applicable.php +++ b/apps/files_external/lib/Command/Applicable.php @@ -100,7 +100,7 @@ class Applicable extends Base { parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $mountId = $input->getArgument('mount_id'); try { $mount = $this->globalService->getStorage($mountId); @@ -154,5 +154,6 @@ class Applicable extends Base { 'users' => $applicableUsers, 'groups' => $applicableGroups ]); + return 0; } } diff --git a/apps/files_external/lib/Command/Backends.php b/apps/files_external/lib/Command/Backends.php index e06f5ea5fd1c130efd39d16f94282caf2f5bfa77..3bb4b9121aef52b4a3d36d8ea046321b4c8bc63a 100644 --- a/apps/files_external/lib/Command/Backends.php +++ b/apps/files_external/lib/Command/Backends.php @@ -59,7 +59,7 @@ class Backends extends Base { parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $authBackends = $this->backendService->getAuthMechanisms(); $storageBackends = $this->backendService->getBackends(); @@ -87,6 +87,7 @@ class Backends extends Base { } $this->writeArrayInOutputFormat($input, $output, $data); + return 0; } private function serializeAuthBackend(\JsonSerializable $backend) { diff --git a/apps/files_external/lib/Command/Config.php b/apps/files_external/lib/Command/Config.php index dde74de3a9c1aaf8e16202147e6bfb7502986213..467f421e7307bd514c764939001de2b5a8f02b3d 100644 --- a/apps/files_external/lib/Command/Config.php +++ b/apps/files_external/lib/Command/Config.php @@ -64,7 +64,7 @@ class Config extends Base { parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $mountId = $input->getArgument('mount_id'); $key = $input->getArgument('key'); try { @@ -80,6 +80,7 @@ class Config extends Base { } else { $this->getOption($mount, $key, $output); } + return 0; } /** diff --git a/apps/files_external/lib/Command/Create.php b/apps/files_external/lib/Command/Create.php index 769ffbec51ccab202ca8bc566eb399a2d447d7de..654c735702358d9f69381f19eda5f85bda193f6e 100644 --- a/apps/files_external/lib/Command/Create.php +++ b/apps/files_external/lib/Command/Create.php @@ -119,7 +119,7 @@ class Create extends Base { parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $user = $input->getOption('user'); $mountPoint = $input->getArgument('mount_point'); $storageIdentifier = $input->getArgument('storage_backend'); diff --git a/apps/files_external/lib/Command/Delete.php b/apps/files_external/lib/Command/Delete.php index c44e35c7fa91cdf80a54c606c94aa74e87ecddec..71496e58d14a13cfbb25f7b550eb94801d3b3876 100644 --- a/apps/files_external/lib/Command/Delete.php +++ b/apps/files_external/lib/Command/Delete.php @@ -84,7 +84,7 @@ class Delete extends Base { parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $mountId = $input->getArgument('mount_id'); try { $mount = $this->globalService->getStorage($mountId); @@ -105,10 +105,11 @@ class Delete extends Base { $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); if (!$questionHelper->ask($input, $output, $question)) { - return null; + return 1; } } $this->globalService->removeStorage($mountId); + return 0; } } diff --git a/apps/files_external/lib/Command/Export.php b/apps/files_external/lib/Command/Export.php index 242f408a54d888e22b1684b2a3e6f19badc8fdf9..d670865f29d69c008593f20fcc25ef188b6d1173 100644 --- a/apps/files_external/lib/Command/Export.php +++ b/apps/files_external/lib/Command/Export.php @@ -45,7 +45,7 @@ class Export extends ListCommand { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); $listInput = new ArrayInput([], $listCommand->getDefinition()); $listInput->setArgument('user_id', $input->getArgument('user_id')); @@ -54,5 +54,6 @@ class Export extends ListCommand { $listInput->setOption('show-password', true); $listInput->setOption('full', true); $listCommand->execute($listInput, $output); + return 0; } } diff --git a/apps/files_external/lib/Command/Import.php b/apps/files_external/lib/Command/Import.php index 0e13a5214410370dd5ba4798fe74a61e7ba4d585..bbaeea91c3e340979a125da8a8bba2750bd5a748 100644 --- a/apps/files_external/lib/Command/Import.php +++ b/apps/files_external/lib/Command/Import.php @@ -107,7 +107,7 @@ class Import extends Base { parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $user = $input->getOption('user'); $path = $input->getArgument('path'); if ($path === '-') { diff --git a/apps/files_external/lib/Command/ListCommand.php b/apps/files_external/lib/Command/ListCommand.php index 1e7598ec5414e087db12bbfd91168eb5aa184c3e..279e581f95e9c1d612a3d6e9d6cf16c5df8e7434 100644 --- a/apps/files_external/lib/Command/ListCommand.php +++ b/apps/files_external/lib/Command/ListCommand.php @@ -96,7 +96,7 @@ class ListCommand extends Base { parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { if ($input->getOption('all')) { /** @var $mounts StorageConfig[] */ $mounts = $this->globalService->getStorageForAllUsers(); @@ -110,6 +110,7 @@ class ListCommand extends Base { } $this->listMounts($userId, $mounts, $input, $output); + return 0; } /** diff --git a/apps/files_external/lib/Command/Notify.php b/apps/files_external/lib/Command/Notify.php index 4a48a22636ccd30b2877a117a200362a837dc9ea..7f305008402db048283fe08466882d9bbd3d6552 100644 --- a/apps/files_external/lib/Command/Notify.php +++ b/apps/files_external/lib/Command/Notify.php @@ -88,7 +88,7 @@ class Notify extends Base { parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $mount = $this->globalService->getStorage($input->getArgument('mount_id')); if (is_null($mount)) { $output->writeln('<error>Mount not found</error>'); @@ -147,6 +147,7 @@ class Notify extends Base { } $this->markParentAsOutdated($mount->getId(), $change->getPath(), $output); }); + return 0; } private function createStorage(StorageConfig $mount) { diff --git a/apps/files_external/lib/Command/Verify.php b/apps/files_external/lib/Command/Verify.php index 8e1fa71cf8b96d92751ca5d9e2d8d951476e51f8..e5bfb3052eead4b85fac8cce1b2be3da4885fab7 100644 --- a/apps/files_external/lib/Command/Verify.php +++ b/apps/files_external/lib/Command/Verify.php @@ -65,7 +65,7 @@ class Verify extends Base { parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $mountId = $input->getArgument('mount_id'); $configInput = $input->getOption('config'); @@ -83,6 +83,7 @@ class Verify extends Base { 'code' => $mount->getStatus(), 'message' => $mount->getStatusMessage() ]); + return 0; } private function manipulateStorageConfig(StorageConfig $storage) { diff --git a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php index 2eb79f87762174572221fa43ad4ca7db49b057dd..259e55ff620fc9e4e1096ed08eed2c681fe97fd9 100644 --- a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php +++ b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php @@ -59,7 +59,7 @@ class CleanupRemoteStorages extends Command { ); } - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { $remoteStorages = $this->getRemoteStorages(); $output->writeln(count($remoteStorages) . ' remote storage(s) need(s) to be checked'); @@ -93,6 +93,7 @@ class CleanupRemoteStorages extends Command { } } } + return 0; } public function countFiles($numericId, OutputInterface $output) { diff --git a/apps/files_sharing/lib/Command/ExiprationNotification.php b/apps/files_sharing/lib/Command/ExiprationNotification.php index 6fd04bcdcccadff3b1ad7b53590b6665bbab038f..1df4994318853446c31ee631f9ea7fa86b36df76 100644 --- a/apps/files_sharing/lib/Command/ExiprationNotification.php +++ b/apps/files_sharing/lib/Command/ExiprationNotification.php @@ -63,7 +63,7 @@ class ExiprationNotification extends Command { ->setDescription('Notify share initiators when a share will expire the next day.'); } - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { //Current time $minTime = $this->time->getDateTime(); $minTime->add(new \DateInterval('P1D')); @@ -94,5 +94,6 @@ class ExiprationNotification extends Command { $notification->setUser($share->getSharedBy()); $this->notificationManager->notify($notification); } + return 0; } } diff --git a/apps/files_trashbin/lib/Command/CleanUp.php b/apps/files_trashbin/lib/Command/CleanUp.php index 7192ed26094d808f872531841faeee0f13ec496b..1b61c1ae74d7ab76df9a28d17568e3c9c8d561e7 100644 --- a/apps/files_trashbin/lib/Command/CleanUp.php +++ b/apps/files_trashbin/lib/Command/CleanUp.php @@ -77,7 +77,7 @@ class CleanUp extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $users = $input->getArgument('user_id'); if ((!empty($users)) and ($input->getOption('all-users'))) { throw new InvalidOptionException('Either specify a user_id or --all-users'); @@ -88,6 +88,7 @@ class CleanUp extends Command { $this->removeDeletedFiles($user); } else { $output->writeln("<error>Unknown user $user</error>"); + return 1; } } } elseif ($input->getOption('all-users')) { @@ -112,6 +113,7 @@ class CleanUp extends Command { } else { throw new InvalidOptionException('Either specify a user_id or --all-users'); } + return 0; } /** diff --git a/apps/files_trashbin/lib/Command/ExpireTrash.php b/apps/files_trashbin/lib/Command/ExpireTrash.php index 7cc6c83b36997ee8bc00128afe49e88d3491342b..26088aad37d9ff71a9ca5e499de3ebb8b909f4c3 100644 --- a/apps/files_trashbin/lib/Command/ExpireTrash.php +++ b/apps/files_trashbin/lib/Command/ExpireTrash.php @@ -42,7 +42,7 @@ class ExpireTrash extends Command { * @var Expiration */ private $expiration; - + /** * @var IUserManager */ @@ -71,11 +71,11 @@ class ExpireTrash extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $maxAge = $this->expiration->getMaxAgeAsTimestamp(); if (!$maxAge) { $output->writeln("No expiry configured."); - return; + return 1; } $users = $input->getArgument('user_id'); @@ -87,6 +87,7 @@ class ExpireTrash extends Command { $this->expireTrashForUser($userObject); } else { $output->writeln("<error>Unknown user $user</error>"); + return 1; } } } else { @@ -99,6 +100,7 @@ class ExpireTrash extends Command { $p->finish(); $output->writeln(''); } + return 0; } public function expireTrashForUser(IUser $user) { diff --git a/apps/files_versions/lib/Command/CleanUp.php b/apps/files_versions/lib/Command/CleanUp.php index d49835f2db489a3032166770e3118ff40d962b68..d67df024a1bca8f3d303c10a03c2f46058156448 100644 --- a/apps/files_versions/lib/Command/CleanUp.php +++ b/apps/files_versions/lib/Command/CleanUp.php @@ -61,7 +61,7 @@ class CleanUp extends Command { } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $users = $input->getArgument('user_id'); if (!empty($users)) { foreach ($users as $user) { @@ -70,6 +70,7 @@ class CleanUp extends Command { $this->deleteVersions($user); } else { $output->writeln("<error>Unknown user $user</error>"); + return 1; } } } else { @@ -95,6 +96,7 @@ class CleanUp extends Command { } while (count($users) >= $limit); } } + return 0; } diff --git a/apps/files_versions/lib/Command/ExpireVersions.php b/apps/files_versions/lib/Command/ExpireVersions.php index a48908dcd6b77de4f014bfdd0287af3a9267d4f3..81da8fda03d21be4fb04a41deaf72eb5d7d8f2ce 100644 --- a/apps/files_versions/lib/Command/ExpireVersions.php +++ b/apps/files_versions/lib/Command/ExpireVersions.php @@ -41,7 +41,7 @@ class ExpireVersions extends Command { * @var Expiration */ private $expiration; - + /** * @var IUserManager */ @@ -70,11 +70,11 @@ class ExpireVersions extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $maxAge = $this->expiration->getMaxAgeAsTimestamp(); if (!$maxAge) { $output->writeln("No expiry configured."); - return; + return 1; } $users = $input->getArgument('user_id'); @@ -86,6 +86,7 @@ class ExpireVersions extends Command { $this->expireVersionsForUser($userObject); } else { $output->writeln("<error>Unknown user $user</error>"); + return 1; } } } else { @@ -98,6 +99,7 @@ class ExpireVersions extends Command { $p->finish(); $output->writeln(''); } + return 0; } public function expireVersionsForUser(IUser $user) { diff --git a/apps/updatenotification/lib/Command/Check.php b/apps/updatenotification/lib/Command/Check.php index 88d7e1d4fac8b1ca8487fbbae0c4ed596d266373..351350ba3eef6e1cad0f1e33a5c915e31db0d953 100644 --- a/apps/updatenotification/lib/Command/Check.php +++ b/apps/updatenotification/lib/Command/Check.php @@ -63,7 +63,7 @@ class Check extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $updatesAvailableCount = 0; // Server diff --git a/apps/user_ldap/lib/Command/CheckUser.php b/apps/user_ldap/lib/Command/CheckUser.php index 9b2c6d93de3e62d0d2f2ad04e3376ee0c6fbd7d0..5314cac365afd281eba74d09cc3237a7faa344c2 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 3f42020c1e9e8cde38ce0c0c8de91028b9cea3d9..4d88bf80c5ee3ea5e8b30f6297134a99ea98c57d 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 43a5055e8ade2ddc480484c671ba15ab4b8a1650..c76ba6f296b3a712dca5c32e9d7e644f9b64df37 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 1389f2eca52930b770482338cf4f46e3e07b3d6a..f19c11a46665b853ed8ba84cdd3f10697cc34fd0 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 53a480c652d23c3b65aaaea2ff559c56070d2f33..2b2fdfe5c8b9b0ce496000799a691fbb1dd5c23c 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 cbd94287f9bea79aaaf5a40950a803b7b516b19d..80af5718dcbd278a2d2779eeabcac28560abbf8f 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 034168cbd3ff9fdf3ea6d03d6f7d67dfd394a158..4722bf76ce167ac51b531dfba72cd2bfa0e857ad 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 0973e6245b38547b64f8ff7d4d854f8345e31fff..b588a8380d01d117f2167d82a1f1ba72a7d272c5 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; } /** diff --git a/apps/workflowengine/lib/Command/Index.php b/apps/workflowengine/lib/Command/Index.php index 5f901c262df368ed4ee04579f27a16275cf89050..fdc83b1d3c223ca6180df3c12e4fa5c89fffbcf6 100644 --- a/apps/workflowengine/lib/Command/Index.php +++ b/apps/workflowengine/lib/Command/Index.php @@ -69,7 +69,7 @@ class Index extends Command { return $scopes[$scope] ?? -1; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $ops = $this->manager->getAllOperations( new ScopeContext( $this->mappedScope($input->getArgument('scope')), @@ -77,5 +77,6 @@ class Index extends Command { ) ); $output->writeln(\json_encode($ops)); + return 0; } } diff --git a/core/Command/App/CheckCode.php b/core/Command/App/CheckCode.php index 25e22d04171e9036320b7d8967d1816ba3891030..f7b3723a8d3e385ac22b47f5cead0977857a71d3 100644 --- a/core/Command/App/CheckCode.php +++ b/core/Command/App/CheckCode.php @@ -80,7 +80,7 @@ class CheckCode extends Command implements CompletionAwareInterface { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $appId = $input->getArgument('app-id'); $checkList = new EmptyCheck(); diff --git a/core/Command/App/Disable.php b/core/Command/App/Disable.php index 94dd1f6354119e4b03515144d6177e7748092faa..ba9b8d769e591c6306544b2d32564e5003623798 100644 --- a/core/Command/App/Disable.php +++ b/core/Command/App/Disable.php @@ -60,7 +60,7 @@ class Disable extends Command implements CompletionAwareInterface { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $appIds = $input->getArgument('app-id'); foreach ($appIds as $appId) { diff --git a/core/Command/App/Enable.php b/core/Command/App/Enable.php index e782a7fc0beb28ca7d947b1a556fe4e4bea14b8f..2e26184b199350ddf7679b2aa6cefcdfe576793d 100644 --- a/core/Command/App/Enable.php +++ b/core/Command/App/Enable.php @@ -83,7 +83,7 @@ class Enable extends Command implements CompletionAwareInterface { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $appIds = $input->getArgument('app-id'); $groups = $this->resolveGroupIds($input->getOption('groups')); $forceEnable = (bool) $input->getOption('force'); diff --git a/core/Command/App/GetPath.php b/core/Command/App/GetPath.php index 07a8a38bbc5924207ee634fc2e948eec0c20c826..1659a110ab0b6784c3567151eb10b928acd56db9 100644 --- a/core/Command/App/GetPath.php +++ b/core/Command/App/GetPath.php @@ -51,7 +51,7 @@ class GetPath extends Base { * @param OutputInterface $output An OutputInterface instance * @return null|int null or 0 if everything went fine, or an error code */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $appName = $input->getArgument('app'); $path = \OC_App::getAppPath($appName); if ($path !== false) { diff --git a/core/Command/App/Install.php b/core/Command/App/Install.php index 65817894955170be946fe73340a0292bf85e205a..41e3e20c9dc201c8f7757b576c9826d459418d25 100644 --- a/core/Command/App/Install.php +++ b/core/Command/App/Install.php @@ -51,7 +51,7 @@ class Install extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $appId = $input->getArgument('app-id'); if (\OC_App::getAppPath($appId)) { diff --git a/core/Command/App/ListApps.php b/core/Command/App/ListApps.php index 0765ab39a24eeb9d6f3f1608ad737782ea3f94b1..74f2ad76ccd4ee281baa98c74fff9362c66b17e0 100644 --- a/core/Command/App/ListApps.php +++ b/core/Command/App/ListApps.php @@ -61,7 +61,7 @@ class ListApps extends Base { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false') { $shippedFilter = $input->getOption('shipped') === 'true'; } else { @@ -97,6 +97,7 @@ class ListApps extends Base { } $this->writeAppList($input, $output, $apps); + return 0; } /** diff --git a/core/Command/App/Remove.php b/core/Command/App/Remove.php index 6e3fa704ef108875476b37d666975b244605b171..96d1efe8c6207a5f538861fa179bcf8d10426d90 100644 --- a/core/Command/App/Remove.php +++ b/core/Command/App/Remove.php @@ -75,7 +75,7 @@ class Remove extends Command implements CompletionAwareInterface { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $appId = $input->getArgument('app-id'); // Check if the app is installed diff --git a/core/Command/App/Update.php b/core/Command/App/Update.php index 417d1915d05397b0a9ac6b0eaeaa7fb4623b4d69..34178c1ee7cecdaeb2e039d13215236d3a149ea7 100644 --- a/core/Command/App/Update.php +++ b/core/Command/App/Update.php @@ -80,7 +80,7 @@ class Update extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $singleAppId = $input->getArgument('app-id'); if ($singleAppId) { diff --git a/core/Command/Background/Base.php b/core/Command/Background/Base.php index 414666600009ca698625576be6bc4937c981b4aa..b80fd751177c314c368d8eba76d87a694134ac97 100644 --- a/core/Command/Background/Base.php +++ b/core/Command/Background/Base.php @@ -48,8 +48,8 @@ abstract class Base extends Command { * @param \OCP\IConfig $config */ public function __construct(IConfig $config) { - $this->config = $config; parent::__construct(); + $this->config = $config; } protected function configure() { @@ -67,9 +67,10 @@ abstract class Base extends Command { * @param InputInterface $input * @param OutputInterface $output */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $mode = $this->getMode(); $this->config->setAppValue('core', 'backgroundjobs_mode', $mode); $output->writeln("Set mode for background jobs to '$mode'"); + return 0; } } diff --git a/core/Command/Broadcast/Test.php b/core/Command/Broadcast/Test.php index 93734369acecbc25924b5591b26c31c50d350dfa..7be49156a77635463bd44184195a33995290e62e 100644 --- a/core/Command/Broadcast/Test.php +++ b/core/Command/Broadcast/Test.php @@ -60,7 +60,7 @@ class Test extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $name = $input->getArgument('name'); $uid = $input->getArgument('uid'); diff --git a/core/Command/Check.php b/core/Command/Check.php index a4e17e0bf9c94afe909efffbc325f9075fff06f7..f1615fa9410ac6cceafd2ae2778481f4093b0b15 100644 --- a/core/Command/Check.php +++ b/core/Command/Check.php @@ -50,7 +50,7 @@ class Check extends Base { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $errors = \OC_Util::checkServer($this->config); if (!empty($errors)) { $errors = array_map(function ($item) { diff --git a/core/Command/Config/App/DeleteConfig.php b/core/Command/Config/App/DeleteConfig.php index 8f8f9e66d4bbbc55ab203b9f70dc8bee9d8acbea..6eb1585d599310ada6b0285cb219607ea921d451 100644 --- a/core/Command/Config/App/DeleteConfig.php +++ b/core/Command/Config/App/DeleteConfig.php @@ -65,7 +65,7 @@ class DeleteConfig extends Base { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $appName = $input->getArgument('app'); $configName = $input->getArgument('name'); diff --git a/core/Command/Config/App/GetConfig.php b/core/Command/Config/App/GetConfig.php index f52461c17e462d9711a0cbcd56921bf9b8b18770..32a83451b77832497c45b54952209293cb0e9677 100644 --- a/core/Command/Config/App/GetConfig.php +++ b/core/Command/Config/App/GetConfig.php @@ -72,7 +72,7 @@ class GetConfig extends Base { * @param OutputInterface $output An OutputInterface instance * @return null|int null or 0 if everything went fine, or an error code */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $appName = $input->getArgument('app'); $configName = $input->getArgument('name'); $defaultValue = $input->getOption('default-value'); diff --git a/core/Command/Config/App/SetConfig.php b/core/Command/Config/App/SetConfig.php index 393deb010e6c24274bdb94226018d5902338d7b1..327eebfaeb17a25b86f5b9d40656c793b4596b88 100644 --- a/core/Command/Config/App/SetConfig.php +++ b/core/Command/Config/App/SetConfig.php @@ -71,7 +71,7 @@ class SetConfig extends Base { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $appName = $input->getArgument('app'); $configName = $input->getArgument('name'); diff --git a/core/Command/Config/Import.php b/core/Command/Config/Import.php index 3ff1950b7657bb941b8a27acb2a1db30cf669a32..755c6c80cd9a9e2211bc845f57d5d28ff921c821 100644 --- a/core/Command/Config/Import.php +++ b/core/Command/Config/Import.php @@ -60,7 +60,7 @@ class Import extends Command implements CompletionAwareInterface { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $importFile = $input->getArgument('file'); if ($importFile !== null) { $content = $this->getArrayFromFile($importFile); @@ -72,7 +72,7 @@ class Import extends Command implements CompletionAwareInterface { $configs = $this->validateFileContent($content); } catch (\UnexpectedValueException $e) { $output->writeln('<error>' . $e->getMessage(). '</error>'); - return; + return 1; } if (!empty($configs['system'])) { @@ -92,6 +92,7 @@ class Import extends Command implements CompletionAwareInterface { } $output->writeln('<info>Config successfully imported from: ' . $importFile . '</info>'); + return 0; } /** diff --git a/core/Command/Config/ListConfigs.php b/core/Command/Config/ListConfigs.php index 2394811f51744c713a01daf41df6049a511f6c19..e73c3a4831cf7dc60c357c8965a6d29e1f8097b7 100644 --- a/core/Command/Config/ListConfigs.php +++ b/core/Command/Config/ListConfigs.php @@ -71,7 +71,7 @@ class ListConfigs extends Base { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $app = $input->getArgument('app'); $noSensitiveValues = !$input->getOption('private'); @@ -102,6 +102,7 @@ class ListConfigs extends Base { } $this->writeArrayInOutputFormat($input, $output, $configs); + return 0; } /** diff --git a/core/Command/Config/System/DeleteConfig.php b/core/Command/Config/System/DeleteConfig.php index 9bd162f987a03c169ad24d602bb5d061673f7015..8df3f934e1e2472a295ab146bb63feea1c3a1336 100644 --- a/core/Command/Config/System/DeleteConfig.php +++ b/core/Command/Config/System/DeleteConfig.php @@ -62,7 +62,7 @@ class DeleteConfig extends Base { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $configNames = $input->getArgument('name'); $configName = $configNames[0]; diff --git a/core/Command/Config/System/GetConfig.php b/core/Command/Config/System/GetConfig.php index a1ea135e59029903b4a24e3acc0e72c253504c1b..f01ed804de4f4f35b9dcda022d0eac6af4c7ccbd 100644 --- a/core/Command/Config/System/GetConfig.php +++ b/core/Command/Config/System/GetConfig.php @@ -68,7 +68,7 @@ class GetConfig extends Base { * @param OutputInterface $output An OutputInterface instance * @return null|int null or 0 if everything went fine, or an error code */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $configNames = $input->getArgument('name'); $configName = array_shift($configNames); $defaultValue = $input->getOption('default-value'); diff --git a/core/Command/Config/System/SetConfig.php b/core/Command/Config/System/SetConfig.php index 55030be545fab83714926e13803b8f6346046e07..bcc55d746a9b394acad698f6dccf399f7ee4eb63 100644 --- a/core/Command/Config/System/SetConfig.php +++ b/core/Command/Config/System/SetConfig.php @@ -77,7 +77,7 @@ class SetConfig extends Base { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $configNames = $input->getArgument('name'); $configName = $configNames[0]; $configValue = $this->castValue($input->getOption('value'), $input->getOption('type')); diff --git a/core/Command/Db/AddMissingColumns.php b/core/Command/Db/AddMissingColumns.php index 5794b95b76f86dccb41110cbab5039b0a03f3491..3ace75b4eef7432890a839f8dec59b161081f553 100644 --- a/core/Command/Db/AddMissingColumns.php +++ b/core/Command/Db/AddMissingColumns.php @@ -63,12 +63,13 @@ class AddMissingColumns extends Command { ->setDescription('Add missing optional columns to the database tables'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $this->addCoreColumns($output); // Dispatch event so apps can also update columns if needed $event = new GenericEvent($output); $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_COLUMNS_EVENT, $event); + return 0; } /** diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 2784721f55fd4c3ff516a75ad760d7913e9eee56..6f41d9dce23ab91b49bfe705488c6da5fba97b1f 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -69,12 +69,13 @@ class AddMissingIndices extends Command { ->setDescription('Add missing indices to the database tables'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $this->addCoreIndexes($output); // Dispatch event so apps can also update indexes if needed $event = new GenericEvent($output); $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event); + return 0; } /** diff --git a/core/Command/Db/ConvertFilecacheBigInt.php b/core/Command/Db/ConvertFilecacheBigInt.php index 4a833fbbeded7641cf17621855c91cccc9e32303..f65e76ddfc3e87f72881de5af1e4ec21bec2366a 100644 --- a/core/Command/Db/ConvertFilecacheBigInt.php +++ b/core/Command/Db/ConvertFilecacheBigInt.php @@ -71,7 +71,7 @@ class ConvertFilecacheBigInt extends Command { ]; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $schema = new SchemaWrapper($this->connection); $isSqlite = $this->connection->getDatabasePlatform() instanceof SqlitePlatform; $updates = []; diff --git a/core/Command/Db/ConvertMysqlToMB4.php b/core/Command/Db/ConvertMysqlToMB4.php index fd16dd09439f34463bc5f8ebef2aeaf6940055c7..369badf0dfe63d314e796f0f269e9a9e3e557013 100644 --- a/core/Command/Db/ConvertMysqlToMB4.php +++ b/core/Command/Db/ConvertMysqlToMB4.php @@ -68,7 +68,7 @@ class ConvertMysqlToMB4 extends Command { ->setDescription('Convert charset of MySQL/MariaDB to use utf8mb4'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) { $output->writeln("This command is only valid for MySQL/MariaDB databases."); return 1; diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index c6d4c9e10f2e732b4582e308725a68d935c00c51..2c4b7d14de3817b78848c1c0aadd8297996f3bab 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -188,7 +188,7 @@ class ConvertType extends Command implements CompletionAwareInterface { } } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $this->validateInput($input, $output); $this->readPassword($input, $output); @@ -221,11 +221,12 @@ class ConvertType extends Command implements CompletionAwareInterface { $helper = $this->getHelper('question'); if (!$helper->ask($input, $output, $question)) { - return; + return 1; } } $intersectingTables = array_intersect($toTables, $fromTables); $this->convertDB($fromDB, $toDB, $intersectingTables, $input, $output); + return 0; } protected function createSchema(Connection $fromDB, Connection $toDB, InputInterface $input, OutputInterface $output) { diff --git a/core/Command/Db/Migrations/ExecuteCommand.php b/core/Command/Db/Migrations/ExecuteCommand.php index 149ca8904b7d824aa9ec0ccdd0029a99a7413b2c..95f1acd14fe8a59a5d3c2bfb52c6d336660c3069 100644 --- a/core/Command/Db/Migrations/ExecuteCommand.php +++ b/core/Command/Db/Migrations/ExecuteCommand.php @@ -75,7 +75,7 @@ class ExecuteCommand extends Command implements CompletionAwareInterface { * @param OutputInterface $output * @return int */ - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { $appName = $input->getArgument('app'); $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); $version = $input->getArgument('version'); diff --git a/core/Command/Db/Migrations/GenerateCommand.php b/core/Command/Db/Migrations/GenerateCommand.php index 6d554a57858f6b044173ad063bf30c150e4f59fb..754d1f48401061e6c7d2c1df98da3f7419c377a6 100644 --- a/core/Command/Db/Migrations/GenerateCommand.php +++ b/core/Command/Db/Migrations/GenerateCommand.php @@ -110,7 +110,7 @@ class {{classname}} extends SimpleMigrationStep { parent::configure(); } - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { $appName = $input->getArgument('app'); $version = $input->getArgument('version'); diff --git a/core/Command/Db/Migrations/GenerateFromSchemaFileCommand.php b/core/Command/Db/Migrations/GenerateFromSchemaFileCommand.php index 4f93b59fe322295322a86e3587389b8c0858aa5c..71349c0fa514527bc031f87693793060ce1490ff 100644 --- a/core/Command/Db/Migrations/GenerateFromSchemaFileCommand.php +++ b/core/Command/Db/Migrations/GenerateFromSchemaFileCommand.php @@ -52,7 +52,7 @@ class GenerateFromSchemaFileCommand extends GenerateCommand { $this->setName('migrations:generate-from-schema'); } - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { $appName = $input->getArgument('app'); $version = $input->getArgument('version'); diff --git a/core/Command/Db/Migrations/MigrateCommand.php b/core/Command/Db/Migrations/MigrateCommand.php index 2b0fe268369ae4e222f2607fc29ecbfa651986a5..229288c794abba2a409fdcc36dc71d7dddf7c5b4 100644 --- a/core/Command/Db/Migrations/MigrateCommand.php +++ b/core/Command/Db/Migrations/MigrateCommand.php @@ -55,12 +55,13 @@ class MigrateCommand extends Command implements CompletionAwareInterface { parent::configure(); } - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { $appName = $input->getArgument('app'); $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); $version = $input->getArgument('version'); $ms->migrate($version); + return 0; } /** diff --git a/core/Command/Db/Migrations/StatusCommand.php b/core/Command/Db/Migrations/StatusCommand.php index b9aa918ebbf929b5c165a3515cd77869ea1ace16..dc92dfb1f5032f8dfc11dec27e7cf65190244184 100644 --- a/core/Command/Db/Migrations/StatusCommand.php +++ b/core/Command/Db/Migrations/StatusCommand.php @@ -53,7 +53,7 @@ class StatusCommand extends Command implements CompletionAwareInterface { ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on'); } - public function execute(InputInterface $input, OutputInterface $output) { + public function execute(InputInterface $input, OutputInterface $output): int { $appName = $input->getArgument('app'); $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); @@ -68,6 +68,7 @@ class StatusCommand extends Command implements CompletionAwareInterface { $output->writeln(" <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value); } } + return 0; } /** diff --git a/core/Command/Encryption/ChangeKeyStorageRoot.php b/core/Command/Encryption/ChangeKeyStorageRoot.php index 894b1f664bf61fb50c3a0e3ec8c89ee9f78e44a2..00e0f8fe332cdca91cb41f86ec297cdae5737704 100644 --- a/core/Command/Encryption/ChangeKeyStorageRoot.php +++ b/core/Command/Encryption/ChangeKeyStorageRoot.php @@ -84,14 +84,14 @@ class ChangeKeyStorageRoot extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $oldRoot = $this->util->getKeyStorageRoot(); $newRoot = $input->getArgument('newRoot'); if ($newRoot === null) { $question = new ConfirmationQuestion('No storage root given, do you want to reset the key storage root to the default location? (y/n) ', false); if (!$this->questionHelper->ask($input, $output, $question)) { - return; + return 1; } $newRoot = ''; } @@ -104,7 +104,9 @@ class ChangeKeyStorageRoot extends Command { $this->util->setKeyStorageRoot($newRoot); $output->writeln(''); $output->writeln("Key storage root successfully changed to <info>$newRootDescription</info>"); + return 0; } + return 1; } /** diff --git a/core/Command/Encryption/DecryptAll.php b/core/Command/Encryption/DecryptAll.php index 14bf74d81207a84a0580a2056f6865cef238e47f..51dc74d1eb7b67811b5d0a827ea28705a14eeafc 100644 --- a/core/Command/Encryption/DecryptAll.php +++ b/core/Command/Encryption/DecryptAll.php @@ -125,14 +125,14 @@ class DecryptAll extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { if (!$input->isInteractive()) { $output->writeln('Invalid TTY.'); $output->writeln('If you are trying to execute the command in a Docker '); $output->writeln("container, do not forget to execute 'docker exec' with"); $output->writeln("the '-i' and '-t' options."); $output->writeln(''); - return; + return 1; } $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); @@ -141,7 +141,7 @@ class DecryptAll extends Command { $output->writeln("in order to load the relevant encryption modules correctly."); $output->writeln("Your instance will automatically be put to maintenance mode"); $output->writeln("during the actual decryption of the files."); - return; + return 1; } try { @@ -151,7 +151,7 @@ class DecryptAll extends Command { $output->writeln('done.'); } else { $output->writeln('Server side encryption not enabled. Nothing to do.'); - return; + return 0; } $uid = $input->getArgument('user'); @@ -181,11 +181,13 @@ class DecryptAll extends Command { $this->config->setAppValue('core', 'encryption_enabled', 'yes'); } $this->resetMaintenanceAndTrashbin(); + return 0; } else { $output->write('Enable server side encryption... '); $this->config->setAppValue('core', 'encryption_enabled', 'yes'); $output->writeln('done.'); $output->writeln('aborted'); + return 1; } } catch (\Exception $e) { // enable server side encryption again if something went wrong diff --git a/core/Command/Encryption/Disable.php b/core/Command/Encryption/Disable.php index 4d7542f0a0c0dab93d1f4f33b4a363539707c1d4..c188e6c097b279f1a4182a7e5696e8da3b3a2ddc 100644 --- a/core/Command/Encryption/Disable.php +++ b/core/Command/Encryption/Disable.php @@ -46,12 +46,13 @@ class Disable extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { if ($this->config->getAppValue('core', 'encryption_enabled', 'no') !== 'yes') { $output->writeln('Encryption is already disabled'); } else { $this->config->setAppValue('core', 'encryption_enabled', 'no'); $output->writeln('<info>Encryption disabled</info>'); } + return 0; } } diff --git a/core/Command/Encryption/Enable.php b/core/Command/Encryption/Enable.php index 2c475ca666a1536216d5779edb4377cb49316396..2de6eb2e0c73e73e72dc61a604027f80f881799c 100644 --- a/core/Command/Encryption/Enable.php +++ b/core/Command/Encryption/Enable.php @@ -54,7 +54,7 @@ class Enable extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { if ($this->config->getAppValue('core', 'encryption_enabled', 'no') === 'yes') { $output->writeln('Encryption is already enabled'); } else { @@ -66,15 +66,19 @@ class Enable extends Command { $modules = $this->encryptionManager->getEncryptionModules(); if (empty($modules)) { $output->writeln('<error>No encryption module is loaded</error>'); + return 1; } else { $defaultModule = $this->config->getAppValue('core', 'default_encryption_module', null); if ($defaultModule === null) { $output->writeln('<error>No default module is set</error>'); + return 1; } elseif (!isset($modules[$defaultModule])) { $output->writeln('<error>The current default module does not exist: ' . $defaultModule . '</error>'); + return 1; } else { $output->writeln('Default module: ' . $defaultModule); } } + return 0; } } diff --git a/core/Command/Encryption/EncryptAll.php b/core/Command/Encryption/EncryptAll.php index f2e798966ba7031afbb1dbd85ab535d19181b6eb..0be03fd95b1d80db75093d9cf4651676b6ee5afe 100644 --- a/core/Command/Encryption/EncryptAll.php +++ b/core/Command/Encryption/EncryptAll.php @@ -106,14 +106,14 @@ class EncryptAll extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { if (!$input->isInteractive()) { $output->writeln('Invalid TTY.'); $output->writeln('If you are trying to execute the command in a Docker '); $output->writeln("container, do not forget to execute 'docker exec' with"); $output->writeln("the '-i' and '-t' options."); $output->writeln(''); - return; + return 1; } if ($this->encryptionManager->isEnabled() === false) { @@ -141,6 +141,8 @@ class EncryptAll extends Command { $this->resetMaintenanceAndTrashbin(); } else { $output->writeln('aborted'); + return 1; } + return 0; } } diff --git a/core/Command/Encryption/ListModules.php b/core/Command/Encryption/ListModules.php index 812d2542d5151f982253aee606be42cada1ed3de..21a8be8057f0ded959a6a7ecd53189f1ebbd7667 100644 --- a/core/Command/Encryption/ListModules.php +++ b/core/Command/Encryption/ListModules.php @@ -59,12 +59,12 @@ class ListModules extends Base { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); if ($isMaintenanceModeEnabled) { $output->writeln("Maintenance mode must be disabled when listing modules"); $output->writeln("in order to list the relevant encryption modules correctly."); - return; + return 1; } $encryptionModules = $this->encryptionManager->getEncryptionModules(); @@ -76,6 +76,7 @@ class ListModules extends Base { $encModules[$module['id']]['default'] = $module['id'] === $defaultEncryptionModuleId; } $this->writeModuleList($input, $output, $encModules); + return 0; } /** diff --git a/core/Command/Encryption/SetDefaultModule.php b/core/Command/Encryption/SetDefaultModule.php index 01c85abdf6e5539153fdf469317101f2003c7520..21c1ba77322c82c6f4abc85a898adedc9f901239 100644 --- a/core/Command/Encryption/SetDefaultModule.php +++ b/core/Command/Encryption/SetDefaultModule.php @@ -65,12 +65,12 @@ class SetDefaultModule extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); if ($isMaintenanceModeEnabled) { $output->writeln("Maintenance mode must be disabled when setting default module,"); $output->writeln("in order to load the relevant encryption modules correctly."); - return; + return 1; } $moduleId = $input->getArgument('module'); @@ -81,6 +81,8 @@ class SetDefaultModule extends Command { $output->writeln('<info>Set default module to "' . $moduleId . '"</info>'); } else { $output->writeln('<error>The specified module "' . $moduleId . '" does not exist</error>'); + return 1; } + return 0; } } diff --git a/core/Command/Encryption/ShowKeyStorageRoot.php b/core/Command/Encryption/ShowKeyStorageRoot.php index 8156781e17b39df29a682f5a2e5b73c509c0dc51..caac043856eace4773544aaf9bcc859f01cf1df5 100644 --- a/core/Command/Encryption/ShowKeyStorageRoot.php +++ b/core/Command/Encryption/ShowKeyStorageRoot.php @@ -48,11 +48,12 @@ class ShowKeyStorageRoot extends Command { ->setDescription('Show current key storage root'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $currentRoot = $this->util->getKeyStorageRoot(); $rootDescription = $currentRoot !== '' ? $currentRoot : 'default storage location (data/)'; $output->writeln("Current key storage root: <info>$rootDescription</info>"); + return 0; } } diff --git a/core/Command/Encryption/Status.php b/core/Command/Encryption/Status.php index 70b7aa8776836e658b0881dd5e97bdc6b20edf3d..b7a6f33d7d8d5deb3707a8d8fd07d56c6192f01e 100644 --- a/core/Command/Encryption/Status.php +++ b/core/Command/Encryption/Status.php @@ -48,10 +48,11 @@ class Status extends Base { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $this->writeArrayInOutputFormat($input, $output, [ 'enabled' => $this->encryptionManager->isEnabled(), 'defaultModule' => $this->encryptionManager->getDefaultEncryptionModuleId(), ]); + return 0; } } diff --git a/core/Command/Group/Add.php b/core/Command/Group/Add.php index 1469968d2fc3b062e707448e1c9805ba41ab87ca..14b733f9af1be7c72be491a0b2bc770364e0b2e4 100644 --- a/core/Command/Group/Add.php +++ b/core/Command/Group/Add.php @@ -65,7 +65,7 @@ class Add extends Base { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $gid = $input->getArgument('groupid'); $group = $this->groupManager->get($gid); if ($group) { diff --git a/core/Command/Group/AddUser.php b/core/Command/Group/AddUser.php index 5cbcbf10145c2d74d9fa80759359c05e7f76d9ca..c941c90d1bcec8d4c2d6690ea3ac99a2b134318b 100644 --- a/core/Command/Group/AddUser.php +++ b/core/Command/Group/AddUser.php @@ -61,7 +61,7 @@ class AddUser extends Base { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $group = $this->groupManager->get($input->getArgument('group')); if (is_null($group)) { $output->writeln('<error>group not found</error>'); @@ -73,5 +73,6 @@ class AddUser extends Base { return 1; } $group->addUser($user); + return 0; } } diff --git a/core/Command/Group/Delete.php b/core/Command/Group/Delete.php index 948665585d6b4c44de00206faeae93cc4835d864..010fb556408e9e04b3ad073094531bc4f872e702 100644 --- a/core/Command/Group/Delete.php +++ b/core/Command/Group/Delete.php @@ -55,7 +55,7 @@ class Delete extends Base { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $gid = $input->getArgument('groupid'); if ($gid === 'admin') { $output->writeln('<error>Group "' . $gid . '" could not be deleted.</error>'); @@ -72,5 +72,6 @@ class Delete extends Base { $output->writeln('<error>Group "' . $gid . '" could not be deleted. Please check the logs.</error>'); return 1; } + return 0; } } diff --git a/core/Command/Group/ListCommand.php b/core/Command/Group/ListCommand.php index 09b91cce3bce19d6f0983e31444b5e60a919207b..d8f11ed5b721fb57f5d0108cd1473d971f228717 100644 --- a/core/Command/Group/ListCommand.php +++ b/core/Command/Group/ListCommand.php @@ -67,9 +67,10 @@ class ListCommand extends Base { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups)); + return 0; } /** diff --git a/core/Command/Group/RemoveUser.php b/core/Command/Group/RemoveUser.php index 1401e70458acec8060efed446bf8eec0d3169b0a..f00853279f395ccb6ddabcb518cad1f27b1c25e2 100644 --- a/core/Command/Group/RemoveUser.php +++ b/core/Command/Group/RemoveUser.php @@ -61,7 +61,7 @@ class RemoveUser extends Base { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $group = $this->groupManager->get($input->getArgument('group')); if (is_null($group)) { $output->writeln('<error>group not found</error>'); @@ -73,5 +73,6 @@ class RemoveUser extends Base { return 1; } $group->removeUser($user); + return 0; } } diff --git a/core/Command/Integrity/CheckApp.php b/core/Command/Integrity/CheckApp.php index e57e3fdc9db984888dc09afad84840d57fe76483..225be750d24bece5eb939509ad607d1c4b6e2c86 100644 --- a/core/Command/Integrity/CheckApp.php +++ b/core/Command/Integrity/CheckApp.php @@ -66,7 +66,7 @@ class CheckApp extends Base { /** * {@inheritdoc } */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $appid = $input->getArgument('appid'); $path = (string)$input->getOption('path'); $result = $this->checker->verifyAppSignature($appid, $path); @@ -74,5 +74,6 @@ class CheckApp extends Base { if (count($result)>0) { return 1; } + return 0; } } diff --git a/core/Command/Integrity/CheckCore.php b/core/Command/Integrity/CheckCore.php index ee61962d426eb63eeb6b56a7e2cea5982230db57..1dee77999009ff178910338dcf50884fedefab10 100644 --- a/core/Command/Integrity/CheckCore.php +++ b/core/Command/Integrity/CheckCore.php @@ -59,11 +59,12 @@ class CheckCore extends Base { /** * {@inheritdoc } */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $result = $this->checker->verifyCoreSignature(); $this->writeArrayInOutputFormat($input, $output, $result); if (count($result)>0) { return 1; } + return 0; } } diff --git a/core/Command/Integrity/SignApp.php b/core/Command/Integrity/SignApp.php index c8a876dca5ad3e97be2772322433dbffe6694636..411ea43cbe0bbdebbd9eda25e11359e10c2a2c58 100644 --- a/core/Command/Integrity/SignApp.php +++ b/core/Command/Integrity/SignApp.php @@ -73,7 +73,7 @@ class SignApp extends Command { /** * {@inheritdoc } */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $path = $input->getOption('path'); $privateKeyPath = $input->getOption('privateKey'); $keyBundlePath = $input->getOption('certificate'); @@ -82,7 +82,7 @@ class SignApp extends Command { $output->writeln('This command requires the --path, --privateKey and --certificate.'); $output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"'); $output->writeln('For more information please consult the documentation: '. $documentationUrl); - return null; + return 1; } $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); @@ -90,12 +90,12 @@ class SignApp extends Command { if ($privateKey === false) { $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); - return null; + return 1; } if ($keyBundle === false) { $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); - return null; + return 1; } $rsa = new RSA(); diff --git a/core/Command/Integrity/SignCore.php b/core/Command/Integrity/SignCore.php index 6da09b52c100999dc57875e2bd7006f71a9dbca1..54c1f2a544578ed85cd436ccb67d183a4f5cdc0f 100644 --- a/core/Command/Integrity/SignCore.php +++ b/core/Command/Integrity/SignCore.php @@ -67,13 +67,13 @@ class SignCore extends Command { /** * {@inheritdoc } */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $privateKeyPath = $input->getOption('privateKey'); $keyBundlePath = $input->getOption('certificate'); $path = $input->getOption('path'); if (is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) { $output->writeln('--privateKey, --certificate and --path are required.'); - return null; + return 1; } $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); @@ -81,12 +81,12 @@ class SignCore extends Command { if ($privateKey === false) { $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); - return null; + return 1; } if ($keyBundle === false) { $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); - return null; + return 1; } $rsa = new RSA(); diff --git a/core/Command/L10n/CreateJs.php b/core/Command/L10n/CreateJs.php index 05d58ec231dc14f21c867dfa947d65ac18136a79..2402369d2747fcec45ea9e43cb681f41b1605f98 100644 --- a/core/Command/L10n/CreateJs.php +++ b/core/Command/L10n/CreateJs.php @@ -52,14 +52,14 @@ class CreateJs extends Command implements CompletionAwareInterface { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $app = $input->getArgument('app'); $lang = $input->getArgument('lang'); $path = \OC_App::getAppPath($app); if ($path === false) { $output->writeln("The app <$app> is unknown."); - return; + return 1; } $languages = $lang; if (empty($lang)) { @@ -69,6 +69,7 @@ class CreateJs extends Command implements CompletionAwareInterface { foreach ($languages as $lang) { $this->writeFiles($app, $path, $lang, $output); } + return 0; } private function getAllLanguages($path) { diff --git a/core/Command/Log/File.php b/core/Command/Log/File.php index 0f7fa9c1a47f09f505f572ada58100be99b0cfe1..5ab3cc16e469e31e5151e14aad71c09406d34f5e 100644 --- a/core/Command/Log/File.php +++ b/core/Command/Log/File.php @@ -72,7 +72,7 @@ class File extends Command implements Completion\CompletionAwareInterface { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $toBeSet = []; if ($input->getOption('enable')) { @@ -115,6 +115,7 @@ class File extends Command implements Completion\CompletionAwareInterface { $rotateString = 'disabled'; } $output->writeln('Rotate at: '.$rotateString); + return 0; } /** diff --git a/core/Command/Log/Manage.php b/core/Command/Log/Manage.php index 3eb24a44178d1e5e444cc09cc3f7f00cb4915e85..3a2cd64a9a07af736ba295a3c17420f5e8029954 100644 --- a/core/Command/Log/Manage.php +++ b/core/Command/Log/Manage.php @@ -73,7 +73,7 @@ class Manage extends Command implements CompletionAwareInterface { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { // collate config setting to the end, to avoid partial configuration $toBeSet = []; @@ -114,6 +114,7 @@ class Manage extends Command implements CompletionAwareInterface { $timezone = $this->config->getSystemValue('logtimezone', self::DEFAULT_TIMEZONE); $output->writeln('Log timezone: '.$timezone); + return 0; } /** diff --git a/core/Command/Maintenance/DataFingerprint.php b/core/Command/Maintenance/DataFingerprint.php index 18c54819a1db73a52071dce8e43044f2a6d7b9a3..4b513ffd40ad4456111923d3459728d71c179990 100644 --- a/core/Command/Maintenance/DataFingerprint.php +++ b/core/Command/Maintenance/DataFingerprint.php @@ -48,7 +48,8 @@ class DataFingerprint extends Command { ->setDescription('update the systems data-fingerprint after a backup is restored'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $this->config->setSystemValue('data-fingerprint', md5($this->timeFactory->getTime())); + return 0; } } diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php index f726699d03777f8bebd6884f2c8e72c047546c52..9cca77bb9c0882d30205de43297c967a118d5a39 100644 --- a/core/Command/Maintenance/Install.php +++ b/core/Command/Maintenance/Install.php @@ -73,7 +73,7 @@ class Install extends Command { ->addOption('data-dir', null, InputOption::VALUE_REQUIRED, 'Path to data directory', \OC::$SERVERROOT."/data"); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { // validate the environment $server = \OC::$server; diff --git a/core/Command/Maintenance/Mimetype/UpdateDB.php b/core/Command/Maintenance/Mimetype/UpdateDB.php index 80ea06433b2d3e0f2239159b70028a30aea54c28..ddca668dd1e4a6d99d80da37f714f2a14edba3a7 100644 --- a/core/Command/Maintenance/Mimetype/UpdateDB.php +++ b/core/Command/Maintenance/Mimetype/UpdateDB.php @@ -63,7 +63,7 @@ class UpdateDB extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $mappings = $this->mimetypeDetector->getAllMappings(); $totalFilecacheUpdates = 0; @@ -95,5 +95,6 @@ class UpdateDB extends Command { $output->writeln('Added '.$totalNewMimetypes.' new mimetypes'); $output->writeln('Updated '.$totalFilecacheUpdates.' filecache rows'); + return 0; } } diff --git a/core/Command/Maintenance/Mimetype/UpdateJS.php b/core/Command/Maintenance/Mimetype/UpdateJS.php index fd5f17ef7bb993c06092cc80b483219b559ad6e7..bc1ab7de7906c33da5cff89928fb1b6332b2f759 100644 --- a/core/Command/Maintenance/Mimetype/UpdateJS.php +++ b/core/Command/Maintenance/Mimetype/UpdateJS.php @@ -48,7 +48,7 @@ class UpdateJS extends Command { ->setDescription('Update mimetypelist.js'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { // Fetch all the aliases $aliases = $this->mimetypeDetector->getAllAliases(); @@ -57,5 +57,6 @@ class UpdateJS extends Command { file_put_contents(\OC::$SERVERROOT.'/core/js/mimetypelist.js', $generatedMimetypeFile->generateFile($aliases)); $output->writeln('<info>mimetypelist.js is updated'); + return 0; } } diff --git a/core/Command/Maintenance/Mode.php b/core/Command/Maintenance/Mode.php index e78d7827fde60725fd0cb8d534d40f92402e883b..4a2f64981ec6a7e9fa9d629405aef660e3f709cd 100644 --- a/core/Command/Maintenance/Mode.php +++ b/core/Command/Maintenance/Mode.php @@ -61,7 +61,7 @@ class Mode extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $maintenanceMode = $this->config->getSystemValueBool('maintenance'); if ($input->getOption('on')) { if ($maintenanceMode === false) { @@ -84,5 +84,6 @@ class Mode extends Command { $output->writeln('Maintenance mode is currently disabled'); } } + return 0; } } diff --git a/core/Command/Maintenance/Repair.php b/core/Command/Maintenance/Repair.php index df5ce068b4e8070248f7d38017566f92b51f5bba..b61bd6e34865a45207014cd8826780aba0be5443 100644 --- a/core/Command/Maintenance/Repair.php +++ b/core/Command/Maintenance/Repair.php @@ -79,7 +79,7 @@ class Repair extends Command { 'Use this option when you want to include resource and load expensive tasks'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $repairSteps = $this->repair::getRepairSteps(); if ($input->getOption('include-expensive')) { @@ -126,6 +126,7 @@ class Repair extends Command { $this->repair->run(); $this->config->setSystemValue('maintenance', $maintenanceMode); + return 0; } public function handleRepairFeedBack($event) { diff --git a/core/Command/Maintenance/UpdateHtaccess.php b/core/Command/Maintenance/UpdateHtaccess.php index 7f143536bfa6afde57c18211c68388bfa636c900..b06127d712fb5241291f87281fe37173a97b84ab 100644 --- a/core/Command/Maintenance/UpdateHtaccess.php +++ b/core/Command/Maintenance/UpdateHtaccess.php @@ -36,7 +36,7 @@ class UpdateHtaccess extends Command { ->setDescription('Updates the .htaccess file'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { if (\OC\Setup::updateHtaccess()) { $output->writeln('.htaccess has been updated'); return 0; diff --git a/core/Command/Maintenance/UpdateTheme.php b/core/Command/Maintenance/UpdateTheme.php index ce13215e05e883ff27f711815dc7a9d16f2d14da..b055f1a0c7f526cd9209f902f1e408e39fd09294 100644 --- a/core/Command/Maintenance/UpdateTheme.php +++ b/core/Command/Maintenance/UpdateTheme.php @@ -54,7 +54,7 @@ class UpdateTheme extends UpdateJS { ->setDescription('Apply custom theme changes'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { // run mimetypelist.js update since themes might change mimetype icons parent::execute($input, $output); @@ -62,5 +62,6 @@ class UpdateTheme extends UpdateJS { $c = $this->cacheFactory->createDistributed('imagePath'); $c->clear(''); $output->writeln('<info>Image cache cleared</info>'); + return 0; } } diff --git a/core/Command/Security/ImportCertificate.php b/core/Command/Security/ImportCertificate.php index 7d540bc946d28e157488444861d0df0cca0a0b0e..0d4ca70dabf46dc035c7dc57f9ec9fd96b0b0805 100644 --- a/core/Command/Security/ImportCertificate.php +++ b/core/Command/Security/ImportCertificate.php @@ -49,17 +49,18 @@ class ImportCertificate extends Base { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $path = $input->getArgument('path'); if (!file_exists($path)) { $output->writeln('<error>certificate not found</error>'); - return; + return 1; } $certData = file_get_contents($path); $name = basename($path); $this->certificateManager->addCertificate($certData, $name); + return 0; } } diff --git a/core/Command/Security/ListCertificates.php b/core/Command/Security/ListCertificates.php index 594fa1bc4d53def3281e6b82c68674bf86a06628..59cb92abe1dcb29ef8430446bdc310e1292665ce 100644 --- a/core/Command/Security/ListCertificates.php +++ b/core/Command/Security/ListCertificates.php @@ -50,7 +50,7 @@ class ListCertificates extends Base { parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $outputType = $input->getOption('output'); if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) { $certificates = array_map(function (ICertificate $certificate) { @@ -91,5 +91,6 @@ class ListCertificates extends Base { $table->setRows($rows); $table->render(); } + return 0; } } diff --git a/core/Command/Security/RemoveCertificate.php b/core/Command/Security/RemoveCertificate.php index 4aa97a6175773ffa701208eeb99822357457a286..fd0b536f29994f965af5e0551eb70aaa8031fe1e 100644 --- a/core/Command/Security/RemoveCertificate.php +++ b/core/Command/Security/RemoveCertificate.php @@ -50,9 +50,10 @@ class RemoveCertificate extends Base { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $name = $input->getArgument('name'); $this->certificateManager->removeCertificate($name); + return 0; } } diff --git a/core/Command/Security/ResetBruteforceAttempts.php b/core/Command/Security/ResetBruteforceAttempts.php index dcb827f8ddbf56bb5d670d9c95059ce64d43bc7e..694b65c7acf0bf0d2319058bd4701c841b305483 100644 --- a/core/Command/Security/ResetBruteforceAttempts.php +++ b/core/Command/Security/ResetBruteforceAttempts.php @@ -49,7 +49,7 @@ class ResetBruteforceAttempts extends Base { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $ip = $input->getArgument('ipaddress'); if (!filter_var($ip, FILTER_VALIDATE_IP)) { @@ -58,5 +58,6 @@ class ResetBruteforceAttempts extends Base { } $this->throttler->resetDelayForIP($ip); + return 0; } } diff --git a/core/Command/Status.php b/core/Command/Status.php index 7702a672fc82aea1021425f802bff1256a75047e..0c3257f8a59a95e9b7431022cdce315e58b8a770 100644 --- a/core/Command/Status.php +++ b/core/Command/Status.php @@ -38,7 +38,7 @@ class Status extends Base { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $values = [ 'installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false), 'version' => implode('.', \OCP\Util::getVersion()), @@ -47,5 +47,6 @@ class Status extends Base { ]; $this->writeArrayInOutputFormat($input, $output, $values); + return 0; } } diff --git a/core/Command/TwoFactorAuth/Cleanup.php b/core/Command/TwoFactorAuth/Cleanup.php index ac9dceef343f4ed91ed4cbe654ec80765a719299..1ff7e16c5e0c30e418cfffcff9aa167950b013cd 100644 --- a/core/Command/TwoFactorAuth/Cleanup.php +++ b/core/Command/TwoFactorAuth/Cleanup.php @@ -50,11 +50,12 @@ class Cleanup extends Base { $this->addArgument('provider-id', InputArgument::REQUIRED); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $providerId = $input->getArgument('provider-id'); $this->registry->cleanUp($providerId); $output->writeln("<info>All user-provider associations for provider <options=bold>$providerId</> have been removed.</info>"); + return 0; } } diff --git a/core/Command/TwoFactorAuth/Disable.php b/core/Command/TwoFactorAuth/Disable.php index 128699a39700375cf59243063137fafa6651bc43..b4f1b1b2822ca533b37ffdc1d056263c2702044f 100644 --- a/core/Command/TwoFactorAuth/Disable.php +++ b/core/Command/TwoFactorAuth/Disable.php @@ -52,7 +52,7 @@ class Disable extends Base { $this->addArgument('provider_id', InputArgument::REQUIRED); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $uid = $input->getArgument('uid'); $providerId = $input->getArgument('provider_id'); $user = $this->userManager->get($uid); diff --git a/core/Command/TwoFactorAuth/Enable.php b/core/Command/TwoFactorAuth/Enable.php index d979768f182fa6068dbacf8ff7b8346450754350..37ef08c2fa3cf92fc1b63a2be06dbf639e524ef0 100644 --- a/core/Command/TwoFactorAuth/Enable.php +++ b/core/Command/TwoFactorAuth/Enable.php @@ -52,7 +52,7 @@ class Enable extends Base { $this->addArgument('provider_id', InputArgument::REQUIRED); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $uid = $input->getArgument('uid'); $providerId = $input->getArgument('provider_id'); $user = $this->userManager->get($uid); diff --git a/core/Command/TwoFactorAuth/Enforce.php b/core/Command/TwoFactorAuth/Enforce.php index 7f3ceb9694ccb031c720108fa9066b95ec9cd4e6..0174fcc76fbd05ef9cb3fb0f7cd4ec60c445e851 100644 --- a/core/Command/TwoFactorAuth/Enforce.php +++ b/core/Command/TwoFactorAuth/Enforce.php @@ -74,7 +74,7 @@ class Enforce extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { if ($input->getOption('on')) { $enforcedGroups = $input->getOption('group'); $excludedGroups = $input->getOption('exclude'); @@ -89,6 +89,7 @@ class Enforce extends Command { } else { $this->writeNotEnforced($output); } + return 0; } /** diff --git a/core/Command/TwoFactorAuth/State.php b/core/Command/TwoFactorAuth/State.php index 438a272223f52b3a39d1df3e2224851062e71cde..5784853d60aa8f5e28b099f46fda8fbf0c94ff80 100644 --- a/core/Command/TwoFactorAuth/State.php +++ b/core/Command/TwoFactorAuth/State.php @@ -52,7 +52,7 @@ class State extends Base { $this->addArgument('uid', InputArgument::REQUIRED); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $uid = $input->getArgument('uid'); $user = $this->userManager->get($uid); if (is_null($user)) { diff --git a/core/Command/Upgrade.php b/core/Command/Upgrade.php index 41088c1685ee7044109137914809e059239cc4e3..76d65ce73cbb5f6d2bee8f349ce6d0a18703399c 100644 --- a/core/Command/Upgrade.php +++ b/core/Command/Upgrade.php @@ -83,7 +83,7 @@ class Upgrade extends Command { * @param InputInterface $input input interface * @param OutputInterface $output output interface */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { if (Util::needUpgrade()) { if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { // Prepend each line with a little timestamp diff --git a/core/Command/User/Add.php b/core/Command/User/Add.php index dfb2c9b8ad4b7b3bdc7be092018b0ce908847325..b75664f16f6917efe3812341d35c9bbc417e4b4c 100644 --- a/core/Command/User/Add.php +++ b/core/Command/User/Add.php @@ -85,7 +85,7 @@ class Add extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $uid = $input->getArgument('uid'); if ($this->userManager->userExists($uid)) { $output->writeln('<error>The user "' . $uid . '" already exists.</error>'); @@ -164,5 +164,6 @@ class Add extends Command { $output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"'); } } + return 0; } } diff --git a/core/Command/User/Delete.php b/core/Command/User/Delete.php index 37099749d08f72aab4810f459b4503feb8bd08fa..c6c7700ce5a88d4574b4c157bd84266853ff386b 100644 --- a/core/Command/User/Delete.php +++ b/core/Command/User/Delete.php @@ -55,18 +55,19 @@ class Delete extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $user = $this->userManager->get($input->getArgument('uid')); if (is_null($user)) { $output->writeln('<error>User does not exist</error>'); - return; + return 0; } if ($user->delete()) { $output->writeln('<info>The specified user was deleted</info>'); - return; + return 0; } $output->writeln('<error>The specified user could not be deleted. Please check the logs.</error>'); + return 1; } } diff --git a/core/Command/User/Disable.php b/core/Command/User/Disable.php index 4967856beb97b77771eabdca98f144c27b0ca14a..7abb625c978a4aff6e8aceb318f1b153fee7f845 100644 --- a/core/Command/User/Disable.php +++ b/core/Command/User/Disable.php @@ -52,14 +52,15 @@ class Disable extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $user = $this->userManager->get($input->getArgument('uid')); if (is_null($user)) { $output->writeln('<error>User does not exist</error>'); - return; + return 1; } $user->setEnabled(false); $output->writeln('<info>The specified user is disabled</info>'); + return 0; } } diff --git a/core/Command/User/Enable.php b/core/Command/User/Enable.php index 5792ba9b7526747523ff12a51897cf4f8c0037f5..c62eee870124e8804fed16c8a39ceec372336a15 100644 --- a/core/Command/User/Enable.php +++ b/core/Command/User/Enable.php @@ -52,14 +52,15 @@ class Enable extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $user = $this->userManager->get($input->getArgument('uid')); if (is_null($user)) { $output->writeln('<error>User does not exist</error>'); - return; + return 1; } $user->setEnabled(true); $output->writeln('<info>The specified user is enabled</info>'); + return 0; } } diff --git a/core/Command/User/Info.php b/core/Command/User/Info.php index 52579a56031f6b80037d33c9b3bbf5687d21357a..ec5f9a4d1f7f5fcf30d54800c0a6356b8266872b 100644 --- a/core/Command/User/Info.php +++ b/core/Command/User/Info.php @@ -65,7 +65,7 @@ class Info extends Base { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $user = $this->userManager->get($input->getArgument('user')); if (is_null($user)) { $output->writeln('<error>user not found</error>'); @@ -85,5 +85,6 @@ class Info extends Base { 'backend' => $user->getBackendClassName() ]; $this->writeArrayInOutputFormat($input, $output, $data); + return 0; } } diff --git a/core/Command/User/LastSeen.php b/core/Command/User/LastSeen.php index b60d88c8617d716f778bc42ee7bf1b6f8d20b877..af80b1e1c059f099b8bb2f410d6642fd3024a564 100644 --- a/core/Command/User/LastSeen.php +++ b/core/Command/User/LastSeen.php @@ -56,11 +56,11 @@ class LastSeen extends Command { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $user = $this->userManager->get($input->getArgument('uid')); if (is_null($user)) { $output->writeln('<error>User does not exist</error>'); - return; + return 1; } $lastLogin = $user->getLastLogin(); @@ -73,5 +73,6 @@ class LastSeen extends Command { $output->writeln($user->getUID() . '`s last login: ' . $date->format('d.m.Y H:i')); } + return 0; } } diff --git a/core/Command/User/ListCommand.php b/core/Command/User/ListCommand.php index 103a999375621723220ff740874e66ab8bcfe373..65305304bf6093b7e7d264b37f4e9f4d5abb62fc 100644 --- a/core/Command/User/ListCommand.php +++ b/core/Command/User/ListCommand.php @@ -81,10 +81,11 @@ class ListCommand extends Base { ); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $users = $this->userManager->search('', (int) $input->getOption('limit'), (int) $input->getOption('offset')); $this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users, (bool)$input->getOption('info'))); + return 0; } /** @@ -96,7 +97,7 @@ class ListCommand extends Base { $keys = array_map(function (IUser $user) { return $user->getUID(); }, $users); - + $values = array_map(function (IUser $user) use ($detailed) { if ($detailed) { $groups = $this->groupManager->getUserGroupIds($user); diff --git a/core/Command/User/Report.php b/core/Command/User/Report.php index fff3924d32499e8000d8dfed44da9b490446f7c0..b7fecee61bb9705e1707abf069d819a80fc4114e 100644 --- a/core/Command/User/Report.php +++ b/core/Command/User/Report.php @@ -51,7 +51,7 @@ class Report extends Command { ->setDescription('shows how many users have access'); } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $table = new Table($output); $table->setHeaders(['User Report', '']); $userCountArray = $this->countUsers(); @@ -75,6 +75,7 @@ class Report extends Command { $table->setRows($rows); $table->render(); + return 0; } private function countUsers() { diff --git a/core/Command/User/ResetPassword.php b/core/Command/User/ResetPassword.php index f5b0736d722e4fba59cdbb990b52977b33f86078..bcb3c774ef02c906ac8a063f30d77a803b21e3eb 100644 --- a/core/Command/User/ResetPassword.php +++ b/core/Command/User/ResetPassword.php @@ -67,7 +67,7 @@ class ResetPassword extends Command { ; } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { $username = $input->getArgument('user'); /** @var $user \OCP\IUser */ @@ -134,5 +134,6 @@ class ResetPassword extends Command { $output->writeln("<error>Error while resetting password!</error>"); return 1; } + return 0; } } diff --git a/core/Command/User/Setting.php b/core/Command/User/Setting.php index 5a2c653bbddbb33a5ecc5ec329b1a7aae2ac133e..2ce09fba646dfbf514edd59d9afaa3252d7e3101 100644 --- a/core/Command/User/Setting.php +++ b/core/Command/User/Setting.php @@ -158,7 +158,7 @@ class Setting extends Base { } } - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output): int { try { $this->checkInput($input); } catch (\InvalidArgumentException $e) { diff --git a/tests/lib/Command/Integrity/SignAppTest.php b/tests/lib/Command/Integrity/SignAppTest.php index 594d17168d6fb17432dd946e5e1910e6033b822d..6802542914fe866922712c5756a8e7e206bcd5cf 100644 --- a/tests/lib/Command/Integrity/SignAppTest.php +++ b/tests/lib/Command/Integrity/SignAppTest.php @@ -76,7 +76,7 @@ class SignAppTest extends TestCase { ->method('writeln') ->with('This command requires the --path, --privateKey and --certificate.'); - $this->assertNull(self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface])); + $this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface])); } public function testExecuteWithMissingPrivateKey() { @@ -104,7 +104,7 @@ class SignAppTest extends TestCase { ->method('writeln') ->with('This command requires the --path, --privateKey and --certificate.'); - $this->assertNull(self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface])); + $this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface])); } public function testExecuteWithMissingCertificate() { @@ -132,7 +132,7 @@ class SignAppTest extends TestCase { ->method('writeln') ->with('This command requires the --path, --privateKey and --certificate.'); - $this->assertNull(self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface])); + $this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface])); } public function testExecuteWithNotExistingPrivateKey() { @@ -166,7 +166,7 @@ class SignAppTest extends TestCase { ->method('writeln') ->with('Private key "privateKey" does not exists.'); - $this->assertNull(self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface])); + $this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface])); } public function testExecuteWithNotExistingCertificate() { @@ -205,7 +205,7 @@ class SignAppTest extends TestCase { ->method('writeln') ->with('Certificate "certificate" does not exists.'); - $this->assertNull(self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface])); + $this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface])); } public function testExecuteWithException() { diff --git a/tests/lib/Command/Integrity/SignCoreTest.php b/tests/lib/Command/Integrity/SignCoreTest.php index 36376ef0e7dd4973da5022f2ae12900ae0058bd9..27e4f66c24219d762a5284bd6c64f00e40bd07c5 100644 --- a/tests/lib/Command/Integrity/SignCoreTest.php +++ b/tests/lib/Command/Integrity/SignCoreTest.php @@ -66,7 +66,7 @@ class SignCoreTest extends TestCase { ->method('writeln') ->with('--privateKey, --certificate and --path are required.'); - $this->assertNull(self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface])); + $this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface])); } public function testExecuteWithMissingCertificate() { @@ -89,7 +89,7 @@ class SignCoreTest extends TestCase { ->method('writeln') ->with('--privateKey, --certificate and --path are required.'); - $this->assertNull(self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface])); + $this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface])); } public function testExecuteWithNotExistingPrivateKey() { @@ -123,7 +123,7 @@ class SignCoreTest extends TestCase { ->method('writeln') ->with('Private key "privateKey" does not exists.'); - $this->assertNull(self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface])); + $this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface])); } public function testExecuteWithNotExistingCertificate() { @@ -162,7 +162,7 @@ class SignCoreTest extends TestCase { ->method('writeln') ->with('Certificate "certificate" does not exists.'); - $this->assertNull(self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface])); + $this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface])); } public function testExecuteWithException() {