aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Repair/RemoveLinkShares.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Repair/RemoveLinkShares.php')
-rw-r--r--lib/private/Repair/RemoveLinkShares.php71
1 files changed, 18 insertions, 53 deletions
diff --git a/lib/private/Repair/RemoveLinkShares.php b/lib/private/Repair/RemoveLinkShares.php
index 1b0270e928d..a07ebdb72c3 100644
--- a/lib/private/Repair/RemoveLinkShares.php
+++ b/lib/private/Repair/RemoveLinkShares.php
@@ -3,29 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Daniel Kesselberg <mail@danielkesselberg.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Repair;
@@ -40,38 +19,24 @@ use OCP\Migration\IRepairStep;
use OCP\Notification\IManager;
class RemoveLinkShares implements IRepairStep {
- /** @var IDBConnection */
- private $connection;
- /** @var IConfig */
- private $config;
/** @var string[] */
private $userToNotify = [];
- /** @var IGroupManager */
- private $groupManager;
- /** @var IManager */
- private $notificationManager;
- /** @var ITimeFactory */
- private $timeFactory;
-
- public function __construct(IDBConnection $connection,
- IConfig $config,
- IGroupManager $groupManager,
- IManager $notificationManager,
- ITimeFactory $timeFactory) {
- $this->connection = $connection;
- $this->config = $config;
- $this->groupManager = $groupManager;
- $this->notificationManager = $notificationManager;
- $this->timeFactory = $timeFactory;
- }
+ public function __construct(
+ private IDBConnection $connection,
+ private IConfig $config,
+ private IGroupManager $groupManager,
+ private IManager $notificationManager,
+ private ITimeFactory $timeFactory,
+ ) {
+ }
public function getName(): string {
return 'Remove potentially over exposing share links';
}
private function shouldRun(): bool {
- $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
+ $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0');
if (version_compare($versionFromBeforeUpdate, '14.0.11', '<')) {
return true;
@@ -95,7 +60,7 @@ class RemoveLinkShares implements IRepairStep {
$qb = $this->connection->getQueryBuilder();
$qb->delete('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
- $qb->execute();
+ $qb->executeStatement();
}
/**
@@ -126,13 +91,13 @@ class RemoveLinkShares implements IRepairStep {
$query = $this->connection->getQueryBuilder();
$query->select($query->func()->count('*', 'total'))
->from('share')
- ->where($query->expr()->in('id', $query->createFunction('(' . $subQuery->getSQL() . ')')));
+ ->where($query->expr()->in('id', $query->createFunction($subQuery->getSQL())));
- $result = $query->execute();
+ $result = $query->executeQuery();
$data = $result->fetch();
$result->closeCursor();
- return (int) $data['total'];
+ return (int)$data['total'];
}
/**
@@ -158,7 +123,7 @@ class RemoveLinkShares implements IRepairStep {
))
->andWhere($query->expr()->eq('s1.item_source', 's2.item_source'));
/** @var IResult $result */
- $result = $query->execute();
+ $result = $query->executeQuery();
return $result;
}
@@ -201,7 +166,7 @@ class RemoveLinkShares implements IRepairStep {
$users = array_keys($this->userToNotify);
foreach ($users as $user) {
- $notification->setUser((string) $user);
+ $notification->setUser((string)$user);
$this->notificationManager->notify($notification);
}
}
@@ -217,7 +182,7 @@ class RemoveLinkShares implements IRepairStep {
$output->finishProgress();
$shareResult->closeCursor();
- // Notifiy all admins
+ // Notify all admins
$adminGroup = $this->groupManager->get('admin');
$adminUsers = $adminGroup->getUsers();
foreach ($adminUsers as $user) {