Browse Source

chore(db): Apply query prepared statements

Fix: psalm

fix: bad file

fix: bug

chore: add batch

chore: add batch

chore: add batch

fix: psalm
pull/48765/head
Git'Fellow 1 year ago
parent
commit
a1681b0756
  1. 28
      apps/dav/lib/CalDAV/Reminder/Backend.php
  2. 4
      apps/dav/lib/Command/RemoveInvalidShares.php
  3. 2
      apps/dav/lib/Db/DirectMapper.php
  4. 23
      apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php
  5. 16
      apps/dav/lib/Migration/FixBirthdayCalendarComponent.php
  6. 13
      apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php
  7. 16
      apps/dav/lib/Migration/RemoveClassifiedEventActivity.php
  8. 12
      apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php
  9. 8
      apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
  10. 16
      apps/files_sharing/lib/Migration/SetAcceptedStatus.php
  11. 10
      apps/files_sharing/lib/ShareBackend/File.php
  12. 26
      apps/files_trashbin/lib/Command/CleanUp.php
  13. 16
      apps/oauth2/lib/Migration/SetTokenExpiration.php
  14. 14
      apps/user_ldap/lib/Migration/RemoveRefreshTime.php
  15. 4
      apps/user_status/lib/Db/UserStatusMapper.php
  16. 14
      build/psalm-baseline.xml
  17. 4
      core/Command/Db/ConvertType.php
  18. 2
      core/Db/LoginFlowV2Mapper.php
  19. 4
      lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php
  20. 6
      lib/private/Collaboration/Resources/Collection.php
  21. 41
      lib/private/DirectEditing/Manager.php
  22. 42
      lib/private/Files/Cache/Cache.php
  23. 4
      lib/private/Files/Cache/QuerySearchHelper.php
  24. 8
      lib/private/Files/Cache/Storage.php
  25. 36
      lib/private/Files/Config/UserMountCache.php
  26. 18
      lib/private/Repair/CleanTags.php
  27. 20
      lib/private/Repair/RepairDavShares.php
  28. 6
      lib/private/Security/CredentialsManager.php
  29. 4
      lib/private/Setup/PostgreSQL.php
  30. 61
      lib/private/Share20/DefaultShareProvider.php
  31. 6
      lib/private/SystemTag/SystemTagObjectMapper.php
  32. 16
      lib/private/User/Database.php

28
apps/dav/lib/CalDAV/Reminder/Backend.php

@ -18,22 +18,16 @@ use OCP\IDBConnection;
*/
class Backend {
/** @var IDBConnection */
protected $db;
/** @var ITimeFactory */
private $timeFactory;
/**
* Backend constructor.
*
* @param IDBConnection $db
* @param ITimeFactory $timeFactory
*/
public function __construct(IDBConnection $db,
ITimeFactory $timeFactory) {
$this->db = $db;
$this->timeFactory = $timeFactory;
public function __construct(
protected IDBConnection $db,
protected ITimeFactory $timeFactory,
) {
}
/**
@ -50,7 +44,7 @@ class Backend {
->join('cr', 'calendarobjects', 'co', $query->expr()->eq('cr.object_id', 'co.id'))
->join('cr', 'calendars', 'c', $query->expr()->eq('cr.calendar_id', 'c.id'))
->groupBy('cr.event_hash', 'cr.notification_date', 'cr.type', 'cr.id', 'cr.calendar_id', 'cr.object_id', 'cr.is_recurring', 'cr.uid', 'cr.recurrence_id', 'cr.is_recurrence_exception', 'cr.alarm_hash', 'cr.is_relative', 'cr.is_repeat_based', 'co.calendardata', 'c.displayname', 'c.principaluri');
$stmt = $query->execute();
$stmt = $query->executeQuery();
return array_map(
[$this, 'fixRowTyping'],
@ -69,7 +63,7 @@ class Backend {
$query->select('*')
->from('calendar_reminders')
->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)));
$stmt = $query->execute();
$stmt = $query->executeQuery();
return array_map(
[$this, 'fixRowTyping'],
@ -122,7 +116,7 @@ class Backend {
'notification_date' => $query->createNamedParameter($notificationDate),
'is_repeat_based' => $query->createNamedParameter($isRepeatBased ? 1 : 0),
])
->execute();
->executeStatement();
return $query->getLastInsertId();
}
@ -139,7 +133,7 @@ class Backend {
$query->update('calendar_reminders')
->set('notification_date', $query->createNamedParameter($newNotificationDate))
->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
->execute();
->executeStatement();
}
/**
@ -153,7 +147,7 @@ class Backend {
$query->delete('calendar_reminders')
->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
->execute();
->executeStatement();
}
/**
@ -166,7 +160,7 @@ class Backend {
$query->delete('calendar_reminders')
->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)))
->execute();
->executeStatement();
}
/**
@ -180,7 +174,7 @@ class Backend {
$query->delete('calendar_reminders')
->where($query->expr()->eq('calendar_id', $query->createNamedParameter($calendarId)))
->execute();
->executeStatement();
}
/**

4
apps/dav/lib/Command/RemoveInvalidShares.php

@ -38,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'];
@ -59,6 +59,6 @@ class RemoveInvalidShares extends Command {
$delete = $this->connection->getQueryBuilder();
$delete->delete('dav_shares')
->where($delete->expr()->eq('principaluri', $delete->createNamedParameter($principaluri)));
$delete->execute();
$delete->executeStatement();
}
}

2
apps/dav/lib/Db/DirectMapper.php

@ -45,6 +45,6 @@ class DirectMapper extends QBMapper {
$qb->expr()->lt('expiration', $qb->createNamedParameter($expiration))
);
$qb->execute();
$qb->executeStatement();
}
}

23
apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php

@ -15,18 +15,11 @@ use Sabre\VObject\InvalidDataException;
class CalDAVRemoveEmptyValue implements IRepairStep {
/** @var IDBConnection */
private $db;
/** @var CalDavBackend */
private $calDavBackend;
private LoggerInterface $logger;
public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, LoggerInterface $logger) {
$this->db = $db;
$this->calDavBackend = $calDavBackend;
$this->logger = $logger;
public function __construct(
private IDBConnection $db,
private CalDavBackend $calDavBackend,
private LoggerInterface $logger,
) {
}
public function getName() {
@ -80,7 +73,7 @@ class CalDAVRemoveEmptyValue implements IRepairStep {
$query = $this->db->getQueryBuilder();
$query->select($query->func()->count('*', 'num_entries'))
->from('calendarobjects');
$result = $query->execute();
$result = $query->executeQuery();
$count = $result->fetchOne();
$result->closeCursor();
@ -92,7 +85,7 @@ class CalDAVRemoveEmptyValue implements IRepairStep {
->setMaxResults($chunkSize);
for ($chunk = 0; $chunk < $numChunks; $chunk++) {
$query->setFirstResult($chunk * $chunkSize);
$result = $query->execute();
$result = $query->executeQuery();
while ($row = $result->fetch()) {
if (mb_strpos($row['calendardata'], $pattern) !== false) {
@ -117,7 +110,7 @@ class CalDAVRemoveEmptyValue implements IRepairStep {
IQueryBuilder::PARAM_STR
));
$result = $query->execute();
$result = $query->executeQuery();
$rows = $result->fetchAll();
$result->closeCursor();

16
apps/dav/lib/Migration/FixBirthdayCalendarComponent.php

@ -1,4 +1,5 @@
<?php
/**
* SPDX-FileCopyrightText: 2016 ownCloud GmbH.
* SPDX-License-Identifier: AGPL-3.0-only
@ -12,16 +13,9 @@ use OCP\Migration\IRepairStep;
class FixBirthdayCalendarComponent implements IRepairStep {
/** @var IDBConnection */
private $connection;
/**
* FixBirthdayCalendarComponent constructor.
*
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
public function __construct(
private IDBConnection $connection,
) {
}
/**
@ -39,7 +33,7 @@ class FixBirthdayCalendarComponent implements IRepairStep {
$updated = $query->update('calendars')
->set('components', $query->createNamedParameter('VEVENT'))
->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
->execute();
->executeStatement();
$output->info("$updated birthday calendars updated.");
}

13
apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php

@ -16,21 +16,16 @@ use OCP\Migration\IRepairStep;
class RefreshWebcalJobRegistrar implements IRepairStep {
/** @var IDBConnection */
private $connection;
/** @var IJobList */
private $jobList;
/**
* FixBirthdayCalendarComponent constructor.
*
* @param IDBConnection $connection
* @param IJobList $jobList
*/
public function __construct(IDBConnection $connection, IJobList $jobList) {
$this->connection = $connection;
$this->jobList = $jobList;
public function __construct(
private IDBConnection $connection,
private IJobList $jobList,
) {
}
/**

16
apps/dav/lib/Migration/RemoveClassifiedEventActivity.php

@ -15,11 +15,9 @@ use OCP\Migration\IRepairStep;
class RemoveClassifiedEventActivity implements IRepairStep {
/** @var IDBConnection */
private $connection;
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
public function __construct(
private IDBConnection $connection,
) {
}
/**
@ -58,7 +56,7 @@ class RemoveClassifiedEventActivity implements IRepairStep {
->from('calendarobjects', 'o')
->leftJoin('o', 'calendars', 'c', $query->expr()->eq('c.id', 'o.calendarid'))
->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_PRIVATE)));
$result = $query->execute();
$result = $query->executeQuery();
while ($row = $result->fetch()) {
if ($row['principaluri'] === null) {
@ -69,7 +67,7 @@ class RemoveClassifiedEventActivity implements IRepairStep {
->setParameter('type', 'calendar')
->setParameter('calendar_id', $row['calendarid'])
->setParameter('event_uid', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '"') . '%');
$deletedEvents += $delete->execute();
$deletedEvents += $delete->executeStatement();
}
$result->closeCursor();
@ -92,7 +90,7 @@ class RemoveClassifiedEventActivity implements IRepairStep {
->from('calendarobjects', 'o')
->leftJoin('o', 'calendars', 'c', $query->expr()->eq('c.id', 'o.calendarid'))
->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_CONFIDENTIAL)));
$result = $query->execute();
$result = $query->executeQuery();
while ($row = $result->fetch()) {
if ($row['principaluri'] === null) {
@ -104,7 +102,7 @@ class RemoveClassifiedEventActivity implements IRepairStep {
->setParameter('calendar_id', $row['calendarid'])
->setParameter('event_uid', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '"') . '%')
->setParameter('filtered_name', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '","name":"Busy"') . '%');
$deletedEvents += $delete->execute();
$deletedEvents += $delete->executeStatement();
}
$result->closeCursor();

12
apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php

@ -16,11 +16,9 @@ use OCP\Migration\IRepairStep;
class RemoveOrphanEventsAndContacts implements IRepairStep {
/** @var IDBConnection */
private $connection;
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
public function __construct(
private IDBConnection $connection,
) {
}
/**
@ -67,7 +65,7 @@ class RemoveOrphanEventsAndContacts implements IRepairStep {
$qb->andWhere($qb->expr()->eq('c.calendartype', $qb->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
}
$result = $qb->execute();
$result = $qb->executeQuery();
$orphanItems = [];
while ($row = $result->fetch()) {
@ -82,7 +80,7 @@ class RemoveOrphanEventsAndContacts implements IRepairStep {
$orphanItemsBatch = array_chunk($orphanItems, 200);
foreach ($orphanItemsBatch as $items) {
$qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
$qb->execute();
$qb->executeStatement();
}
}

8
apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php

@ -450,7 +450,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
)
);
$result = $qb->execute();
$result = $qb->executeQuery();
$share = $result->fetch();
$result->closeCursor();
@ -470,13 +470,13 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
)
);
$qb->execute();
$qb->executeStatement();
// delete all child in case of a group share
$qb = $this->connection->getQueryBuilder();
$qb->delete('share_external')
->where($qb->expr()->eq('parent', $qb->createNamedParameter((int)$share['id'])));
$qb->execute();
$qb->executeStatement();
$ownerDisplayName = $this->getUserDisplayName($owner->getId());
@ -624,7 +624,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
$query->update('share')
->where($query->expr()->eq('id', $query->createNamedParameter($share->getId())))
->set('permissions', $query->createNamedParameter($permissions))
->execute();
->executeStatement();
}

16
apps/files_sharing/lib/Migration/SetAcceptedStatus.php

@ -17,16 +17,10 @@ use OCP\Share\IShare;
class SetAcceptedStatus implements IRepairStep {
/** @var IDBConnection */
private $connection;
/** @var IConfig */
private $config;
public function __construct(IDBConnection $connection, IConfig $config) {
$this->connection = $connection;
$this->config = $config;
public function __construct(
private IDBConnection $connection,
private IConfig $config,
) {
}
/**
@ -52,7 +46,7 @@ class SetAcceptedStatus implements IRepairStep {
->update('share')
->set('accepted', $query->createNamedParameter(IShare::STATUS_ACCEPTED))
->where($query->expr()->in('share_type', $query->createNamedParameter([IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_USERGROUP], IQueryBuilder::PARAM_INT_ARRAY)));
$query->execute();
$query->executeStatement();
}
protected function shouldRun() {

10
apps/files_sharing/lib/ShareBackend/File.php

@ -1,4 +1,5 @@
<?php
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@ -27,10 +28,9 @@ class File implements Share_Backend_File_Dependent {
private $path;
/** @var FederatedShareProvider */
private $federatedShareProvider;
public function __construct(?FederatedShareProvider $federatedShareProvider = null) {
public function __construct(
private ?FederatedShareProvider $federatedShareProvider = null,
) {
if ($federatedShareProvider) {
$this->federatedShareProvider = $federatedShareProvider;
} else {
@ -189,7 +189,7 @@ class File implements Share_Backend_File_Dependent {
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($parent))
);
$result = $qb->execute();
$result = $qb->executeQuery();
$item = $result->fetch();
$result->closeCursor();
if (isset($item['parent'])) {

26
apps/files_trashbin/lib/Command/CleanUp.php

@ -1,4 +1,5 @@
<?php
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@ -19,25 +20,12 @@ use Symfony\Component\Console\Output\OutputInterface;
class CleanUp extends Command {
/** @var IUserManager */
protected $userManager;
/** @var IRootFolder */
protected $rootFolder;
/** @var \OCP\IDBConnection */
protected $dbConnection;
/**
* @param IRootFolder $rootFolder
* @param IUserManager $userManager
* @param IDBConnection $dbConnection
*/
public function __construct(IRootFolder $rootFolder, IUserManager $userManager, IDBConnection $dbConnection) {
public function __construct(
protected IRootFolder $rootFolder,
protected IUserManager $userManager,
protected IDBConnection $dbConnection,
) {
parent::__construct();
$this->userManager = $userManager;
$this->rootFolder = $rootFolder;
$this->dbConnection = $dbConnection;
}
protected function configure() {
@ -119,7 +107,7 @@ class CleanUp extends Command {
$query->delete('files_trash')
->where($query->expr()->eq('user', $query->createParameter('uid')))
->setParameter('uid', $uid);
$query->execute();
$query->executeStatement();
} else {
if ($verbose) {
$output->writeln("No trash found for <info>$uid</info>");

16
apps/oauth2/lib/Migration/SetTokenExpiration.php

@ -18,21 +18,15 @@ use OCP\Migration\IRepairStep;
class SetTokenExpiration implements IRepairStep {
/** @var IDBConnection */
private $connection;
/** @var ITimeFactory */
private $time;
/** @var TokenProvider */
private $tokenProvider;
public function __construct(IDBConnection $connection,
public function __construct(
private IDBConnection $connection,
ITimeFactory $timeFactory,
TokenProvider $tokenProvider) {
$this->connection = $connection;
private TokenProvider $tokenProvider,
) {
$this->time = $timeFactory;
$this->tokenProvider = $tokenProvider;
}
public function getName(): string {
@ -44,7 +38,7 @@ class SetTokenExpiration implements IRepairStep {
$qb->select('*')
->from('oauth2_access_tokens');
$cursor = $qb->execute();
$cursor = $qb->executeQuery();
while ($row = $cursor->fetch()) {
$token = AccessToken::fromRow($row);

14
apps/user_ldap/lib/Migration/RemoveRefreshTime.php

@ -22,14 +22,10 @@ use OCP\Migration\IRepairStep;
*/
class RemoveRefreshTime implements IRepairStep {
/** @var IDBConnection */
private $dbc;
/** @var IConfig */
private $config;
public function __construct(IDBConnection $dbc, IConfig $config) {
$this->dbc = $dbc;
$this->config = $config;
public function __construct(
private IDBConnection $dbc,
private IConfig $config,
) {
}
public function getName() {
@ -43,6 +39,6 @@ class RemoveRefreshTime implements IRepairStep {
$qb->delete('preferences')
->where($qb->expr()->eq('appid', $qb->createNamedParameter('user_ldap')))
->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter('lastFeatureRefresh')))
->execute();
->executeStatement();
}
}

4
apps/user_status/lib/Db/UserStatusMapper.php

@ -126,7 +126,7 @@ class UserStatusMapper extends QBMapper {
$qb->expr()->eq('status', $qb->createNamedParameter(IUserStatus::ONLINE))
));
$qb->execute();
$qb->executeStatement();
}
/**
@ -140,7 +140,7 @@ class UserStatusMapper extends QBMapper {
->where($qb->expr()->isNotNull('clear_at'))
->andWhere($qb->expr()->lte('clear_at', $qb->createNamedParameter($timestamp, IQueryBuilder::PARAM_INT)));
$qb->execute();
$qb->executeStatement();
}

14
build/psalm-baseline.xml

@ -1792,12 +1792,8 @@
</InvalidReturnType>
</file>
<file src="lib/private/DirectEditing/Manager.php">
<InvalidReturnStatement>
<code><![CDATA[$query->execute()]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code><![CDATA[TemplateResponse]]></code>
<code><![CDATA[int]]></code>
</InvalidReturnType>
<UndefinedMethod>
<code><![CDATA[$template]]></code>
@ -2466,16 +2462,6 @@
<code><![CDATA[\strlen($this->value)]]></code>
</InvalidArgument>
</file>
<file src="lib/private/Security/CredentialsManager.php">
<InvalidReturnStatement>
<code><![CDATA[$qb->execute()]]></code>
<code><![CDATA[$qb->execute()]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code><![CDATA[int]]></code>
<code><![CDATA[int]]></code>
</InvalidReturnType>
</file>
<file src="lib/private/Security/Crypto.php">
<InternalMethod>
<code><![CDATA[decrypt]]></code>

4
core/Command/Db/ConvertType.php

@ -298,7 +298,7 @@ class ConvertType extends Command implements CompletionAwareInterface {
$query->automaticTablePrefix(false);
$query->select($query->func()->count('*', 'num_entries'))
->from($table->getName());
$result = $query->execute();
$result = $query->executeQuery();
$count = $result->fetchOne();
$result->closeCursor();
@ -337,7 +337,7 @@ class ConvertType extends Command implements CompletionAwareInterface {
for ($chunk = 0; $chunk < $numChunks; $chunk++) {
$query->setFirstResult($chunk * $chunkSize);
$result = $query->execute();
$result = $query->executeQuery();
try {
$toDB->beginTransaction();

2
core/Db/LoginFlowV2Mapper.php

@ -71,7 +71,7 @@ class LoginFlowV2Mapper extends QBMapper {
$qb->expr()->lt('timestamp', $qb->createNamedParameter($this->timeFactory->getTime() - self::lifetime))
);
$qb->execute();
$qb->executeStatement();
}
/**

4
lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php

@ -37,7 +37,7 @@ class ProviderUserAssignmentDao {
$query = $qb->select('provider_id', 'enabled')
->from(self::TABLE_NAME)
->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid)));
$result = $query->execute();
$result = $query->executeQuery();
$providers = [];
foreach ($result->fetchAll() as $row) {
$providers[(string)$row['provider_id']] = (int)$row['enabled'] === 1;
@ -106,6 +106,6 @@ class ProviderUserAssignmentDao {
$deleteQuery = $qb->delete(self::TABLE_NAME)
->where($qb->expr()->eq('provider_id', $qb->createNamedParameter($providerId)));
$deleteQuery->execute();
$deleteQuery->executeStatement();
}
}

6
lib/private/Collaboration/Resources/Collection.php

@ -54,7 +54,7 @@ class Collection implements ICollection {
$query->update(Manager::TABLE_COLLECTIONS)
->set('name', $query->createNamedParameter($name))
->where($query->expr()->eq('id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)));
$query->execute();
$query->executeStatement();
$this->name = $name;
}
@ -118,7 +118,7 @@ class Collection implements ICollection {
->where($query->expr()->eq('collection_id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType())))
->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId())));
$query->execute();
$query->executeStatement();
if (empty($this->resources)) {
$this->removeCollection();
@ -172,7 +172,7 @@ class Collection implements ICollection {
$query = $this->connection->getQueryBuilder();
$query->delete(Manager::TABLE_COLLECTIONS)
->where($query->expr()->eq('id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT)));
$query->execute();
$query->executeStatement();
$this->manager->invalidateAccessCacheForCollection($this);
$this->id = 0;

41
lib/private/DirectEditing/Manager.php

@ -38,36 +38,21 @@ class Manager implements IManager {
/** @var IEditor[] */
private $editors = [];
/** @var IDBConnection */
private $connection;
/** @var IUserSession */
private $userSession;
/** @var ISecureRandom */
private $random;
/** @var string|null */
private $userId;
/** @var IRootFolder */
private $rootFolder;
/** @var IL10N */
private $l10n;
/** @var EncryptionManager */
private $encryptionManager;
public function __construct(
ISecureRandom $random,
IDBConnection $connection,
IUserSession $userSession,
IRootFolder $rootFolder,
IFactory $l10nFactory,
EncryptionManager $encryptionManager,
private ISecureRandom $random,
private IDBConnection $connection,
private IUserSession $userSession,
private IRootFolder $rootFolder,
private IFactory $l10nFactory,
private EncryptionManager $encryptionManager,
) {
$this->random = $random;
$this->connection = $connection;
$this->userSession = $userSession;
$this->userId = $userSession->getUser() ? $userSession->getUser()->getUID() : null;
$this->rootFolder = $rootFolder;
$this->l10n = $l10nFactory->get('lib');
$this->encryptionManager = $encryptionManager;
}
public function registerDirectEditor(IEditor $directEditor): void {
@ -209,7 +194,7 @@ class Manager implements IManager {
$query = $this->connection->getQueryBuilder();
$query->select('*')->from(self::TABLE_TOKENS)
->where($query->expr()->eq('token', $query->createNamedParameter($token, IQueryBuilder::PARAM_STR)));
$result = $query->execute();
$result = $query->executeQuery();
if ($tokenRow = $result->fetch(FetchMode::ASSOCIATIVE)) {
return new Token($this, $tokenRow);
}
@ -220,7 +205,7 @@ class Manager implements IManager {
$query = $this->connection->getQueryBuilder();
$query->delete(self::TABLE_TOKENS)
->where($query->expr()->lt('timestamp', $query->createNamedParameter(time() - self::TOKEN_CLEANUP_TIME)));
return $query->execute();
return $query->executeStatement();
}
public function refreshToken(string $token): bool {
@ -228,7 +213,7 @@ class Manager implements IManager {
$query->update(self::TABLE_TOKENS)
->set('timestamp', $query->createNamedParameter(time(), IQueryBuilder::PARAM_INT))
->where($query->expr()->eq('token', $query->createNamedParameter($token, IQueryBuilder::PARAM_STR)));
$result = $query->execute();
$result = $query->executeStatement();
return $result !== 0;
}
@ -237,7 +222,7 @@ class Manager implements IManager {
$query = $this->connection->getQueryBuilder();
$query->delete(self::TABLE_TOKENS)
->where($query->expr()->eq('token', $query->createNamedParameter($token, IQueryBuilder::PARAM_STR)));
$result = $query->execute();
$result = $query->executeStatement();
return $result !== 0;
}
@ -247,7 +232,7 @@ class Manager implements IManager {
->set('accessed', $query->createNamedParameter(true, IQueryBuilder::PARAM_BOOL))
->set('timestamp', $query->createNamedParameter(time(), IQueryBuilder::PARAM_INT))
->where($query->expr()->eq('token', $query->createNamedParameter($token, IQueryBuilder::PARAM_STR)));
$result = $query->execute();
$result = $query->executeStatement();
return $result !== 0;
}
@ -272,7 +257,7 @@ class Manager implements IManager {
'share_id' => $query->createNamedParameter($share !== null ? $share->getId(): null),
'timestamp' => $query->createNamedParameter(time())
]);
$query->execute();
$query->executeStatement();
return $token;
}
@ -303,7 +288,7 @@ class Manager implements IManager {
$moduleId = $this->encryptionManager->getDefaultEncryptionModuleId();
$module = $this->encryptionManager->getEncryptionModule($moduleId);
/** @var \OCA\Encryption\Util $util */
$util = \OC::$server->get(\OCA\Encryption\Util::class);
$util = \OCP\Server::get(\OCA\Encryption\Util::class);
if ($module->isReadyForUser($this->userId) && $util->isMasterKeyEnabled()) {
return true;
}

42
lib/private/Files/Cache/Cache.php

@ -74,7 +74,7 @@ class Cache implements ICache {
$this->storageId = md5($this->storageId);
}
if (!$dependencies) {
$dependencies = \OC::$server->get(CacheDependencies::class);
$dependencies = \OCP\Server::get(CacheDependencies::class);
}
$this->storageCache = new Storage($this->storage, true, $dependencies->getConnection());
$this->mimetypeLoader = $dependencies->getMimeTypeLoader();
@ -127,7 +127,7 @@ class Cache implements ICache {
}
$query->whereStorageId($this->getNumericStorageId());
$result = $query->execute();
$result = $query->executeQuery();
$data = $result->fetch();
$result->closeCursor();
@ -205,7 +205,7 @@ class Cache implements ICache {
$metadataQuery = $query->selectMetadata();
$result = $query->execute();
$result = $query->executeQuery();
$files = $result->fetchAll();
$result->closeCursor();
@ -294,7 +294,7 @@ class Cache implements ICache {
foreach ($extensionValues as $column => $value) {
$query->setValue($column, $query->createNamedParameter($value));
}
$query->execute();
$query->executeStatement();
}
$event = new CacheEntryInsertedEvent($this->storage, $file, $fileId, $storageId);
@ -355,7 +355,7 @@ class Cache implements ICache {
$query->set($key, $query->createNamedParameter($value));
}
$query->execute();
$query->executeStatement();
}
if (count($extensionValues)) {
@ -386,7 +386,7 @@ class Cache implements ICache {
$query->set($key, $query->createNamedParameter($value));
}
$query->execute();
$query->executeStatement();
}
}
@ -468,7 +468,7 @@ class Cache implements ICache {
->whereStorageId($this->getNumericStorageId())
->wherePath($file);
$result = $query->execute();
$result = $query->executeQuery();
$id = $result->fetchOne();
$result->closeCursor();
@ -523,13 +523,13 @@ class Cache implements ICache {
$query->delete('filecache')
->whereStorageId($this->getNumericStorageId())
->whereFileId($entry->getId());
$query->execute();
$query->executeStatement();
$query = $this->getQueryBuilder();
$query->delete('filecache_extended')
->whereFileId($entry->getId())
->hintShardKey('storage', $this->getNumericStorageId());
$query->execute();
$query->executeStatement();
if ($entry->getMimeType() == FileInfo::MIMETYPE_FOLDER) {
$this->removeChildren($entry);
@ -577,7 +577,7 @@ class Cache implements ICache {
foreach (array_chunk($childIds, 1000) as $childIdChunk) {
$query->setParameter('childIds', $childIdChunk, IQueryBuilder::PARAM_INT_ARRAY);
$query->execute();
$query->executeStatement();
}
/** @var ICacheEntry[] $childFolders */
@ -603,7 +603,7 @@ class Cache implements ICache {
sort($parentIds, SORT_NUMERIC);
foreach (array_chunk($parentIds, 1000) as $parentIdChunk) {
$query->setParameter('parentIds', $parentIdChunk, IQueryBuilder::PARAM_INT_ARRAY);
$query->execute();
$query->executeStatement();
}
foreach (array_combine($deletedIds, $deletedPaths) as $fileId => $filePath) {
@ -765,7 +765,7 @@ class Cache implements ICache {
$query->set('encrypted', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT));
}
$query->execute();
$query->executeStatement();
$this->connection->commit();
@ -800,12 +800,12 @@ class Cache implements ICache {
$query = $this->getQueryBuilder();
$query->delete('filecache')
->whereStorageId($this->getNumericStorageId());
$query->execute();
$query->executeStatement();
$query = $this->connection->getQueryBuilder();
$query->delete('storages')
->where($query->expr()->eq('id', $query->createNamedParameter($this->storageId)));
$query->execute();
$query->executeStatement();
}
/**
@ -830,7 +830,7 @@ class Cache implements ICache {
->whereStorageId($this->getNumericStorageId())
->wherePath($file);
$result = $query->execute();
$result = $query->executeQuery();
$size = $result->fetchOne();
$result->closeCursor();
@ -919,7 +919,7 @@ class Cache implements ICache {
->whereStorageId($this->getNumericStorageId())
->andWhere($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)));
$result = $query->execute();
$result = $query->executeQuery();
$size = (int)$result->fetchOne();
$result->closeCursor();
@ -965,7 +965,7 @@ class Cache implements ICache {
$query->andWhere($query->expr()->gte('size', $query->createNamedParameter(0)));
}
$result = $query->execute();
$result = $query->executeQuery();
$rows = $result->fetchAll();
$result->closeCursor();
@ -1039,7 +1039,7 @@ class Cache implements ICache {
->from('filecache')
->whereStorageId($this->getNumericStorageId());
$result = $query->execute();
$result = $query->executeQuery();
$files = $result->fetchAll(\PDO::FETCH_COLUMN);
$result->closeCursor();
@ -1070,7 +1070,7 @@ class Cache implements ICache {
->orderBy('fileid', 'DESC')
->setMaxResults(1);
$result = $query->execute();
$result = $query->executeQuery();
$id = $result->fetchOne();
$result->closeCursor();
@ -1095,7 +1095,7 @@ class Cache implements ICache {
->whereStorageId($this->getNumericStorageId())
->whereFileId($id);
$result = $query->execute();
$result = $query->executeQuery();
$path = $result->fetchOne();
$result->closeCursor();
@ -1121,7 +1121,7 @@ class Cache implements ICache {
->from('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
$result = $query->execute();
$result = $query->executeQuery();
$row = $result->fetch();
$result->closeCursor();

4
lib/private/Files/Cache/QuerySearchHelper.php

@ -88,7 +88,7 @@ class QuerySearchHelper {
$this->applySearchConstraints($query, $searchQuery, $caches);
$result = $query->execute();
$result = $query->executeQuery();
$tags = $result->fetchAll();
$result->closeCursor();
return $tags;
@ -167,7 +167,7 @@ class QuerySearchHelper {
$this->applySearchConstraints($query, $searchQuery, $caches, $metadataQuery);
$result = $query->execute();
$result = $query->executeQuery();
$files = $result->fetchAll();
$rawEntries = array_map(function (array $data) use ($metadataQuery) {

8
lib/private/Files/Cache/Storage.php

@ -149,7 +149,7 @@ class Storage {
public function setAvailability($isAvailable, int $delay = 0) {
$available = $isAvailable ? 1 : 0;
if (!$isAvailable) {
\OC::$server->get(LoggerInterface::class)->info('Storage with ' . $this->storageId . ' marked as unavailable', ['app' => 'lib']);
\OCP\Server::get(LoggerInterface::class)->info('Storage with ' . $this->storageId . ' marked as unavailable', ['app' => 'lib']);
}
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
@ -157,7 +157,7 @@ class Storage {
->set('available', $query->createNamedParameter($available))
->set('last_checked', $query->createNamedParameter(time() + $delay))
->where($query->expr()->eq('id', $query->createNamedParameter($this->storageId)));
$query->execute();
$query->executeStatement();
}
/**
@ -182,13 +182,13 @@ class Storage {
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$query->delete('storages')
->where($query->expr()->eq('id', $query->createNamedParameter($storageId)));
$query->execute();
$query->executeStatement();
if (!is_null($numericId)) {
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('storage', $query->createNamedParameter($numericId)));
$query->execute();
$query->executeStatement();
}
}

36
lib/private/Files/Config/UserMountCache.php

@ -24,8 +24,6 @@ use Psr\Log\LoggerInterface;
* Cache mounts points per user in the cache so we can easily look them up
*/
class UserMountCache implements IUserMountCache {
private IDBConnection $connection;
private IUserManager $userManager;
/**
* Cached mount info.
@ -37,24 +35,18 @@ class UserMountCache implements IUserMountCache {
* @var CappedMemoryCache<string>
**/
private CappedMemoryCache $internalPathCache;
private LoggerInterface $logger;
/** @var CappedMemoryCache<array> */
private CappedMemoryCache $cacheInfoCache;
private IEventLogger $eventLogger;
/**
* UserMountCache constructor.
*/
public function __construct(
IDBConnection $connection,
IUserManager $userManager,
LoggerInterface $logger,
IEventLogger $eventLogger,
private IDBConnection $connection,
private IUserManager $userManager,
private LoggerInterface $logger,
private IEventLogger $eventLogger,
) {
$this->connection = $connection;
$this->userManager = $userManager;
$this->logger = $logger;
$this->eventLogger = $eventLogger;
$this->cacheInfoCache = new CappedMemoryCache();
$this->internalPathCache = new CappedMemoryCache();
$this->mountsForUsers = new CappedMemoryCache();
@ -177,7 +169,7 @@ class UserMountCache implements IUserMountCache {
->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID())))
->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT)));
$query->execute();
$query->executeStatement();
}
private function removeFromCache(ICachedMountInfo $mount) {
@ -187,7 +179,7 @@ class UserMountCache implements IUserMountCache {
->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID())))
->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT)))
->andWhere($builder->expr()->eq('mount_point', $builder->createNamedParameter($mount->getMountPoint())));
$query->execute();
$query->executeStatement();
}
/**
@ -239,7 +231,7 @@ class UserMountCache implements IUserMountCache {
->from('mounts', 'm')
->where($builder->expr()->eq('user_id', $builder->createNamedParameter($userUID)));
$result = $query->execute();
$result = $query->executeQuery();
$rows = $result->fetchAll();
$result->closeCursor();
@ -284,7 +276,7 @@ class UserMountCache implements IUserMountCache {
$query->andWhere($builder->expr()->eq('user_id', $builder->createNamedParameter($user)));
}
$result = $query->execute();
$result = $query->executeQuery();
$rows = $result->fetchAll();
$result->closeCursor();
@ -302,7 +294,7 @@ class UserMountCache implements IUserMountCache {
->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
->where($builder->expr()->eq('root_id', $builder->createNamedParameter($rootFileId, IQueryBuilder::PARAM_INT)));
$result = $query->execute();
$result = $query->executeQuery();
$rows = $result->fetchAll();
$result->closeCursor();
@ -321,7 +313,7 @@ class UserMountCache implements IUserMountCache {
->from('filecache')
->where($builder->expr()->eq('fileid', $builder->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)));
$result = $query->execute();
$result = $query->executeQuery();
$row = $result->fetch();
$result->closeCursor();
@ -390,7 +382,7 @@ class UserMountCache implements IUserMountCache {
$query = $builder->delete('mounts')
->where($builder->expr()->eq('user_id', $builder->createNamedParameter($user->getUID())));
$query->execute();
$query->executeStatement();
}
public function removeUserStorageMount($storageId, $userId) {
@ -399,7 +391,7 @@ class UserMountCache implements IUserMountCache {
$query = $builder->delete('mounts')
->where($builder->expr()->eq('user_id', $builder->createNamedParameter($userId)))
->andWhere($builder->expr()->eq('storage_id', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)));
$query->execute();
$query->executeStatement();
}
public function remoteStorageMounts($storageId) {
@ -407,7 +399,7 @@ class UserMountCache implements IUserMountCache {
$query = $builder->delete('mounts')
->where($builder->expr()->eq('storage_id', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)));
$query->execute();
$query->executeStatement();
}
/**
@ -438,7 +430,7 @@ class UserMountCache implements IUserMountCache {
->where($builder->expr()->eq('m.mount_point', $mountPoint))
->andWhere($builder->expr()->in('m.user_id', $builder->createNamedParameter($userIds, IQueryBuilder::PARAM_STR_ARRAY)));
$result = $query->execute();
$result = $query->executeQuery();
$results = [];
while ($row = $result->fetch()) {

18
lib/private/Repair/CleanTags.php

@ -19,11 +19,6 @@ use OCP\Migration\IRepairStep;
* @package OC\Repair
*/
class CleanTags implements IRepairStep {
/** @var IDBConnection */
protected $connection;
/** @var IUserManager */
protected $userManager;
protected $deletedTags = 0;
@ -31,9 +26,10 @@ class CleanTags implements IRepairStep {
* @param IDBConnection $connection
* @param IUserManager $userManager
*/
public function __construct(IDBConnection $connection, IUserManager $userManager) {
$this->connection = $connection;
$this->userManager = $userManager;
public function __construct(
protected IDBConnection $connection,
protected IUserManager $userManager,
) {
}
/**
@ -73,7 +69,7 @@ class CleanTags implements IRepairStep {
->orderBy('uid')
->setMaxResults(50)
->setFirstResult($offset);
$result = $query->execute();
$result = $query->executeQuery();
$users = [];
$hadResults = false;
@ -94,7 +90,7 @@ class CleanTags implements IRepairStep {
$query = $this->connection->getQueryBuilder();
$query->delete('vcategory')
->where($query->expr()->in('uid', $query->createNamedParameter($users, IQueryBuilder::PARAM_STR_ARRAY)));
$this->deletedTags += $query->execute();
$this->deletedTags += $query->executeStatement();
}
return true;
}
@ -162,7 +158,7 @@ class CleanTags implements IRepairStep {
->andWhere(
$qb->expr()->isNull('s.' . $sourceNullColumn)
);
$result = $qb->execute();
$result = $qb->executeQuery();
$orphanItems = [];
while ($row = $result->fetch()) {

20
lib/private/Repair/RepairDavShares.php

@ -23,27 +23,15 @@ use function urlencode;
class RepairDavShares implements IRepairStep {
protected const GROUP_PRINCIPAL_PREFIX = 'principals/groups/';
/** @var IConfig */
private $config;
/** @var IDBConnection */
private $dbc;
/** @var IGroupManager */
private $groupManager;
/** @var LoggerInterface */
private $logger;
/** @var bool */
private $hintInvalidShares = false;
public function __construct(
IConfig $config,
IDBConnection $dbc,
IGroupManager $groupManager,
LoggerInterface $logger,
private IConfig $config,
private IDBConnection $dbc,
private IGroupManager $groupManager,
private LoggerInterface $logger,
) {
$this->config = $config;
$this->dbc = $dbc;
$this->groupManager = $groupManager;
$this->logger = $logger;
}
/**

6
lib/private/Security/CredentialsManager.php

@ -60,7 +60,7 @@ class CredentialsManager implements ICredentialsManager {
$qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter($userId)));
}
$qResult = $qb->execute();
$qResult = $qb->executeQuery();
$result = $qResult->fetch();
$qResult->closeCursor();
@ -89,7 +89,7 @@ class CredentialsManager implements ICredentialsManager {
$qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter($userId)));
}
return $qb->execute();
return $qb->executeStatement();
}
/**
@ -102,6 +102,6 @@ class CredentialsManager implements ICredentialsManager {
$qb->delete(self::DB_TABLE)
->where($qb->expr()->eq('user', $qb->createNamedParameter($userId)))
;
return $qb->execute();
return $qb->executeStatement();
}
}

4
lib/private/Setup/PostgreSQL.php

@ -131,7 +131,7 @@ class PostgreSQL extends AbstractDatabase {
$query = $builder->select('*')
->from('pg_roles')
->where($builder->expr()->eq('rolname', $builder->createNamedParameter($this->dbUser)));
$result = $query->execute();
$result = $query->executeQuery();
return $result->rowCount() > 0;
}
@ -141,7 +141,7 @@ class PostgreSQL extends AbstractDatabase {
$query = $builder->select('datname')
->from('pg_database')
->where($builder->expr()->eq('datname', $builder->createNamedParameter($this->dbName)));
$result = $query->execute();
$result = $query->executeQuery();
return $result->rowCount() > 0;
}

61
lib/private/Share20/DefaultShareProvider.php

@ -226,7 +226,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
->set('note', $qb->createNamedParameter($share->getNote()))
->set('accepted', $qb->createNamedParameter($share->getStatus()))
->set('reminder_sent', $qb->createNamedParameter($share->getReminderSent(), IQueryBuilder::PARAM_BOOL))
->execute();
->executeStatement();
} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$qb = $this->dbConn->getQueryBuilder();
$qb->update('share')
@ -239,7 +239,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
->set('file_source', $qb->createNamedParameter($share->getNode()->getId()))
->set('expiration', $qb->createNamedParameter($expirationDate, IQueryBuilder::PARAM_DATE))
->set('note', $qb->createNamedParameter($share->getNote()))
->execute();
->executeStatement();
/*
* Update all user defined group shares
@ -254,7 +254,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
->set('file_source', $qb->createNamedParameter($share->getNode()->getId()))
->set('expiration', $qb->createNamedParameter($expirationDate, IQueryBuilder::PARAM_DATE))
->set('note', $qb->createNamedParameter($share->getNote()))
->execute();
->executeStatement();
/*
* Now update the permissions for all children that have not set it to 0
@ -265,7 +265,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
->andWhere($qb->expr()->neq('permissions', $qb->createNamedParameter(0)))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
->set('attributes', $qb->createNamedParameter($shareAttributes))
->execute();
->executeStatement();
} elseif ($share->getShareType() === IShare::TYPE_LINK) {
$qb = $this->dbConn->getQueryBuilder();
$qb->update('share')
@ -283,7 +283,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
->set('note', $qb->createNamedParameter($share->getNote()))
->set('label', $qb->createNamedParameter($share->getLabel()))
->set('hide_download', $qb->createNamedParameter($share->getHideDownload() ? 1 : 0), IQueryBuilder::PARAM_INT)
->execute();
->executeStatement();
}
if ($originalShare->getNote() !== $share->getNote() && $share->getNote() !== '') {
@ -326,7 +326,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->expr()->eq('item_type', $qb->createNamedParameter('file')),
$qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
))
->execute();
->executeQuery();
$data = $stmt->fetch();
$stmt->closeCursor();
@ -354,7 +354,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->update('share')
->set('accepted', $qb->createNamedParameter(IShare::STATUS_ACCEPTED))
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
->execute();
->executeStatement();
return $share;
}
@ -389,7 +389,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
))
->orderBy('id');
$cursor = $qb->execute();
$cursor = $qb->executeQuery();
while ($data = $cursor->fetch()) {
$children[] = $this->createShare($data);
}
@ -416,7 +416,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->orWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())));
}
$qb->execute();
$qb->executeStatement();
}
/**
@ -453,7 +453,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->expr()->eq('item_type', $qb->createNamedParameter('file')),
$qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
))
->execute();
->executeQuery();
$data = $stmt->fetch();
@ -475,7 +475,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->update('share')
->set('permissions', $qb->createNamedParameter(0))
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
->execute();
->executeStatement();
}
} elseif ($share->getShareType() === IShare::TYPE_USER) {
if ($share->getSharedWith() !== $recipient) {
@ -506,7 +506,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
'file_target' => $qb->createNamedParameter($share->getTarget()),
'permissions' => $qb->createNamedParameter($share->getPermissions()),
'stime' => $qb->createNamedParameter($share->getShareTime()->getTimestamp()),
])->execute();
])->executeStatement();
return $qb->getLastInsertId();
}
@ -524,7 +524,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))
);
$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$data = $cursor->fetch();
$cursor->closeCursor();
@ -541,7 +541,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))
);
$qb->execute();
$qb->executeStatement();
return $this->getShareById($share->getId(), $recipient);
}
@ -556,7 +556,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->update('share')
->set('file_target', $qb->createNamedParameter($share->getTarget()))
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
->execute();
->executeStatement();
} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
// Check if there is a usergroup share
$qb = $this->dbConn->getQueryBuilder();
@ -570,7 +570,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
))
->setMaxResults(1)
->execute();
->executeQuery();
$data = $stmt->fetch();
$stmt->closeCursor();
@ -596,14 +596,14 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
'permissions' => $qb->createNamedParameter($share->getPermissions()),
'attributes' => $qb->createNamedParameter($shareAttributes),
'stime' => $qb->createNamedParameter($share->getShareTime()->getTimestamp()),
])->execute();
])->executeStatement();
} else {
// Already a usergroup share. Update it.
$qb = $this->dbConn->getQueryBuilder();
$qb->update('share')
->set('file_target', $qb->createNamedParameter($share->getTarget()))
->where($qb->expr()->eq('id', $qb->createNamedParameter($data['id'])))
->execute();
->executeStatement();
}
}
@ -727,7 +727,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->setFirstResult($offset);
$qb->orderBy('id');
$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$shares = [];
while ($data = $cursor->fetch()) {
$shares[] = $this->createShare($data);
@ -761,7 +761,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
));
$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$data = $cursor->fetch();
$cursor->closeCursor();
@ -805,7 +805,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->expr()->eq('item_type', $qb->createNamedParameter('file')),
$qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
))
->execute();
->executeQuery();
$shares = [];
while ($data = $cursor->fetch()) {
@ -882,7 +882,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
}
$cursor = $qb->execute();
$cursor = $qb->executeQuery();
while ($data = $cursor->fetch()) {
if ($data['fileid'] && $data['path'] === null) {
@ -933,7 +933,6 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
}
$groups = array_filter($groups);
$qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)))
@ -946,7 +945,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
));
$cursor = $qb->execute();
$cursor = $qb->executeQuery();
while ($data = $cursor->fetch()) {
if ($offset > 0) {
$offset--;
@ -1099,7 +1098,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$query->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())));
}
$stmt = $query->execute();
$stmt = $query->executeQuery();
while ($data = $stmt->fetch()) {
if (array_key_exists($data['parent'], $shareMap)) {
@ -1179,7 +1178,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
return;
}
$qb->execute();
$qb->executeStatement();
}
/**
@ -1198,7 +1197,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid)));
$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$ids = [];
while ($row = $cursor->fetch()) {
$ids[] = (int)$row['id'];
@ -1215,7 +1214,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
foreach ($chunks as $chunk) {
$qb->setParameter('parents', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
$qb->execute();
$qb->executeStatement();
}
}
@ -1226,7 +1225,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->delete('share')
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid)));
$qb->execute();
$qb->executeStatement();
}
/**
@ -1342,7 +1341,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$qb->expr()->eq('item_type', $qb->createNamedParameter('file')),
$qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
));
$cursor = $qb->execute();
$cursor = $qb->executeQuery();
$users = [];
$link = false;
@ -1659,7 +1658,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
)
);
$cursor = $qb->execute();
$cursor = $qb->executeQuery();
while ($data = $cursor->fetch()) {
try {
$share = $this->createShare($data);

6
lib/private/SystemTag/SystemTagObjectMapper.php

@ -97,7 +97,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
$objectIds = [];
$result = $query->execute();
$result = $query->executeQuery();
while ($row = $result->fetch()) {
$objectIds[] = $row['objectid'];
}
@ -187,7 +187,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
->setParameter('objectid', $objId)
->setParameter('objecttype', $objectType)
->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY)
->execute();
->executeStatement();
$this->dispatcher->dispatch(MapperEvent::EVENT_UNASSIGN, new MapperEvent(
MapperEvent::EVENT_UNASSIGN,
@ -226,7 +226,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
->setParameter('tagid', $tagId)
->setParameter('objecttype', $objectType);
$result = $query->execute();
$result = $query->executeQuery();
$row = $result->fetch(\PDO::FETCH_NUM);
$result->closeCursor();

16
lib/private/User/Database.php

@ -97,7 +97,7 @@ class Database extends ABackend implements
$qb->insert($this->table)
->values([
'uid' => $qb->createNamedParameter($uid),
'password' => $qb->createNamedParameter(\OC::$server->get(IHasher::class)->hash($password)),
'password' => $qb->createNamedParameter(\OCP\Server::get(IHasher::class)->hash($password)),
'uid_lower' => $qb->createNamedParameter(mb_strtolower($uid)),
]);
@ -130,7 +130,7 @@ class Database extends ABackend implements
$query = $this->dbConn->getQueryBuilder();
$query->delete($this->table)
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
$result = $query->execute();
$result = $query->executeStatement();
if (isset($this->cache[$uid])) {
unset($this->cache[$uid]);
@ -144,7 +144,7 @@ class Database extends ABackend implements
$query->update($this->table)
->set('password', $query->createNamedParameter($passwordHash))
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
$result = $query->execute();
$result = $query->executeStatement();
return $result ? true : false;
}
@ -164,7 +164,7 @@ class Database extends ABackend implements
if ($this->userExists($uid)) {
$this->eventDispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password));
$hasher = \OC::$server->get(IHasher::class);
$hasher = \OCP\Server::get(IHasher::class);
$hashedPassword = $hasher->hash($password);
$return = $this->updatePassword($uid, $hashedPassword);
@ -236,7 +236,7 @@ class Database extends ABackend implements
$query->update($this->table)
->set('displayname', $query->createNamedParameter($displayName))
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
$query->execute();
$query->executeStatement();
$this->cache[$uid]['displayname'] = $displayName;
@ -329,7 +329,7 @@ class Database extends ABackend implements
->setMaxResults($limit)
->setFirstResult($offset);
$result = $query->execute();
$result = $query->executeQuery();
$displayNames = [];
while ($row = $result->fetch()) {
$displayNames[(string)$row['uid']] = (string)$row['displayname'];
@ -354,7 +354,7 @@ class Database extends ABackend implements
if ($found && is_array($this->cache[$loginName])) {
$storedHash = $this->cache[$loginName]['password'];
$newHash = '';
if (\OC::$server->get(IHasher::class)->verify($password, $storedHash, $newHash)) {
if (\OCP\Server::get(IHasher::class)->verify($password, $storedHash, $newHash)) {
if (!empty($newHash)) {
$this->updatePassword($loginName, $newHash);
}
@ -390,7 +390,7 @@ class Database extends ABackend implements
'uid_lower', $qb->createNamedParameter(mb_strtolower($uid))
)
);
$result = $qb->execute();
$result = $qb->executeQuery();
$row = $result->fetch();
$result->closeCursor();

Loading…
Cancel
Save