aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Command/CleanupRemoteStorages.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/lib/Command/CleanupRemoteStorages.php')
-rw-r--r--apps/files_sharing/lib/Command/CleanupRemoteStorages.php63
1 files changed, 20 insertions, 43 deletions
diff --git a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php
index 3816a2a5124..809481e5c0f 100644
--- a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php
+++ b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php
@@ -1,27 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud GmbH.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Daniel Calviño Sánchez <danxuliu@gmail.com>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @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: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud GmbH.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_Sharing\Command;
@@ -39,19 +21,10 @@ use Symfony\Component\Console\Output\OutputInterface;
*/
class CleanupRemoteStorages extends Command {
- /**
- * @var IDBConnection
- */
- protected $connection;
-
- /**
- * @var ICloudIdManager
- */
- private $cloudIdManager;
-
- public function __construct(IDBConnection $connection, ICloudIdManager $cloudIdManager) {
- $this->connection = $connection;
- $this->cloudIdManager = $cloudIdManager;
+ public function __construct(
+ protected IDBConnection $connection,
+ private ICloudIdManager $cloudIdManager,
+ ) {
parent::__construct();
}
@@ -113,8 +86,9 @@ class CleanupRemoteStorages extends Command {
$queryBuilder->createNamedParameter($numericId, IQueryBuilder::PARAM_STR),
IQueryBuilder::PARAM_STR)
);
- $result = $queryBuilder->execute();
+ $result = $queryBuilder->executeQuery();
$count = $result->fetchOne();
+ $result->closeCursor();
$output->writeln("$count files can be deleted for storage $numericId");
}
@@ -127,7 +101,7 @@ class CleanupRemoteStorages extends Command {
IQueryBuilder::PARAM_STR)
);
$output->write("deleting $id [$numericId] ... ");
- $count = $queryBuilder->execute();
+ $count = $queryBuilder->executeStatement();
$output->writeln("deleted $count storage");
$this->deleteFiles($numericId, $output);
}
@@ -141,7 +115,7 @@ class CleanupRemoteStorages extends Command {
IQueryBuilder::PARAM_STR)
);
$output->write("deleting files for storage $numericId ... ");
- $count = $queryBuilder->execute();
+ $count = $queryBuilder->executeStatement();
$output->writeln("deleted $count files");
}
@@ -160,14 +134,16 @@ class CleanupRemoteStorages extends Command {
// but not the ones starting with a '/', they are for normal shares
$queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::/') . '%'),
IQueryBuilder::PARAM_STR)
- )->orderBy('numeric_id');
- $query = $queryBuilder->execute();
+ )
+ ->orderBy('numeric_id');
+ $result = $queryBuilder->executeQuery();
$remoteStorages = [];
- while ($row = $query->fetch()) {
+ while ($row = $result->fetch()) {
$remoteStorages[$row['id']] = $row['numeric_id'];
}
+ $result->closeCursor();
return $remoteStorages;
}
@@ -176,16 +152,17 @@ class CleanupRemoteStorages extends Command {
$queryBuilder = $this->connection->getQueryBuilder();
$queryBuilder->select(['id', 'share_token', 'owner', 'remote'])
->from('share_external');
- $query = $queryBuilder->execute();
+ $result = $queryBuilder->executeQuery();
$remoteShareIds = [];
- while ($row = $query->fetch()) {
+ while ($row = $result->fetch()) {
$cloudId = $this->cloudIdManager->getCloudId($row['owner'], $row['remote']);
$remote = $cloudId->getRemote();
$remoteShareIds[$row['id']] = 'shared::' . md5($row['share_token'] . '@' . $remote);
}
+ $result->closeCursor();
return $remoteShareIds;
}