diff options
Diffstat (limited to 'apps/dav/lib/Command/RemoveInvalidShares.php')
-rw-r--r-- | apps/dav/lib/Command/RemoveInvalidShares.php | 49 |
1 files changed, 13 insertions, 36 deletions
diff --git a/apps/dav/lib/Command/RemoveInvalidShares.php b/apps/dav/lib/Command/RemoveInvalidShares.php index 4f9e4836a72..340e878a912 100644 --- a/apps/dav/lib/Command/RemoveInvalidShares.php +++ b/apps/dav/lib/Command/RemoveInvalidShares.php @@ -2,27 +2,11 @@ declare(strict_types=1); + /** - * @copyright Copyright (c) 2018, ownCloud GmbH - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2018 ownCloud GmbH + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OCA\DAV\Command; @@ -37,21 +21,14 @@ use Symfony\Component\Console\Output\OutputInterface; * have no matching principal. Happened because of a bug in the calendar app. */ class RemoveInvalidShares extends Command { - - /** @var IDBConnection */ - private $connection; - /** @var Principal */ - private $principalBackend; - - public function __construct(IDBConnection $connection, - Principal $principalBackend) { + public function __construct( + private IDBConnection $connection, + private Principal $principalBackend, + ) { parent::__construct(); - - $this->connection = $connection; - $this->principalBackend = $principalBackend; } - protected function configure() { + protected function configure(): void { $this ->setName('dav:remove-invalid-shares') ->setDescription('Remove invalid dav shares'); @@ -61,7 +38,7 @@ class RemoveInvalidShares extends Command { $query = $this->connection->getQueryBuilder(); $result = $query->selectDistinct('principaluri') ->from('dav_shares') - ->execute(); + ->executeQuery(); while ($row = $result->fetch()) { $principaluri = $row['principaluri']; @@ -72,16 +49,16 @@ class RemoveInvalidShares extends Command { } $result->closeCursor(); - return 0; + return self::SUCCESS; } /** * @param string $principaluri */ - private function deleteSharesForPrincipal($principaluri) { + private function deleteSharesForPrincipal($principaluri): void { $delete = $this->connection->getQueryBuilder(); $delete->delete('dav_shares') ->where($delete->expr()->eq('principaluri', $delete->createNamedParameter($principaluri))); - $delete->execute(); + $delete->executeStatement(); } } |