diff options
Diffstat (limited to 'core/Command')
58 files changed, 404 insertions, 294 deletions
diff --git a/core/Command/App/CheckCode.php b/core/Command/App/CheckCode.php index b658ccbe2ea..25e22d04171 100644 --- a/core/Command/App/CheckCode.php +++ b/core/Command/App/CheckCode.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <robin@mccorkell.me.uk> @@ -34,7 +35,6 @@ use OC\App\CodeChecker\InfoChecker; use OC\App\CodeChecker\LanguageParseChecker; use OC\App\CodeChecker\PrivateCheck; use OC\App\CodeChecker\StrongComparisonCheck; -use OC\App\InfoParser; use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface; use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext; use Symfony\Component\Console\Command\Command; @@ -43,8 +43,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class CheckCode extends Command implements CompletionAwareInterface { - +class CheckCode extends Command implements CompletionAwareInterface { protected $checkers = [ 'private' => PrivateCheck::class, 'deprecation' => DeprecationCheck::class, @@ -95,40 +94,40 @@ class CheckCode extends Command implements CompletionAwareInterface { $codeChecker = new CodeChecker($checkList, !$input->getOption('skip-validate-info')); - $codeChecker->listen('CodeChecker', 'analyseFileBegin', function($params) use ($output) { - if(OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + $codeChecker->listen('CodeChecker', 'analyseFileBegin', function ($params) use ($output) { + if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $output->writeln("<info>Analysing {$params}</info>"); } }); - $codeChecker->listen('CodeChecker', 'analyseFileFinished', function($filename, $errors) use ($output) { + $codeChecker->listen('CodeChecker', 'analyseFileFinished', function ($filename, $errors) use ($output) { $count = count($errors); // show filename if the verbosity is low, but there are errors in a file - if($count > 0 && OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) { + if ($count > 0 && OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) { $output->writeln("<info>Analysing {$filename}</info>"); } // show error count if there are errors present or the verbosity is high - if($count > 0 || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + if ($count > 0 || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $output->writeln(" {$count} errors"); } - usort($errors, function($a, $b) { + usort($errors, function ($a, $b) { return $a['line'] >$b['line']; }); - foreach($errors as $p) { + foreach ($errors as $p) { $line = sprintf("%' 4d", $p['line']); $output->writeln(" <error>line $line: {$p['disallowedToken']} - {$p['reason']}</error>"); } }); $errors = []; - if(!$input->getOption('skip-checkers')) { + if (!$input->getOption('skip-checkers')) { $errors = $codeChecker->analyse($appId); } - if(!$input->getOption('skip-validate-info')) { + if (!$input->getOption('skip-validate-info')) { $infoChecker = new InfoChecker(); - $infoChecker->listen('InfoChecker', 'parseError', function($error) use ($output) { + $infoChecker->listen('InfoChecker', 'parseError', function ($error) use ($output) { $output->writeln("<error>Invalid appinfo.xml file found: $error</error>"); }); diff --git a/core/Command/App/Enable.php b/core/Command/App/Enable.php index c4e2363def5..e782a7fc0be 100644 --- a/core/Command/App/Enable.php +++ b/core/Command/App/Enable.php @@ -6,6 +6,7 @@ * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> + * @author Sander Ruitenbeek <s.ruitenbeek@getgoing.nl> * * @license AGPL-3.0 * @@ -105,6 +106,10 @@ class Enable extends Command implements CompletionAwareInterface { return $group->getDisplayName(); }, $groupIds); + if ($this->appManager->isInstalled($appId) && $groupIds === []) { + $output->writeln($appId . ' already enabled'); + return; + } try { /** @var Installer $installer */ diff --git a/core/Command/App/Install.php b/core/Command/App/Install.php index 7248ec1e425..65817894955 100644 --- a/core/Command/App/Install.php +++ b/core/Command/App/Install.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> * @author sualko <klaus@jsxc.org> @@ -32,7 +33,6 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Install extends Command { - protected function configure() { $this ->setName('app:install') @@ -64,12 +64,12 @@ class Install extends Command { $installer = \OC::$server->query(Installer::class); $installer->downloadApp($appId); $result = $installer->installApp($appId); - } catch(\Exception $e) { + } catch (\Exception $e) { $output->writeln('Error: ' . $e->getMessage()); return 1; } - if($result === false) { + if ($result === false) { $output->writeln($appId . ' couldn\'t be installed'); return 1; } diff --git a/core/Command/App/ListApps.php b/core/Command/App/ListApps.php index 5ee575f60d9..0765ab39a24 100644 --- a/core/Command/App/ListApps.php +++ b/core/Command/App/ListApps.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> @@ -61,19 +62,19 @@ class ListApps extends Base { } protected function execute(InputInterface $input, OutputInterface $output) { - if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false'){ + if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false') { $shippedFilter = $input->getOption('shipped') === 'true'; } else { $shippedFilter = null; } - + $apps = \OC_App::getAllApps(); $enabledApps = $disabledApps = []; $versions = \OC_App::getAppVersions(); //sort enabled apps above disabled apps foreach ($apps as $app) { - if ($shippedFilter !== null && $this->manager->isShipped($app) !== $shippedFilter){ + if ($shippedFilter !== null && $this->manager->isShipped($app) !== $shippedFilter) { continue; } if ($this->manager->isInstalled($app)) { diff --git a/core/Command/App/Remove.php b/core/Command/App/Remove.php index bb264e77e5f..6e3fa704ef1 100644 --- a/core/Command/App/Remove.php +++ b/core/Command/App/Remove.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2018, Patrik Kernstock <info@pkern.at> * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Patrik Kernstock <info@pkern.at> * @author Roeland Jago Douma <roeland@famdouma.nl> * @@ -96,7 +97,7 @@ class Remove extends Command implements CompletionAwareInterface { try { $this->manager->disableApp($appId); $output->writeln($appId . ' disabled'); - } catch(Throwable $e) { + } catch (Throwable $e) { $output->writeln('<error>Error: ' . $e->getMessage() . '</error>'); $this->logger->logException($e, [ 'app' => 'CLI', @@ -109,7 +110,7 @@ class Remove extends Command implements CompletionAwareInterface { // Let's try to remove the app... try { $result = $this->installer->removeApp($appId); - } catch(Throwable $e) { + } catch (Throwable $e) { $output->writeln('<error>Error: ' . $e->getMessage() . '</error>'); $this->logger->logException($e, [ 'app' => 'CLI', @@ -118,7 +119,7 @@ class Remove extends Command implements CompletionAwareInterface { return 1; } - if($result === false) { + if ($result === false) { $output->writeln($appId . ' could not be removed'); return 1; } diff --git a/core/Command/App/Update.php b/core/Command/App/Update.php index f02da1c66ba..417d1915d05 100644 --- a/core/Command/App/Update.php +++ b/core/Command/App/Update.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2018, michag86 (michag86@arcor.de) * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author michag86 <micha_g@arcor.de> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> @@ -83,15 +84,14 @@ class Update extends Command { $singleAppId = $input->getArgument('app-id'); if ($singleAppId) { - $apps = array($singleAppId); + $apps = [$singleAppId]; try { $this->manager->getAppPath($singleAppId); } catch (\OCP\App\AppPathNotFoundException $e) { $output->writeln($singleAppId . ' not installed'); return 1; } - - } else if ($input->getOption('all') || $input->getOption('showonly')) { + } elseif ($input->getOption('all') || $input->getOption('showonly')) { $apps = \OC_App::getAllApps(); } else { $output->writeln("<error>Please specify an app to update or \"--all\" to update all updatable apps\"</error>"); @@ -107,7 +107,7 @@ class Update extends Command { if (!$input->getOption('showonly')) { try { $result = $this->installer->updateAppstoreApp($appId); - } catch(\Exception $e) { + } catch (\Exception $e) { $this->logger->logException($e, ['message' => 'Failure during update of app "' . $appId . '"','app' => 'app:update']); $output->writeln('Error: ' . $e->getMessage()); $return = 1; @@ -116,7 +116,7 @@ class Update extends Command { if ($result === false) { $output->writeln($appId . ' couldn\'t be updated'); $return = 1; - } else if($result === true) { + } elseif ($result === true) { $output->writeln($appId . ' updated'); } } diff --git a/core/Command/Background/Ajax.php b/core/Command/Background/Ajax.php index e9cd1405ebd..5dc94d939d7 100644 --- a/core/Command/Background/Ajax.php +++ b/core/Command/Background/Ajax.php @@ -1,32 +1,31 @@ <?php /** -* The MIT License (MIT) -* -* Copyright (c) 2015 Christian Kampka <christian@kampka.net> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ + * The MIT License (MIT) + * + * Copyright (c) 2015 Christian Kampka <christian@kampka.net> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ namespace OC\Core\Command\Background; class Ajax extends Base { - protected function getMode() { return 'ajax'; } diff --git a/core/Command/Background/Base.php b/core/Command/Background/Base.php index 32d22d64cb9..41466660000 100644 --- a/core/Command/Background/Base.php +++ b/core/Command/Background/Base.php @@ -1,27 +1,27 @@ <?php /** -* The MIT License (MIT) -* -* Copyright (c) 2015 Christian Kampka <christian@kampka.net> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ + * The MIT License (MIT) + * + * Copyright (c) 2015 Christian Kampka <christian@kampka.net> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ namespace OC\Core\Command\Background; @@ -32,23 +32,21 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** -* An abstract base class for configuring the background job mode -* from the command line interface. -* Subclasses will override the getMode() function to specify the mode to configure. -*/ + * An abstract base class for configuring the background job mode + * from the command line interface. + * Subclasses will override the getMode() function to specify the mode to configure. + */ abstract class Base extends Command { - - abstract protected function getMode(); /** - * @var \OCP\IConfig - */ + * @var \OCP\IConfig + */ protected $config; /** - * @param \OCP\IConfig $config - */ + * @param \OCP\IConfig $config + */ public function __construct(IConfig $config) { $this->config = $config; parent::__construct(); @@ -62,16 +60,16 @@ abstract class Base extends Command { } /** - * Executing this command will set the background job mode for owncloud. - * The mode to set is specified by the concrete sub class by implementing the - * getMode() function. - * - * @param InputInterface $input - * @param OutputInterface $output - */ + * Executing this command will set the background job mode for owncloud. + * The mode to set is specified by the concrete sub class by implementing the + * getMode() function. + * + * @param InputInterface $input + * @param OutputInterface $output + */ protected function execute(InputInterface $input, OutputInterface $output) { $mode = $this->getMode(); - $this->config->setAppValue( 'core', 'backgroundjobs_mode', $mode ); + $this->config->setAppValue('core', 'backgroundjobs_mode', $mode); $output->writeln("Set mode for background jobs to '$mode'"); } } diff --git a/core/Command/Background/Cron.php b/core/Command/Background/Cron.php index 434e88893b2..9dbb4f855e5 100644 --- a/core/Command/Background/Cron.php +++ b/core/Command/Background/Cron.php @@ -1,32 +1,31 @@ <?php /** -* The MIT License (MIT) -* -* Copyright (c) 2015 Christian Kampka <christian@kampka.net> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ + * The MIT License (MIT) + * + * Copyright (c) 2015 Christian Kampka <christian@kampka.net> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ namespace OC\Core\Command\Background; class Cron extends Base { - protected function getMode() { return 'cron'; } diff --git a/core/Command/Background/WebCron.php b/core/Command/Background/WebCron.php index 23dbe98e635..7da379b6a53 100644 --- a/core/Command/Background/WebCron.php +++ b/core/Command/Background/WebCron.php @@ -1,32 +1,31 @@ <?php /** -* The MIT License (MIT) -* -* Copyright (c) 2015 Christian Kampka <christian@kampka.net> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ + * The MIT License (MIT) + * + * Copyright (c) 2015 Christian Kampka <christian@kampka.net> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ namespace OC\Core\Command\Background; class WebCron extends Base { - protected function getMode() { return 'webcron'; } diff --git a/core/Command/Base.php b/core/Command/Base.php index 678f0286db5..3b294198974 100644 --- a/core/Command/Base.php +++ b/core/Command/Base.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Daniel Kesselberg <mail@danielkesselberg.de> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> @@ -34,9 +35,9 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Base extends Command implements CompletionAwareInterface { - const OUTPUT_FORMAT_PLAIN = 'plain'; - const OUTPUT_FORMAT_JSON = 'json'; - const OUTPUT_FORMAT_JSON_PRETTY = 'json_pretty'; + public const OUTPUT_FORMAT_PLAIN = 'plain'; + public const OUTPUT_FORMAT_JSON = 'json'; + public const OUTPUT_FORMAT_JSON_PRETTY = 'json_pretty'; protected $defaultOutputFormat = self::OUTPUT_FORMAT_PLAIN; @@ -121,9 +122,9 @@ class Base extends Command implements CompletionAwareInterface { protected function valueToString($value, $returnNull = true) { if ($value === false) { return 'false'; - } else if ($value === true) { + } elseif ($value === true) { return 'true'; - } else if ($value === null) { + } elseif ($value === null) { return $returnNull ? null : 'null'; } else { return $value; diff --git a/core/Command/Broadcast/Test.php b/core/Command/Broadcast/Test.php index 08fcd1f0d92..93734369ace 100644 --- a/core/Command/Broadcast/Test.php +++ b/core/Command/Broadcast/Test.php @@ -98,5 +98,4 @@ class Test extends Command { return 0; } - } diff --git a/core/Command/Check.php b/core/Command/Check.php index b225aff61ed..a4e17e0bf9c 100644 --- a/core/Command/Check.php +++ b/core/Command/Check.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> @@ -52,7 +53,7 @@ class Check extends Base { protected function execute(InputInterface $input, OutputInterface $output) { $errors = \OC_Util::checkServer($this->config); if (!empty($errors)) { - $errors = array_map(function($item) { + $errors = array_map(function ($item) { return (string) $item['error']; }, $errors); diff --git a/core/Command/Config/Import.php b/core/Command/Config/Import.php index a6e57e92052..3ff1950b765 100644 --- a/core/Command/Config/Import.php +++ b/core/Command/Config/Import.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @@ -33,7 +34,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class Import extends Command implements CompletionAwareInterface { +class Import extends Command implements CompletionAwareInterface { protected $validRootKeys = ['system', 'apps']; /** @var IConfig */ diff --git a/core/Command/Config/System/DeleteConfig.php b/core/Command/Config/System/DeleteConfig.php index 22e83b15f79..9bd162f987a 100644 --- a/core/Command/Config/System/DeleteConfig.php +++ b/core/Command/Config/System/DeleteConfig.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @@ -75,8 +76,7 @@ class DeleteConfig extends Base { try { $value = $this->removeSubValue(array_slice($configNames, 1), $value, $input->hasParameterOption('--error-if-not-exists')); - } - catch (\UnexpectedValueException $e) { + } catch (\UnexpectedValueException $e) { $output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>'); return 1; } @@ -106,10 +106,10 @@ class DeleteConfig extends Base { } else { $currentValue[$nextKey] = $this->removeSubValue($keys, $currentValue[$nextKey], $throwError); } - } else if ($throwError) { + } elseif ($throwError) { throw new \UnexpectedValueException('Config parameter does not exist'); } - } else if ($throwError) { + } elseif ($throwError) { throw new \UnexpectedValueException('Config parameter does not exist'); } diff --git a/core/Command/Config/System/GetConfig.php b/core/Command/Config/System/GetConfig.php index ec4ea7e2577..a1ea135e590 100644 --- a/core/Command/Config/System/GetConfig.php +++ b/core/Command/Config/System/GetConfig.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * * @license AGPL-3.0 @@ -84,7 +85,7 @@ class GetConfig extends Base { foreach ($configNames as $configName) { if (isset($configValue[$configName])) { $configValue = $configValue[$configName]; - } else if (!$input->hasParameterOption('--default-value')) { + } elseif (!$input->hasParameterOption('--default-value')) { return 1; } else { $configValue = $defaultValue; diff --git a/core/Command/Config/System/SetConfig.php b/core/Command/Config/System/SetConfig.php index 0f0d28a038d..55030be545f 100644 --- a/core/Command/Config/System/SetConfig.php +++ b/core/Command/Config/System/SetConfig.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <robin@mccorkell.me.uk> @@ -150,6 +151,7 @@ class SetConfig extends Base { throw new \InvalidArgumentException('Unable to parse value as boolean'); } + // no break case 'null': return [ 'value' => null, diff --git a/core/Command/Db/AddMissingColumns.php b/core/Command/Db/AddMissingColumns.php new file mode 100644 index 00000000000..5794b95b76f --- /dev/null +++ b/core/Command/Db/AddMissingColumns.php @@ -0,0 +1,104 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com> + * + * @author Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\Core\Command\Db; + +use OC\DB\SchemaWrapper; +use OCP\IDBConnection; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\GenericEvent; + +/** + * Class AddMissingColumns + * + * if you added a new lazy column to the database, this is the right place to add + * your update routine for existing instances + * + * @package OC\Core\Command\Db + */ +class AddMissingColumns extends Command { + + /** @var IDBConnection */ + private $connection; + + /** @var EventDispatcherInterface */ + private $dispatcher; + + public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) { + parent::__construct(); + + $this->connection = $connection; + $this->dispatcher = $dispatcher; + } + + protected function configure() { + $this + ->setName('db:add-missing-columns') + ->setDescription('Add missing optional columns to the database tables'); + } + + protected function execute(InputInterface $input, OutputInterface $output) { + $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); + } + + /** + * add missing indices to the share table + * + * @param OutputInterface $output + * @throws \Doctrine\DBAL\Schema\SchemaException + */ + private function addCoreColumns(OutputInterface $output) { + $output->writeln('<info>Check columns of the comments table.</info>'); + + $schema = new SchemaWrapper($this->connection); + $updated = false; + + if ($schema->hasTable('comments')) { + $table = $schema->getTable('comments'); + if (!$table->hasColumn('reference_id')) { + $output->writeln('<info>Adding additional reference_id column to the comments table, this can take some time...</info>'); + $table->addColumn('reference_id', 'string', [ + 'notnull' => false, + 'length' => 64, + ]); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('<info>Comments table updated successfully.</info>'); + } + } + + if (!$updated) { + $output->writeln('<info>Done.</info>'); + } + } +} diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 0152df21737..2784721f55f 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -10,7 +10,8 @@ declare(strict_types=1); * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Citharel <tcit@tcit.fr> + * @author Thomas Citharel <nextcloud@tcit.fr> + * @author Mario Danic <mario@lovelyhq.com> * * @license GNU AGPL version 3 or any later version * @@ -43,7 +44,7 @@ use Symfony\Component\EventDispatcher\GenericEvent; * Class AddMissingIndices * * if you added any new indices to the database, this is the right place to add - * it your update routine for existing instances + * your update routine for existing instances * * @package OC\Core\Command\Db */ @@ -83,7 +84,6 @@ class AddMissingIndices extends Command { * @throws \Doctrine\DBAL\Schema\SchemaException */ private function addCoreIndexes(OutputInterface $output) { - $output->writeln('<info>Check indices of the share table.</info>'); $schema = new SchemaWrapper($this->connection); @@ -255,6 +255,19 @@ class AddMissingIndices extends Command { } } + $output->writeln('<info>Check indices of the oc_properties table.</info>'); + if ($schema->hasTable('properties')) { + $table = $schema->getTable('properties'); + if (!$table->hasIndex('properties_path_index')) { + $output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>'); + + $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('<info>oc_properties table updated successfully.</info>'); + } + } + if (!$updated) { $output->writeln('<info>Done.</info>'); } diff --git a/core/Command/Db/ConvertFilecacheBigInt.php b/core/Command/Db/ConvertFilecacheBigInt.php index 16971e20b6c..4a833fbbede 100644 --- a/core/Command/Db/ConvertFilecacheBigInt.php +++ b/core/Command/Db/ConvertFilecacheBigInt.php @@ -72,7 +72,6 @@ class ConvertFilecacheBigInt extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { - $schema = new SchemaWrapper($this->connection); $isSqlite = $this->connection->getDatabasePlatform() instanceof SqlitePlatform; $updates = []; diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index c79ece79915..c6d4c9e10f2 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -5,6 +5,7 @@ * @author Andreas Fischer <bantu@owncloud.com> * @author Bart Visscher <bartv@thisnet.nl> * @author Bernhard Ostertag <bernieo.code@gmx.de> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Lukas Reschke <lukas@statuscode.ch> * @author Łukasz Buśko <busko.lukasz@pm.me> @@ -239,7 +240,7 @@ class ConvertType extends Command implements CompletionAwareInterface { $schemaManager = new \OC\DB\MDB2SchemaManager($toDB); $apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps(); - foreach($apps as $app) { + foreach ($apps as $app) { if (file_exists(\OC_App::getAppPath($app).'/appinfo/database.xml')) { $schemaManager->createDbFromStructure(\OC_App::getAppPath($app).'/appinfo/database.xml'); } else { @@ -275,7 +276,7 @@ class ConvertType extends Command implements CompletionAwareInterface { if (!empty($toTables)) { $output->writeln('<info>Clearing schema in new database</info>'); } - foreach($toTables as $table) { + foreach ($toTables as $table) { $db->getSchemaManager()->dropTable($table); } } @@ -403,7 +404,7 @@ class ConvertType extends Command implements CompletionAwareInterface { try { // copy table rows - foreach($tables as $table) { + foreach ($tables as $table) { $output->writeln($table); $this->copyTable($fromDB, $toDB, $schema->getTable($table), $input, $output); } @@ -413,7 +414,7 @@ class ConvertType extends Command implements CompletionAwareInterface { } // save new database config $this->saveDBInfo($input); - } catch(\Exception $e) { + } catch (\Exception $e) { $this->config->setSystemValue('maintenance', false); throw $e; } diff --git a/core/Command/Db/Migrations/ExecuteCommand.php b/core/Command/Db/Migrations/ExecuteCommand.php index 1104818e710..149ca8904b7 100644 --- a/core/Command/Db/Migrations/ExecuteCommand.php +++ b/core/Command/Db/Migrations/ExecuteCommand.php @@ -23,7 +23,6 @@ namespace OC\Core\Command\Db\Migrations; - use OC\DB\MigrationService; use OC\Migration\ConsoleOutput; use OCP\App\IAppManager; @@ -128,5 +127,4 @@ class ExecuteCommand extends Command implements CompletionAwareInterface { return []; } - } diff --git a/core/Command/Db/Migrations/GenerateCommand.php b/core/Command/Db/Migrations/GenerateCommand.php index 6e3b26f583c..6d554a57858 100644 --- a/core/Command/Db/Migrations/GenerateCommand.php +++ b/core/Command/Db/Migrations/GenerateCommand.php @@ -25,7 +25,6 @@ namespace OC\Core\Command\Db\Migrations; - use OC\DB\MigrationService; use OC\Migration\ConsoleOutput; use OCP\App\IAppManager; @@ -39,7 +38,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class GenerateCommand extends Command implements CompletionAwareInterface { - protected static $_templateSimple = '<?php diff --git a/core/Command/Db/Migrations/GenerateFromSchemaFileCommand.php b/core/Command/Db/Migrations/GenerateFromSchemaFileCommand.php index 34c91ad6b04..4f93b59fe32 100644 --- a/core/Command/Db/Migrations/GenerateFromSchemaFileCommand.php +++ b/core/Command/Db/Migrations/GenerateFromSchemaFileCommand.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Maxence Lange <maxence@artificial-owl.com> * @@ -24,7 +25,6 @@ namespace OC\Core\Command\Db\Migrations; - use Doctrine\DBAL\Schema\Schema; use OC\DB\MDB2SchemaReader; use OC\DB\MigrationService; @@ -130,7 +130,7 @@ EOT if ($default !== null) { if (is_string($default)) { $default = "'$default'"; - } else if (is_bool($default)) { + } elseif (is_bool($default)) { $default = ($default === true) ? 'true' : 'false'; } $content .= str_replace('{{default}}', $default, <<<'EOT' diff --git a/core/Command/Db/Migrations/MigrateCommand.php b/core/Command/Db/Migrations/MigrateCommand.php index e484dbd3f4f..2b0fe268369 100644 --- a/core/Command/Db/Migrations/MigrateCommand.php +++ b/core/Command/Db/Migrations/MigrateCommand.php @@ -22,7 +22,6 @@ namespace OC\Core\Command\Db\Migrations; - use OC\DB\MigrationService; use OC\Migration\ConsoleOutput; use OCP\IDBConnection; @@ -96,5 +95,4 @@ class MigrateCommand extends Command implements CompletionAwareInterface { return []; } - } diff --git a/core/Command/Db/Migrations/StatusCommand.php b/core/Command/Db/Migrations/StatusCommand.php index 6f19ef03bd6..b9aa918ebbf 100644 --- a/core/Command/Db/Migrations/StatusCommand.php +++ b/core/Command/Db/Migrations/StatusCommand.php @@ -97,7 +97,6 @@ class StatusCommand extends Command implements CompletionAwareInterface { * @return array associative array of human readable info name as key and the actual information as value */ public function getMigrationsInfos(MigrationService $ms) { - $executedMigrations = $ms->getMigratedVersions(); $availableMigrations = $ms->getAvailableVersions(); $executedUnavailableMigrations = array_diff($executedMigrations, array_keys($availableMigrations)); @@ -145,6 +144,4 @@ class StatusCommand extends Command implements CompletionAwareInterface { return $migration; } - - } diff --git a/core/Command/Encryption/ChangeKeyStorageRoot.php b/core/Command/Encryption/ChangeKeyStorageRoot.php index 05626715781..894b1f664bf 100644 --- a/core/Command/Encryption/ChangeKeyStorageRoot.php +++ b/core/Command/Encryption/ChangeKeyStorageRoot.php @@ -4,6 +4,7 @@ * * @author Bjoern Schiessle <bjoern@schiessle.org> * @author Björn Schießle <bjoern@schiessle.org> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Morris Jobke <hey@morrisjobke.de> * * @license AGPL-3.0 @@ -116,7 +117,6 @@ class ChangeKeyStorageRoot extends Command { * @throws \Exception */ protected function moveAllKeys($oldRoot, $newRoot, OutputInterface $output) { - $output->writeln("Start to move keys:"); if ($this->rootView->is_dir($oldRoot) === false) { @@ -150,7 +150,6 @@ class ChangeKeyStorageRoot extends Command { if (!$result) { throw new \Exception("Can't access the new root folder. Please check the permissions and make sure that the folder is in your data folder"); } - } @@ -189,12 +188,11 @@ class ChangeKeyStorageRoot extends Command { * @param OutputInterface $output */ protected function moveUserKeys($oldRoot, $newRoot, OutputInterface $output) { - $progress = new ProgressBar($output); $progress->start(); - foreach($this->userManager->getBackends() as $backend) { + foreach ($this->userManager->getBackends() as $backend) { $limit = 500; $offset = 0; do { @@ -205,7 +203,7 @@ class ChangeKeyStorageRoot extends Command { $this->moveUserEncryptionFolder($user, $oldRoot, $newRoot); } $offset += $limit; - } while(count($users) >= $limit); + } while (count($users) >= $limit); } $progress->finish(); } @@ -219,9 +217,7 @@ class ChangeKeyStorageRoot extends Command { * @throws \Exception */ protected function moveUserEncryptionFolder($user, $oldRoot, $newRoot) { - if ($this->userManager->userExists($user)) { - $source = $oldRoot . '/' . $user . '/files_encryption'; $target = $newRoot . '/' . $user . '/files_encryption'; if ( @@ -268,5 +264,4 @@ class ChangeKeyStorageRoot extends Command { return false; } - } diff --git a/core/Command/Encryption/DecryptAll.php b/core/Command/Encryption/DecryptAll.php index 4d7b4028396..14bf74d8120 100644 --- a/core/Command/Encryption/DecryptAll.php +++ b/core/Command/Encryption/DecryptAll.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Björn Schießle <bjoern@schiessle.org> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author davitol <dtoledo@solidgear.es> * @author Evgeny Golyshev <eugulixes@gmail.com> * @author Joas Schilling <coding@schilljs.com> @@ -125,7 +126,7 @@ class DecryptAll extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { - if ( !$input->isInteractive() ) { + 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"); @@ -175,7 +176,7 @@ class DecryptAll extends Command { $output->writeln(' aborted.'); $output->writeln('Server side encryption remains enabled'); $this->config->setAppValue('core', 'encryption_enabled', 'yes'); - } else if ($uid !== '') { + } elseif ($uid !== '') { $output->writeln('Server side encryption remains enabled'); $this->config->setAppValue('core', 'encryption_enabled', 'yes'); } @@ -192,6 +193,5 @@ class DecryptAll extends Command { $this->resetMaintenanceAndTrashbin(); throw $e; } - } } diff --git a/core/Command/Encryption/Enable.php b/core/Command/Encryption/Enable.php index c9b842bd2a6..2c475ca666a 100644 --- a/core/Command/Encryption/Enable.php +++ b/core/Command/Encryption/Enable.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * * @license AGPL-3.0 @@ -69,7 +70,7 @@ class Enable extends Command { $defaultModule = $this->config->getAppValue('core', 'default_encryption_module', null); if ($defaultModule === null) { $output->writeln('<error>No default module is set</error>'); - } else if (!isset($modules[$defaultModule])) { + } elseif (!isset($modules[$defaultModule])) { $output->writeln('<error>The current default module does not exist: ' . $defaultModule . '</error>'); } else { $output->writeln('Default module: ' . $defaultModule); diff --git a/core/Command/Encryption/EncryptAll.php b/core/Command/Encryption/EncryptAll.php index fecb7778ed8..f2e798966ba 100644 --- a/core/Command/Encryption/EncryptAll.php +++ b/core/Command/Encryption/EncryptAll.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Björn Schießle <bjoern@schiessle.org> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Evgeny Golyshev <eugulixes@gmail.com> * @author Joas Schilling <coding@schilljs.com> * @author Matthew Setter <matthew@matthewsetter.com> @@ -106,7 +107,7 @@ class EncryptAll extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { - if ( !$input->isInteractive() ) { + 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"); @@ -142,5 +143,4 @@ class EncryptAll extends Command { $output->writeln('aborted'); } } - } diff --git a/core/Command/Encryption/ListModules.php b/core/Command/Encryption/ListModules.php index c38571d7c62..812d2542d51 100644 --- a/core/Command/Encryption/ListModules.php +++ b/core/Command/Encryption/ListModules.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Ruben Homs <ruben@homs.codes> * @@ -69,7 +70,7 @@ class ListModules extends Base { $encryptionModules = $this->encryptionManager->getEncryptionModules(); $defaultEncryptionModuleId = $this->encryptionManager->getDefaultEncryptionModuleId(); - $encModules = array(); + $encModules = []; foreach ($encryptionModules as $module) { $encModules[$module['id']]['displayName'] = $module['displayName']; $encModules[$module['id']]['default'] = $module['id'] === $defaultEncryptionModuleId; @@ -84,7 +85,7 @@ class ListModules extends Base { */ protected function writeModuleList(InputInterface $input, OutputInterface $output, $items) { if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { - array_walk($items, function(&$item) { + array_walk($items, function (&$item) { if (!$item['default']) { $item = $item['displayName']; } else { diff --git a/core/Command/Encryption/SetDefaultModule.php b/core/Command/Encryption/SetDefaultModule.php index eb9f3718b1d..01c85abdf6e 100644 --- a/core/Command/Encryption/SetDefaultModule.php +++ b/core/Command/Encryption/SetDefaultModule.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Ruben Homs <ruben@homs.codes> * @@ -23,7 +24,6 @@ namespace OC\Core\Command\Encryption; - use OCP\Encryption\IManager; use OCP\IConfig; use Symfony\Component\Console\Command\Command; @@ -77,7 +77,7 @@ class SetDefaultModule extends Command { if ($moduleId === $this->encryptionManager->getDefaultEncryptionModuleId()) { $output->writeln('"' . $moduleId . '"" is already the default module'); - } else if ($this->encryptionManager->setDefaultEncryptionModule($moduleId)) { + } elseif ($this->encryptionManager->setDefaultEncryptionModule($moduleId)) { $output->writeln('<info>Set default module to "' . $moduleId . '"</info>'); } else { $output->writeln('<error>The specified module "' . $moduleId . '" does not exist</error>'); diff --git a/core/Command/Encryption/ShowKeyStorageRoot.php b/core/Command/Encryption/ShowKeyStorageRoot.php index a1ab9c2915c..8156781e17b 100644 --- a/core/Command/Encryption/ShowKeyStorageRoot.php +++ b/core/Command/Encryption/ShowKeyStorageRoot.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Björn Schießle <bjoern@schiessle.org> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * * @license AGPL-3.0 * @@ -27,7 +28,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class ShowKeyStorageRoot extends Command{ +class ShowKeyStorageRoot extends Command { /** @var Util */ protected $util; @@ -54,5 +55,4 @@ class ShowKeyStorageRoot extends Command{ $output->writeln("Current key storage root: <info>$rootDescription</info>"); } - } diff --git a/core/Command/Integrity/CheckApp.php b/core/Command/Integrity/CheckApp.php index d62c13deffb..e57e3fdc9db 100644 --- a/core/Command/Integrity/CheckApp.php +++ b/core/Command/Integrity/CheckApp.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Carla Schroder <carla@owncloud.com> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Georg Ehrke <oc.list@georgehrke.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> @@ -70,9 +71,8 @@ class CheckApp extends Base { $path = (string)$input->getOption('path'); $result = $this->checker->verifyAppSignature($appid, $path); $this->writeArrayInOutputFormat($input, $output, $result); - if (count($result)>0){ + if (count($result)>0) { return 1; } } - } diff --git a/core/Command/Integrity/CheckCore.php b/core/Command/Integrity/CheckCore.php index bebfbea560e..ee61962d426 100644 --- a/core/Command/Integrity/CheckCore.php +++ b/core/Command/Integrity/CheckCore.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Carla Schroder <carla@owncloud.com> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Roeland Jago Douma <roeland@famdouma.nl> * @author Victor Dubiniuk <dubiniuk@owncloud.com> * @@ -61,7 +62,7 @@ class CheckCore extends Base { protected function execute(InputInterface $input, OutputInterface $output) { $result = $this->checker->verifyCoreSignature(); $this->writeArrayInOutputFormat($input, $output, $result); - if (count($result)>0){ + if (count($result)>0) { return 1; } } diff --git a/core/Command/Integrity/SignApp.php b/core/Command/Integrity/SignApp.php index 6e750d4af10..c8a876dca5a 100644 --- a/core/Command/Integrity/SignApp.php +++ b/core/Command/Integrity/SignApp.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Lukas Reschke <lukas@statuscode.ch> * @author Victor Dubiniuk <dubiniuk@owncloud.com> * @@ -76,7 +77,7 @@ class SignApp extends Command { $path = $input->getOption('path'); $privateKeyPath = $input->getOption('privateKey'); $keyBundlePath = $input->getOption('certificate'); - if(is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) { + if (is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) { $documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity'); $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"'); @@ -87,12 +88,12 @@ class SignApp extends Command { $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); - if($privateKey === false) { + if ($privateKey === false) { $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); return null; } - if($keyBundle === false) { + if ($keyBundle === false) { $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); return null; } @@ -105,7 +106,7 @@ class SignApp extends Command { try { $this->checker->writeAppSignature($path, $x509, $rsa); $output->writeln('Successfully signed "'.$path.'"'); - } catch (\Exception $e){ + } catch (\Exception $e) { $output->writeln('Error: ' . $e->getMessage()); return 1; } diff --git a/core/Command/Integrity/SignCore.php b/core/Command/Integrity/SignCore.php index b825a942d80..6da09b52c10 100644 --- a/core/Command/Integrity/SignCore.php +++ b/core/Command/Integrity/SignCore.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Lukas Reschke <lukas@statuscode.ch> * @author Victor Dubiniuk <dubiniuk@owncloud.com> * @@ -70,7 +71,7 @@ class SignCore extends Command { $privateKeyPath = $input->getOption('privateKey'); $keyBundlePath = $input->getOption('certificate'); $path = $input->getOption('path'); - if(is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) { + if (is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) { $output->writeln('--privateKey, --certificate and --path are required.'); return null; } @@ -78,12 +79,12 @@ class SignCore extends Command { $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); - if($privateKey === false) { + if ($privateKey === false) { $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); return null; } - if($keyBundle === false) { + if ($keyBundle === false) { $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); return null; } @@ -97,7 +98,7 @@ class SignCore extends Command { try { $this->checker->writeCoreSignature($x509, $rsa, $path); $output->writeln('Successfully signed "core"'); - } catch (\Exception $e){ + } catch (\Exception $e) { $output->writeln('Error: ' . $e->getMessage()); return 1; } diff --git a/core/Command/InterruptedException.php b/core/Command/InterruptedException.php index 3ca2f1572a0..caedbc12275 100644 --- a/core/Command/InterruptedException.php +++ b/core/Command/InterruptedException.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2017, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Roeland Jago Douma <roeland@famdouma.nl> * @author Vincent Petry <pvince81@owncloud.com> * @@ -26,4 +27,5 @@ namespace OC\Core\Command; /** * Exception for when the user hit ctrl-c */ -class InterruptedException extends \Exception {} +class InterruptedException extends \Exception { +} diff --git a/core/Command/L10n/CreateJs.php b/core/Command/L10n/CreateJs.php index f2b833fe914..05d58ec231d 100644 --- a/core/Command/L10n/CreateJs.php +++ b/core/Command/L10n/CreateJs.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> @@ -35,7 +36,6 @@ use Symfony\Component\Console\Output\OutputInterface; use UnexpectedValueException; class CreateJs extends Command implements CompletionAwareInterface { - protected function configure() { $this ->setName('l10n:createjs') @@ -66,21 +66,21 @@ class CreateJs extends Command implements CompletionAwareInterface { $languages= $this->getAllLanguages($path); } - foreach($languages as $lang) { + foreach ($languages as $lang) { $this->writeFiles($app, $path, $lang, $output); } } private function getAllLanguages($path) { - $result = array(); + $result = []; foreach (new DirectoryIterator("$path/l10n") as $fileInfo) { - if($fileInfo->isDot()) { + if ($fileInfo->isDot()) { continue; } - if($fileInfo->isDir()) { + if ($fileInfo->isDir()) { continue; } - if($fileInfo->getExtension() !== 'php') { + if ($fileInfo->getExtension() !== 'php') { continue; } $result[]= substr($fileInfo->getBasename(), 0, -4); @@ -102,7 +102,7 @@ class CreateJs extends Command implements CompletionAwareInterface { return; } $content = "OC.L10N.register(\n \"$app\",\n {\n "; - $jsTrans = array(); + $jsTrans = []; foreach ($translations as $id => $val) { if (is_array($val)) { $val = '[ ' . implode(',', $val) . ']'; @@ -122,21 +122,21 @@ class CreateJs extends Command implements CompletionAwareInterface { $output->writeln("File already exists: $jsFile"); return; } - $content = array('translations' => $translations, 'pluralForm' => $plurals); + $content = ['translations' => $translations, 'pluralForm' => $plurals]; file_put_contents($jsFile, json_encode($content)); $output->writeln("Json translation file generated: $jsFile"); } private function loadTranslations($path, $lang) { $phpFile = "$path/l10n/$lang.php"; - $TRANSLATIONS = array(); + $TRANSLATIONS = []; $PLURAL_FORMS = ''; if (!file_exists($phpFile)) { throw new UnexpectedValueException("PHP translation file <$phpFile> does not exist."); } require $phpFile; - return array($TRANSLATIONS, $PLURAL_FORMS); + return [$TRANSLATIONS, $PLURAL_FORMS]; } /** @@ -160,7 +160,7 @@ class CreateJs extends Command implements CompletionAwareInterface { public function completeArgumentValues($argumentName, CompletionContext $context) { if ($argumentName === 'app') { return \OC_App::getAllApps(); - } else if ($argumentName === 'lang') { + } elseif ($argumentName === 'lang') { $appName = $context->getWordAtIndex($context->getWordIndex() - 1); return $this->getAllLanguages(\OC_App::getAppPath($appName)); } diff --git a/core/Command/Log/File.php b/core/Command/Log/File.php index df5e1ba53ab..0f7fa9c1a47 100644 --- a/core/Command/Log/File.php +++ b/core/Command/Log/File.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <robin@mccorkell.me.uk> @@ -143,7 +144,7 @@ class File extends Command implements Completion\CompletionAwareInterface { Completion::TYPE_OPTION ); return $helper->run(); - } else if ($optionName === 'rotate-size') { + } elseif ($optionName === 'rotate-size') { return [0]; } return []; diff --git a/core/Command/Log/Manage.php b/core/Command/Log/Manage.php index b2816ea5f4b..3eb24a44178 100644 --- a/core/Command/Log/Manage.php +++ b/core/Command/Log/Manage.php @@ -2,11 +2,11 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Johannes Ernst <jernst@indiecomputing.com> * @author Robin McCorkell <robin@mccorkell.me.uk> * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Pulzer <t.pulzer@kniel.de> * @author Tim Terhorst <mynamewastaken+gitlab@gmail.com> * * @license AGPL-3.0 @@ -36,10 +36,9 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Manage extends Command implements CompletionAwareInterface { - - const DEFAULT_BACKEND = 'file'; - const DEFAULT_LOG_LEVEL = 2; - const DEFAULT_TIMEZONE = 'UTC'; + public const DEFAULT_BACKEND = 'file'; + public const DEFAULT_LOG_LEVEL = 2; + public const DEFAULT_TIMEZONE = 'UTC'; /** @var IConfig */ protected $config; @@ -188,9 +187,9 @@ class Manage extends Command implements CompletionAwareInterface { public function completeOptionValues($optionName, CompletionContext $context) { if ($optionName === 'backend') { return ['file', 'syslog', 'errorlog', 'systemd']; - } else if ($optionName === 'level') { + } elseif ($optionName === 'level') { return ['debug', 'info', 'warning', 'error', 'fatal']; - } else if ($optionName === 'timezone') { + } elseif ($optionName === 'timezone') { return \DateTimeZone::listIdentifiers(); } return []; diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php index fa18ef721b2..0fe9c28cf91 100644 --- a/core/Command/Maintenance/Install.php +++ b/core/Command/Maintenance/Install.php @@ -4,6 +4,7 @@ * * @author Bernhard Posselt <dev@bernhard-posselt.com> * @author Christian Kampka <christian@kampka.net> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Daniel Hansson <daniel@techandme.se> * @author Daniel Kesselberg <mail@danielkesselberg.de> * @author Joas Schilling <coding@schilljs.com> @@ -92,7 +93,7 @@ class Install extends Command { $this->printErrors($output, $errors); // ignore the OS X setup warning - if(count($errors) !== 1 || + if (count($errors) !== 1 || (string)$errors[0]['error'] !== 'Mac OS X is not supported and Nextcloud will not work properly on this platform. Use it at your own risk! ') { return 1; } diff --git a/core/Command/Maintenance/Mimetype/GenerateMimetypeFileBuilder.php b/core/Command/Maintenance/Mimetype/GenerateMimetypeFileBuilder.php index aa252b8bbb6..0f91ec9a4eb 100644 --- a/core/Command/Maintenance/Mimetype/GenerateMimetypeFileBuilder.php +++ b/core/Command/Maintenance/Mimetype/GenerateMimetypeFileBuilder.php @@ -5,6 +5,7 @@ declare(strict_types=1); /** * @copyright Copyright (c) 2019 Xheni Myrtaj <xheni@protonmail.com> * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Roeland Jago Douma <roeland@famdouma.nl> * @author Xheni Myrtaj <myrtajxheni@gmail.com> * @@ -27,9 +28,7 @@ declare(strict_types=1); namespace OC\Core\Command\Maintenance\Mimetype; - -class GenerateMimetypeFileBuilder -{ +class GenerateMimetypeFileBuilder { /** * Generate mime type list file * @param $aliases @@ -37,10 +36,10 @@ class GenerateMimetypeFileBuilder */ public function generateFile(array $aliases): string { // Remove comments - $keys = array_filter(array_keys($aliases), function($k) { + $keys = array_filter(array_keys($aliases), function ($k) { return $k[0] === '_'; }); - foreach($keys as $key) { + foreach ($keys as $key) { unset($aliases[$key]); } @@ -48,7 +47,7 @@ class GenerateMimetypeFileBuilder $dir = new \DirectoryIterator(\OC::$SERVERROOT.'/core/img/filetypes'); $files = []; - foreach($dir as $fileInfo) { + foreach ($dir as $fileInfo) { if ($fileInfo->isFile()) { $file = preg_replace('/.[^.]*$/', '', $fileInfo->getFilename()); $files[] = $file; @@ -62,7 +61,7 @@ class GenerateMimetypeFileBuilder // Fetch all themes! $themes = []; $dirs = new \DirectoryIterator(\OC::$SERVERROOT.'/themes/'); - foreach($dirs as $dir) { + foreach ($dirs as $dir) { //Valid theme dir if ($dir->isFile() || $dir->isDot()) { continue; @@ -106,5 +105,4 @@ OC.MimeTypeList={ }; '; } - } diff --git a/core/Command/Maintenance/Mimetype/UpdateDB.php b/core/Command/Maintenance/Mimetype/UpdateDB.php index 5bb78d9a3f3..80ea06433b2 100644 --- a/core/Command/Maintenance/Mimetype/UpdateDB.php +++ b/core/Command/Maintenance/Mimetype/UpdateDB.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Robin McCorkell <robin@mccorkell.me.uk> * @author Roeland Jago Douma <roeland@famdouma.nl> * @@ -32,8 +33,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class UpdateDB extends Command { - - const DEFAULT_MIMETYPE = 'application/octet-stream'; + public const DEFAULT_MIMETYPE = 'application/octet-stream'; /** @var IMimeTypeDetector */ protected $mimetypeDetector; diff --git a/core/Command/Maintenance/UpdateHtaccess.php b/core/Command/Maintenance/UpdateHtaccess.php index 6397ed7aec4..7f143536bfa 100644 --- a/core/Command/Maintenance/UpdateHtaccess.php +++ b/core/Command/Maintenance/UpdateHtaccess.php @@ -30,7 +30,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class UpdateHtaccess extends Command { - protected function configure() { $this ->setName('maintenance:update:htaccess') diff --git a/core/Command/Maintenance/UpdateTheme.php b/core/Command/Maintenance/UpdateTheme.php index 9be29f885a7..ce13215e05e 100644 --- a/core/Command/Maintenance/UpdateTheme.php +++ b/core/Command/Maintenance/UpdateTheme.php @@ -61,6 +61,6 @@ class UpdateTheme extends UpdateJS { // cleanup image cache $c = $this->cacheFactory->createDistributed('imagePath'); $c->clear(''); - $output->writeln('<info>Image cache cleared'); + $output->writeln('<info>Image cache cleared</info>'); } } diff --git a/core/Command/Status.php b/core/Command/Status.php index 8f615004f3c..7702a672fc8 100644 --- a/core/Command/Status.php +++ b/core/Command/Status.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Bart Visscher <bartv@thisnet.nl> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @@ -38,12 +39,12 @@ class Status extends Base { } protected function execute(InputInterface $input, OutputInterface $output) { - $values = array( + $values = [ 'installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false), 'version' => implode('.', \OCP\Util::getVersion()), 'versionstring' => \OC_Util::getVersionString(), 'edition' => '', - ); + ]; $this->writeArrayInOutputFormat($input, $output, $values); } diff --git a/core/Command/TwoFactorAuth/Base.php b/core/Command/TwoFactorAuth/Base.php index 3af99daca07..9112fffea42 100644 --- a/core/Command/TwoFactorAuth/Base.php +++ b/core/Command/TwoFactorAuth/Base.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> @@ -54,7 +55,7 @@ class Base extends \OC\Core\Command\Base { */ public function completeArgumentValues($argumentName, CompletionContext $context) { if ($argumentName === 'uid') { - return array_map(function(IUser $user) { + return array_map(function (IUser $user) { return $user->getUID(); }, $this->userManager->search($context->getCurrentWord(), 100)); } diff --git a/core/Command/TwoFactorAuth/Cleanup.php b/core/Command/TwoFactorAuth/Cleanup.php index a8576b15384..ac9dceef343 100644 --- a/core/Command/TwoFactorAuth/Cleanup.php +++ b/core/Command/TwoFactorAuth/Cleanup.php @@ -57,5 +57,4 @@ class Cleanup extends Base { $output->writeln("<info>All user-provider associations for provider <options=bold>$providerId</> have been removed.</info>"); } - } diff --git a/core/Command/TwoFactorAuth/Disable.php b/core/Command/TwoFactorAuth/Disable.php index d08bf7b767e..128699a3970 100644 --- a/core/Command/TwoFactorAuth/Disable.php +++ b/core/Command/TwoFactorAuth/Disable.php @@ -23,7 +23,6 @@ namespace OC\Core\Command\TwoFactorAuth; -use OC\Authentication\TwoFactorAuth\Manager; use OC\Authentication\TwoFactorAuth\ProviderManager; use OCP\IUserManager; use Symfony\Component\Console\Input\InputArgument; @@ -69,5 +68,4 @@ class Disable extends Base { return 2; } } - } diff --git a/core/Command/TwoFactorAuth/Enable.php b/core/Command/TwoFactorAuth/Enable.php index 0c2aef540e9..d979768f182 100644 --- a/core/Command/TwoFactorAuth/Enable.php +++ b/core/Command/TwoFactorAuth/Enable.php @@ -68,5 +68,4 @@ class Enable extends Base { return 2; } } - } diff --git a/core/Command/TwoFactorAuth/Enforce.php b/core/Command/TwoFactorAuth/Enforce.php index e99c584384c..7f3ceb9694c 100644 --- a/core/Command/TwoFactorAuth/Enforce.php +++ b/core/Command/TwoFactorAuth/Enforce.php @@ -112,5 +112,4 @@ class Enforce extends Command { protected function writeNotEnforced(OutputInterface $output) { $output->writeln('Two-factor authentication is not enforced'); } - } diff --git a/core/Command/TwoFactorAuth/State.php b/core/Command/TwoFactorAuth/State.php index 5f658e30507..438a272223f 100644 --- a/core/Command/TwoFactorAuth/State.php +++ b/core/Command/TwoFactorAuth/State.php @@ -62,7 +62,7 @@ class State extends Base { $providerStates = $this->registry->getProviderStates($user); $filtered = $this->filterEnabledDisabledUnknownProviders($providerStates); - list ($enabled, $disabled) = $filtered; + list($enabled, $disabled) = $filtered; if (!empty($enabled)) { $output->writeln("Two-factor authentication is enabled for user $uid"); @@ -104,5 +104,4 @@ class State extends Base { $output->writeln("- " . $provider); } } - } diff --git a/core/Command/Upgrade.php b/core/Command/Upgrade.php index 944b1da9f26..41088c1685e 100644 --- a/core/Command/Upgrade.php +++ b/core/Command/Upgrade.php @@ -4,8 +4,8 @@ * * @author Andreas Fischer <bantu@owncloud.com> * @author Björn Schießle <bjoern@schiessle.org> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> - * @author Jürgen Haas <juergen@paragon-es.de> * @author Lukas Reschke <lukas@statuscode.ch> * @author Morris Jobke <hey@morrisjobke.de> * @author Owen Winkler <a_github@midnightcircus.com> @@ -46,13 +46,12 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\EventDispatcher\GenericEvent; class Upgrade extends Command { - - const ERROR_SUCCESS = 0; - const ERROR_NOT_INSTALLED = 1; - const ERROR_MAINTENANCE_MODE = 2; - const ERROR_UP_TO_DATE = 0; - const ERROR_INVALID_ARGUMENTS = 4; - const ERROR_FAILURE = 5; + public const ERROR_SUCCESS = 0; + public const ERROR_NOT_INSTALLED = 1; + public const ERROR_MAINTENANCE_MODE = 2; + public const ERROR_UP_TO_DATE = 0; + public const ERROR_INVALID_ARGUMENTS = 4; + public const ERROR_FAILURE = 5; /** @var IConfig */ private $config; @@ -85,8 +84,7 @@ class Upgrade extends Command { * @param OutputInterface $output output interface */ protected function execute(InputInterface $input, OutputInterface $output) { - - if(Util::needUpgrade()) { + if (Util::needUpgrade()) { if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { // Prepend each line with a little timestamp $timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter()); @@ -104,7 +102,7 @@ class Upgrade extends Command { $dispatcher = \OC::$server->getEventDispatcher(); $progress = new ProgressBar($output); $progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%"); - $listener = function($event) use ($progress, $output) { + $listener = function ($event) use ($progress, $output) { if ($event instanceof GenericEvent) { $message = $event->getSubject(); if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { @@ -127,7 +125,7 @@ class Upgrade extends Command { } } }; - $repairListener = function($event) use ($progress, $output) { + $repairListener = function ($event) use ($progress, $output) { if (!$event instanceof GenericEvent) { return; } @@ -152,12 +150,12 @@ class Upgrade extends Command { $output->writeln(''); break; case '\OC\Repair::step': - if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>'); } break; case '\OC\Repair::info': - if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>'); } break; @@ -181,17 +179,17 @@ class Upgrade extends Command { $dispatcher->addListener('\OC\Repair::error', $repairListener); - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use($output) { + $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($output) { $output->writeln('<info>Turned on maintenance mode</info>'); }); - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use($output) { + $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($output) { $output->writeln('<info>Turned off maintenance mode</info>'); }); - $updater->listen('\OC\Updater', 'maintenanceActive', function () use($output) { + $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($output) { $output->writeln('<info>Maintenance mode is kept active</info>'); }); $updater->listen('\OC\Updater', 'updateEnd', - function ($success) use($output, $self) { + function ($success) use ($output, $self) { if ($success) { $message = "<info>Update successful</info>"; } else { @@ -199,28 +197,28 @@ class Upgrade extends Command { } $output->writeln($message); }); - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($output) { + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($output) { $output->writeln('<info>Updating database schema</info>'); }); - $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) { + $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) { $output->writeln('<info>Updated database</info>'); }); - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($output) { + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($output) { $output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>'); }); - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($output) { + $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($output) { $output->writeln('<info>Checked database schema update</info>'); }); - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($output) { + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output) { $output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>'); }); - $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use($output) { + $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($output) { $output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>'); }); - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($output) { + $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) { $output->writeln('<info>Update app ' . $app . ' from appstore</info>'); }); - $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use($output) { + $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($output) { $output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>'); }); $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) { @@ -238,19 +236,19 @@ class Upgrade extends Command { $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) { $output->writeln("<info>Updated <$app> to $version</info>"); }); - $updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) { + $updater->listen('\OC\Updater', 'failure', function ($message) use ($output, $self) { $output->writeln("<error>$message</error>"); }); - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use($output) { + $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output) { $output->writeln("<info>Set log level to debug</info>"); }); - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($output) { + $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($output) { $output->writeln("<info>Reset log level</info>"); }); - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($output) { + $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($output) { $output->writeln("<info>Starting code integrity check...</info>"); }); - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($output) { + $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($output) { $output->writeln("<info>Finished code integrity check</info>"); }); @@ -258,12 +256,12 @@ class Upgrade extends Command { $this->postUpgradeCheck($input, $output); - if(!$success) { + if (!$success) { return self::ERROR_FAILURE; } return self::ERROR_SUCCESS; - } else if($this->config->getSystemValueBool('maintenance')) { + } elseif ($this->config->getSystemValueBool('maintenance')) { //Possible scenario: Nextcloud core is updated but an app failed $output->writeln('<warning>Nextcloud is in maintenance mode</warning>'); $output->write('<comment>Maybe an upgrade is already in process. Please check the ' @@ -285,7 +283,7 @@ class Upgrade extends Command { * @param OutputInterface $output output interface */ protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) { - $trustedDomains = $this->config->getSystemValue('trusted_domains', array()); + $trustedDomains = $this->config->getSystemValue('trusted_domains', []); if (empty($trustedDomains)) { $output->write( '<warning>The setting "trusted_domains" could not be ' . diff --git a/core/Command/User/Add.php b/core/Command/User/Add.php index 208fb1dceb5..dfb2c9b8ad4 100644 --- a/core/Command/User/Add.php +++ b/core/Command/User/Add.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Laurens Post <lkpost@scept.re> * @author Roeland Jago Douma <roeland@famdouma.nl> @@ -154,11 +155,11 @@ class Add extends Command { if (!$group) { $this->groupManager->createGroup($groupName); $group = $this->groupManager->get($groupName); - if($group instanceof IGroup) { + if ($group instanceof IGroup) { $output->writeln('Created group "' . $group->getGID() . '"'); } } - if($group instanceof IGroup) { + if ($group instanceof IGroup) { $group->addUser($user); $output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"'); } diff --git a/core/Command/User/LastSeen.php b/core/Command/User/LastSeen.php index 37cad457015..b60d88c8617 100644 --- a/core/Command/User/LastSeen.php +++ b/core/Command/User/LastSeen.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Pierre Ozoux <pierre@ozoux.net> @@ -57,13 +58,13 @@ class LastSeen extends Command { protected function execute(InputInterface $input, OutputInterface $output) { $user = $this->userManager->get($input->getArgument('uid')); - if(is_null($user)) { + if (is_null($user)) { $output->writeln('<error>User does not exist</error>'); return; } $lastLogin = $user->getLastLogin(); - if($lastLogin === 0) { + if ($lastLogin === 0) { $output->writeln('User ' . $user->getUID() . ' has never logged in, yet.'); } else { diff --git a/core/Command/User/Report.php b/core/Command/User/Report.php index 3f15d40dba7..fff3924d324 100644 --- a/core/Command/User/Report.php +++ b/core/Command/User/Report.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> @@ -52,25 +53,25 @@ class Report extends Command { protected function execute(InputInterface $input, OutputInterface $output) { $table = new Table($output); - $table->setHeaders(array('User Report', '')); + $table->setHeaders(['User Report', '']); $userCountArray = $this->countUsers(); - if(!empty($userCountArray)) { + if (!empty($userCountArray)) { $total = 0; - $rows = array(); - foreach($userCountArray as $classname => $users) { + $rows = []; + foreach ($userCountArray as $classname => $users) { $total += $users; - $rows[] = array($classname, $users); + $rows[] = [$classname, $users]; } - $rows[] = array(' '); - $rows[] = array('total users', $total); + $rows[] = [' ']; + $rows[] = ['total users', $total]; } else { - $rows[] = array('No backend enabled that supports user counting', ''); + $rows[] = ['No backend enabled that supports user counting', '']; } $userDirectoryCount = $this->countUserDirectories(); - $rows[] = array(' '); - $rows[] = array('user directories', $userDirectoryCount); + $rows[] = [' ']; + $rows[] = ['user directories', $userDirectoryCount]; $table->setRows($rows); $table->render(); diff --git a/core/Command/User/Setting.php b/core/Command/User/Setting.php index 521ac850b92..5a2c653bbdd 100644 --- a/core/Command/User/Setting.php +++ b/core/Command/User/Setting.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> * @author Joas Schilling <coding@schilljs.com> * @author Kim Brose <kim.brose@rwth-aachen.de> * @author Roeland Jago Douma <roeland@famdouma.nl> @@ -187,8 +188,7 @@ class Setting extends Base { $this->config->setUserValue($uid, $app, $key, $input->getArgument('value')); return 0; - - } else if ($input->hasParameterOption('--delete')) { + } elseif ($input->hasParameterOption('--delete')) { if ($input->hasParameterOption('--error-if-not-exists') && $value === null) { $output->writeln('<error>The setting does not exist for user "' . $uid . '".</error>'); return 1; @@ -204,8 +204,7 @@ class Setting extends Base { $this->config->deleteUserValue($uid, $app, $key); return 0; - - } else if ($value !== null) { + } elseif ($value !== null) { $output->writeln($value); return 0; } else { |