diff --git a/apps/contactsinteraction/lib/Db/RecentContactMapper.php b/apps/contactsinteraction/lib/Db/RecentContactMapper.php index 25a96aaa01ebb..12af1cbd9e3d3 100644 --- a/apps/contactsinteraction/lib/Db/RecentContactMapper.php +++ b/apps/contactsinteraction/lib/Db/RecentContactMapper.php @@ -94,7 +94,7 @@ public function findLastUpdatedForUserId(string $uid): ?int { ->setMaxResults(1); $cursor = $select->executeQuery(); - $row = $cursor->fetch(); + $row = $cursor->fetchAssociative(); if ($row === false) { return null; diff --git a/apps/contactsinteraction/lib/Migration/FixVcardCategory.php b/apps/contactsinteraction/lib/Migration/FixVcardCategory.php index b2b7ca9fbf51c..80e37249a4b51 100644 --- a/apps/contactsinteraction/lib/Migration/FixVcardCategory.php +++ b/apps/contactsinteraction/lib/Migration/FixVcardCategory.php @@ -53,7 +53,7 @@ public function run(IOutput $output): void { ->set('card', $query->createParameter('card')) ->where($query->expr()->eq('id', $query->createParameter('id'))); - while ($card = $cardsWithTranslatedCategory->fetch()) { + while ($card = $cardsWithTranslatedCategory->fetchAssociative()) { $output->advance(1); try { diff --git a/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php b/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php index 1165367c33fc3..974c7cd3239bd 100644 --- a/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php +++ b/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php @@ -74,7 +74,7 @@ private function buildIndex(int $offset, int $stopAt):int { ->orderBy('id', 'ASC'); $result = $query->executeQuery(); - while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $result->fetchAssociative()) { $offset = (int)$row['id']; if (is_resource($row['calendardata'])) { $row['calendardata'] = stream_get_contents($row['calendardata']); diff --git a/apps/dav/lib/BackgroundJob/CleanupOrphanedChildrenJob.php b/apps/dav/lib/BackgroundJob/CleanupOrphanedChildrenJob.php index 8a5e34381a7c5..0f574df084ff1 100644 --- a/apps/dav/lib/BackgroundJob/CleanupOrphanedChildrenJob.php +++ b/apps/dav/lib/BackgroundJob/CleanupOrphanedChildrenJob.php @@ -72,7 +72,7 @@ private function cleanUpOrphans( } $result = $selectQb->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $result->closeCursor(); if (empty($rows)) { return 0; diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 2299db2a23959..8d90df16dbded 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -283,7 +283,7 @@ public function getDeletedCalendars(int $deletedBefore): array { ->andWhere($qb->expr()->lt('deleted_at', $qb->createNamedParameter($deletedBefore))); $result = $qb->executeQuery(); $calendars = []; - while (($row = $result->fetch()) !== false) { + while (($row = $result->fetchAssociative()) !== false) { $calendars[] = [ 'id' => (int)$row['id'], 'deleted_at' => (int)$row['deleted_at'], @@ -345,7 +345,7 @@ public function getCalendarsForUser($principalUri) { $result = $query->executeQuery(); $calendars = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $row['principaluri'] = (string)$row['principaluri']; $components = []; if ($row['components']) { @@ -408,7 +408,7 @@ public function getCalendarsForUser($principalUri) { $results = $select->executeQuery(); $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'; - while ($row = $results->fetch()) { + while ($row = $results->fetchAssociative()) { $row['principaluri'] = (string)$row['principaluri']; if ($row['principaluri'] === $principalUri) { continue; @@ -478,7 +478,7 @@ public function getUsersOwnCalendars($principalUri) { ->orderBy('calendarorder', 'ASC'); $stmt = $query->executeQuery(); $calendars = []; - while ($row = $stmt->fetch()) { + while ($row = $stmt->fetchAssociative()) { $row['principaluri'] = (string)$row['principaluri']; $components = []; if ($row['components']) { @@ -528,7 +528,7 @@ public function getPublicCalendars() { ->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar'))) ->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $row['principaluri'] = (string)$row['principaluri']; [, $name] = Uri\split($row['principaluri']); $row['displayname'] = $row['displayname'] . "($name)"; @@ -586,7 +586,7 @@ public function getPublicCalendar($uri) { ->andWhere($query->expr()->eq('s.publicuri', $query->createNamedParameter($uri))) ->executeQuery(); - $row = $result->fetch(); + $row = $result->fetchAssociative(); $result->closeCursor(); @@ -643,7 +643,7 @@ public function getCalendarByUri($principal, $uri) { ->setMaxResults(1); $stmt = $query->executeQuery(); - $row = $stmt->fetch(); + $row = $stmt->fetchAssociative(); $stmt->closeCursor(); if ($row === false) { return null; @@ -692,7 +692,7 @@ public function getCalendarById(int $calendarId): ?array { ->setMaxResults(1); $stmt = $query->executeQuery(); - $row = $stmt->fetch(); + $row = $stmt->fetchAssociative(); $stmt->closeCursor(); if ($row === false) { return null; @@ -740,7 +740,7 @@ public function getSubscriptionById($subscriptionId) { ->orderBy('calendarorder', 'asc'); $stmt = $query->executeQuery(); - $row = $stmt->fetch(); + $row = $stmt->fetchAssociative(); $stmt->closeCursor(); if ($row === false) { return null; @@ -777,7 +777,7 @@ public function getSubscriptionByUri(string $principal, string $uri): ?array { ->setMaxResults(1); $stmt = $query->executeQuery(); - $row = $stmt->fetch(); + $row = $stmt->fetchAssociative(); $stmt->closeCursor(); if ($row === false) { return null; @@ -1044,7 +1044,7 @@ public function exportCalendar(int $calendarId, int $calendarType = self::CALEND $rs = $qb->executeQuery(); // iterate through results try { - while (($row = $rs->fetch()) !== false) { + while (($row = $rs->fetchAssociative()) !== false) { yield $row; } } finally { @@ -1076,7 +1076,7 @@ public function getLimitedCalendarObjects(int $calendarId, int $calendarType = s $stmt = $query->executeQuery(); $result = []; - while (($row = $stmt->fetch()) !== false) { + while (($row = $stmt->fetchAssociative()) !== false) { $result[$row['uid']] = [ 'id' => $row['id'], 'etag' => $row['etag'], @@ -1141,7 +1141,7 @@ public function getCalendarObjects($calendarId, $calendarType = self::CALENDAR_T $stmt = $query->executeQuery(); $result = []; - while (($row = $stmt->fetch()) !== false) { + while (($row = $stmt->fetchAssociative()) !== false) { $result[] = [ 'id' => $row['id'], 'uri' => $row['uri'], @@ -1168,7 +1168,7 @@ public function getDeletedCalendarObjects(int $deletedBefore): array { $stmt = $query->executeQuery(); $result = []; - while (($row = $stmt->fetch()) !== false) { + while (($row = $stmt->fetchAssociative()) !== false) { $result[] = [ 'id' => $row['id'], 'uri' => $row['uri'], @@ -1207,7 +1207,7 @@ public function getDeletedCalendarObjectsByPrincipal(string $principalUri): arra $stmt = $query->executeQuery(); $result = []; - while ($row = $stmt->fetch()) { + while ($row = $stmt->fetchAssociative()) { $result[] = [ 'id' => $row['id'], 'uri' => $row['uri'], @@ -1255,7 +1255,7 @@ public function getCalendarObject($calendarId, $objectUri, int $calendarType = s ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))) ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType))); $stmt = $query->executeQuery(); - $row = $stmt->fetch(); + $row = $stmt->fetchAssociative(); $stmt->closeCursor(); if (!$row) { @@ -1316,7 +1316,7 @@ public function getMultipleCalendarObjects($calendarId, array $uris, $calendarTy $query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY); $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $objects[] = [ 'id' => $row['id'], 'uri' => $row['uri'], @@ -1383,7 +1383,7 @@ public function createCalendarObject($calendarId, $objectUri, $calendarData, $ca ->andWhere($qbDel->expr()->eq('calendartype', $qbDel->createNamedParameter($calendarType))) ->andWhere($qbDel->expr()->isNotNull('deleted_at')); $result = $qbDel->executeQuery(); - $found = $result->fetch(); + $found = $result->fetchAssociative(); $result->closeCursor(); if ($found !== false) { // the object existed previously but has been deleted @@ -1675,7 +1675,7 @@ public function restoreCalendarObject(array $objectData): void { ->from('calendarobjects') ->where($qb2->expr()->eq('id', $qb2->createNamedParameter($id, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)); $result = $selectObject->executeQuery(); - $row = $result->fetch(); + $row = $result->fetchAssociative(); $result->closeCursor(); if ($row === false) { // Welp, this should possibly not have happened, but let's ignore @@ -1798,7 +1798,7 @@ public function calendarQuery($calendarId, array $filters, $calendarType = self: $stmt = $query->executeQuery(); $result = []; - while ($row = $stmt->fetch()) { + while ($row = $stmt->fetchAssociative()) { // if we leave it as a blob we can't read it both from the post filter and the rowToCalendarObject if (isset($row['calendardata'])) { $row['calendardata'] = $this->readBlob($row['calendardata']); @@ -1958,7 +1958,7 @@ public function calendarSearch($principalUri, array $filters, $limit = null, $of $stmt = $query->executeQuery(); $result = []; - while ($row = $stmt->fetch()) { + while ($row = $stmt->fetchAssociative()) { $path = $uriMapper[$row['calendarid']] . '/' . $row['uri']; if (!in_array($path, $result)) { $result[] = $path; @@ -2171,7 +2171,7 @@ private function searchCalendarObjects(IQueryBuilder $query, ?DateTimeInterface $result = $query->executeQuery(); - while (($row = $result->fetch()) !== false) { + while (($row = $result->fetchAssociative()) !== false) { if ($filterByTimeRange === false) { // No filter required $calendarObjects[] = $row; @@ -2399,7 +2399,7 @@ public function searchPrincipalUri(string $principalUri, $result = $calendarObjectIdQuery->executeQuery(); $matches = []; - while (($row = $result->fetch()) !== false) { + while (($row = $result->fetchAssociative()) !== false) { $matches[] = (int)$row['objectid']; } $result->closeCursor(); @@ -2411,7 +2411,7 @@ public function searchPrincipalUri(string $principalUri, $result = $query->executeQuery(); $calendarObjects = []; - while (($array = $result->fetch()) !== false) { + while (($array = $result->fetchAssociative()) !== false) { $array['calendarid'] = (int)$array['calendarid']; $array['calendartype'] = (int)$array['calendartype']; $array['calendardata'] = $this->readBlob($array['calendardata']); @@ -2456,7 +2456,7 @@ public function getCalendarObjectByUID($principalUri, $uid, $calendarUri = null) } $stmt = $query->executeQuery(); - $row = $stmt->fetch(); + $row = $stmt->fetchAssociative(); $stmt->closeCursor(); if ($row) { return $row['calendaruri'] . '/' . $row['objecturi']; @@ -2474,7 +2474,7 @@ public function getCalendarObjectById(string $principalUri, int $id): ?array { ->where($query->expr()->eq('c.principaluri', $query->createNamedParameter($principalUri))) ->andWhere($query->expr()->eq('co.id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)); $stmt = $query->executeQuery(); - $row = $stmt->fetch(); + $row = $stmt->fetchAssociative(); $stmt->closeCursor(); if (!$row) { @@ -2600,11 +2600,11 @@ public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limi $result = ['syncToken' => $currentToken, 'added' => [], 'modified' => [], 'deleted' => []]; // retrieve results if ($initialSync) { - $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN); + $result['added'] = $stmt->fetchFirstColumn(); } else { // \PDO::FETCH_NUM is needed due to the inconsistent field names // produced by doctrine for MAX() with different databases - while ($entry = $stmt->fetch(\PDO::FETCH_NUM)) { + while ($entry = $stmt->fetchNumeric()) { // assign uri (column 0) to appropriate mutation based on operation (column 1) // forced (int) is needed as doctrine with OCI returns the operation field as string not integer match ((int)$entry[1]) { @@ -2670,7 +2670,7 @@ public function getSubscriptionsForUser($principalUri) { $stmt = $query->executeQuery(); $subscriptions = []; - while ($row = $stmt->fetch()) { + while ($row = $stmt->fetchAssociative()) { $subscription = [ 'id' => $row['id'], 'uri' => $row['uri'], @@ -2855,7 +2855,7 @@ public function getSchedulingObject($principalUri, $objectUri) { ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))) ->executeQuery(); - $row = $stmt->fetch(); + $row = $stmt->fetchAssociative(); if (!$row) { return null; @@ -2889,7 +2889,7 @@ public function getSchedulingObjects($principalUri) { ->executeQuery(); $results = []; - while (($row = $stmt->fetch()) !== false) { + while (($row = $stmt->fetchAssociative()) !== false) { $results[] = [ 'calendardata' => $row['calendardata'], 'uri' => $row['uri'], @@ -2939,7 +2939,7 @@ public function deleteOutdatedSchedulingObjects(int $modifiedBefore, int $limit) } $ids = array_map(static function (array $id) { return (int)$id[0]; - }, $result->fetchAll(\PDO::FETCH_NUM)); + }, $result->fetchAllNumeric()); $result->closeCursor(); $numDeleted = 0; @@ -3040,7 +3040,7 @@ public function restoreChanges(int $calendarId, int $calendarType = self::CALEND ) ); $resultAdded = $qbAdded->executeQuery(); - $addedUris = $resultAdded->fetchAll(\PDO::FETCH_COLUMN); + $addedUris = $resultAdded->fetchFirstColumn(); $resultAdded->closeCursor(); // Track everything as changed // Tracking the creation is not necessary because \OCA\DAV\CalDAV\CalDavBackend::getChangesForCalendar @@ -3060,7 +3060,7 @@ public function restoreChanges(int $calendarId, int $calendarType = self::CALEND $resultDeleted = $qbDeleted->executeQuery(); $deletedUris = array_map(function (string $uri) { return str_replace('-deleted.ics', '.ics', $uri); - }, $resultDeleted->fetchAll(\PDO::FETCH_COLUMN)); + }, $resultDeleted->fetchFirstColumn()); $resultDeleted->closeCursor(); $this->addChanges($calendarId, $deletedUris, 3, $calendarType); }, $this->db); @@ -3306,7 +3306,7 @@ public function preloadPublishStatuses(array $resourceIds): void { ->executeQuery(); $hasPublishStatuses = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $this->publishStatusCache->set((string)$row['resourceid'], $row['publicuri']); $hasPublishStatuses[(int)$row['resourceid']] = true; } @@ -3419,7 +3419,7 @@ public function deleteAllBirthdayCalendars() { ->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))) ->executeQuery(); - while (($row = $result->fetch()) !== false) { + while (($row = $result->fetchAssociative()) !== false) { $this->deleteCalendar( $row['id'], true // No data to keep in the trashbin, if the user re-enables then we regenerate @@ -3442,7 +3442,7 @@ public function purgeAllCachedEventsForSubscription($subscriptionId) { $stmt = $query->executeQuery(); $uris = []; - while (($row = $stmt->fetch()) !== false) { + while (($row = $stmt->fetchAssociative()) !== false) { $uris[] = $row['uri']; } $stmt->closeCursor(); @@ -3568,7 +3568,7 @@ protected function getCalendarObjectId($calendarId, $uri, $calendarType):int { ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType))); $result = $query->executeQuery(); - $objectIds = $result->fetch(); + $objectIds = $result->fetchAssociative(); $result->closeCursor(); if (!isset($objectIds['id'])) { @@ -3713,7 +3713,7 @@ protected function purgeCalendarInvitations(int $calendarId): void { $cmd->select('uid') ->from($this->dbObjectsTable) ->where($cmd->expr()->eq('calendarid', $cmd->createNamedParameter($calendarId))); - $allIds = $cmd->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); + $allIds = $cmd->executeQuery()->fetchFirstColumn(); // delete all links that match object uid's $cmd = $this->db->getQueryBuilder(); $cmd->delete($this->dbObjectInvitationsTable) diff --git a/apps/dav/lib/CalDAV/Federation/FederatedCalendarMapper.php b/apps/dav/lib/CalDAV/Federation/FederatedCalendarMapper.php index 00fa8e659debf..4a8103a08656f 100644 --- a/apps/dav/lib/CalDAV/Federation/FederatedCalendarMapper.php +++ b/apps/dav/lib/CalDAV/Federation/FederatedCalendarMapper.php @@ -148,7 +148,7 @@ public function findAll(): \Generator { ->from(self::TABLE_NAME); $result = $qb->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { yield $this->mapRowToEntity($row); } $result->closeCursor(); diff --git a/apps/dav/lib/CalDAV/Reminder/Backend.php b/apps/dav/lib/CalDAV/Reminder/Backend.php index 329af3a2f56aa..eca7081928ea4 100644 --- a/apps/dav/lib/CalDAV/Reminder/Backend.php +++ b/apps/dav/lib/CalDAV/Reminder/Backend.php @@ -48,7 +48,7 @@ public function getRemindersToProcess():array { return array_map( [$this, 'fixRowTyping'], - $stmt->fetchAll() + $stmt->fetchAllAssociative() ); } @@ -67,7 +67,7 @@ public function getAllScheduledRemindersForEvent(int $objectId):array { return array_map( [$this, 'fixRowTyping'], - $stmt->fetchAll() + $stmt->fetchAllAssociative() ); } diff --git a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php index 0ddd83b6e0d62..fa3ee937f22bd 100644 --- a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php +++ b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php @@ -78,7 +78,7 @@ public function getPrincipalsByPrefix($prefixPath): array { $metaDataQuery->select([$this->dbForeignKeyName, 'key', 'value']) ->from($this->dbMetaDataTableName); $metaDataStmt = $metaDataQuery->executeQuery(); - $metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC); + $metaDataRows = $metaDataStmt->fetchAllAssociative(); $metaDataById = []; foreach ($metaDataRows as $metaDataRow) { @@ -90,7 +90,7 @@ public function getPrincipalsByPrefix($prefixPath): array { = $metaDataRow['value']; } - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetchAssociative()) { $id = $row['id']; if (isset($metaDataById[$id])) { @@ -129,7 +129,7 @@ public function getPrincipalByPath($path) { ->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId))) ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resourceId))); $stmt = $query->executeQuery(); - $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $row = $stmt->fetchAssociative(); if (!$row) { return null; @@ -140,7 +140,7 @@ public function getPrincipalByPath($path) { ->from($this->dbMetaDataTableName) ->where($metaDataQuery->expr()->eq($this->dbForeignKeyName, $metaDataQuery->createNamedParameter($row['id']))); $metaDataStmt = $metaDataQuery->executeQuery(); - $metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC); + $metaDataRows = $metaDataStmt->fetchAllAssociative(); $metadata = []; foreach ($metaDataRows as $metaDataRow) { @@ -160,7 +160,7 @@ public function getPrincipalById($id): ?array { ->from($this->dbTableName) ->where($query->expr()->eq('id', $query->createNamedParameter($id))); $stmt = $query->executeQuery(); - $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $row = $stmt->fetchAssociative(); if (!$row) { return null; @@ -171,7 +171,7 @@ public function getPrincipalById($id): ?array { ->from($this->dbMetaDataTableName) ->where($metaDataQuery->expr()->eq($this->dbForeignKeyName, $metaDataQuery->createNamedParameter($row['id']))); $metaDataStmt = $metaDataQuery->executeQuery(); - $metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC); + $metaDataRows = $metaDataStmt->fetchAllAssociative(); $metadata = []; foreach ($metaDataRows as $metaDataRow) { @@ -221,7 +221,7 @@ public function searchPrincipals($prefixPath, array $searchProperties, $test = ' $stmt = $query->executeQuery(); $principals = []; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetchAssociative()) { if (!$this->isAllowedToAccessResource($row, $usersGroups)) { continue; } @@ -240,7 +240,7 @@ public function searchPrincipals($prefixPath, array $searchProperties, $test = ' $stmt = $query->executeQuery(); $principals = []; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetchAssociative()) { if (!$this->isAllowedToAccessResource($row, $usersGroups)) { continue; } @@ -366,7 +366,7 @@ private function getRows(IQueryBuilder $query, array $usersGroups): array { } $rows = []; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetchAssociative()) { $principalRow = $this->getPrincipalById($row[$this->dbForeignKeyName]); if (!$principalRow) { continue; @@ -407,7 +407,7 @@ public function findByUri($uri, $principalPrefix): ?string { ->where($query->expr()->eq('email', $query->createNamedParameter($email))); $stmt = $query->executeQuery(); - $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $row = $stmt->fetchAssociative(); if (!$row) { return null; @@ -434,7 +434,7 @@ public function findByUri($uri, $principalPrefix): ?string { ->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId))) ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resourceId))); $stmt = $query->executeQuery(); - $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $row = $stmt->fetchAssociative(); if (!$row) { return null; diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 4829bdf4e764f..0ca82200735d9 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -26,7 +26,6 @@ use OCP\IConfig; use OCP\IDBConnection; use OCP\IUserManager; -use PDO; use Sabre\CardDAV\Backend\BackendInterface; use Sabre\CardDAV\Backend\SyncSupport; use Sabre\CardDAV\Plugin; @@ -112,7 +111,7 @@ public function getAddressBooksForUser($principalUri) { $addressBooks = []; $result = $select->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $addressBooks[$row['id']] = [ 'id' => $row['id'], 'uri' => $row['uri'], @@ -150,7 +149,7 @@ public function getAddressBooksForUser($principalUri) { $result = $select->executeQuery(); $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { if ($row['principaluri'] === $principalUri) { continue; } @@ -202,7 +201,7 @@ public function getUsersOwnAddressBooks($principalUri) { $addressBooks = []; $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $addressBooks[$row['id']] = [ 'id' => $row['id'], 'uri' => $row['uri'], @@ -229,7 +228,7 @@ public function getAddressBookById(int $addressBookId): ?array { ->from('addressbooks') ->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId, IQueryBuilder::PARAM_INT))) ->executeQuery(); - $row = $result->fetch(); + $row = $result->fetchAssociative(); $result->closeCursor(); if (!$row) { return null; @@ -259,7 +258,7 @@ public function getAddressBooksByUri(string $principal, string $addressBookUri): ->setMaxResults(1) ->executeQuery(); - $row = $result->fetch(); + $row = $result->fetchAssociative(); $result->closeCursor(); if ($row === false) { return null; @@ -482,7 +481,7 @@ public function getCards($addressbookId) { $cards = []; $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $row['etag'] = '"' . $row['etag'] . '"'; $modified = false; @@ -519,7 +518,7 @@ public function getCard($addressBookId, $cardUri) { ->setMaxResults(1); $result = $query->executeQuery(); - $row = $result->fetch(); + $row = $result->fetchAssociative(); if (!$row) { return false; } @@ -564,7 +563,7 @@ public function getMultipleCards($addressBookId, array $uris) { $query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY); $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $row['etag'] = '"' . $row['etag'] . '"'; $modified = false; @@ -891,7 +890,7 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, )->orderBy('id') ->setMaxResults($limit); $stmt = $qb->executeQuery(); - $values = $stmt->fetchAll(\PDO::FETCH_ASSOC); + $values = $stmt->fetchAllAssociative(); $stmt->closeCursor(); if (count($values) === 0) { $result['syncToken'] = $initialSyncToken; @@ -928,7 +927,7 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, // This loop ensures that any duplicates are overwritten, only the // last change on a node is relevant. - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetchAssociative()) { $changes[$row['uri']] = $row['operation']; $highestSyncToken = $row['synctoken']; } @@ -977,7 +976,7 @@ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, // No synctoken supplied, this is the initial sync. $qb->setMaxResults($limit); $stmt = $qb->executeQuery(); - $values = $stmt->fetchAll(\PDO::FETCH_ASSOC); + $values = $stmt->fetchAllAssociative(); if (empty($values)) { $result['added'] = []; return $result; @@ -1239,7 +1238,7 @@ private function searchByAddressBookIds(array $addressBookIds, } $result = $query2->executeQuery(); - $matches = $result->fetchAll(); + $matches = $result->fetchAllAssociative(); $result->closeCursor(); $matches = array_map(function ($match) { return (int)$match['cardid']; @@ -1254,7 +1253,7 @@ private function searchByAddressBookIds(array $addressBookIds, foreach (array_chunk($matches, 1000) as $matchesChunk) { $query->setParameter('matches', $matchesChunk, IQueryBuilder::PARAM_INT_ARRAY); $result = $query->executeQuery(); - $cardResults[] = $result->fetchAll(); + $cardResults[] = $result->fetchAllAssociative(); $result->closeCursor(); } @@ -1283,7 +1282,7 @@ public function collectCardProperties($bookId, $name) { ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($bookId))) ->executeQuery(); - $all = $result->fetchAll(PDO::FETCH_COLUMN); + $all = $result->fetchFirstColumn(); $result->closeCursor(); return $all; @@ -1302,7 +1301,7 @@ public function getCardUri($id) { ->setParameter('id', $id); $result = $query->executeQuery(); - $uri = $result->fetch(); + $uri = $result->fetchAssociative(); $result->closeCursor(); if (!isset($uri['uri'])) { @@ -1326,7 +1325,7 @@ public function getContact($addressBookId, $uri) { ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); $queryResult = $query->executeQuery(); - $contact = $queryResult->fetch(); + $contact = $queryResult->fetchAssociative(); $queryResult->closeCursor(); if (is_array($contact)) { @@ -1437,7 +1436,7 @@ protected function getCardId(int $addressBookId, string $uri): int { ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); $result = $query->executeQuery(); - $cardIds = $result->fetch(); + $cardIds = $result->fetchAssociative(); $result->closeCursor(); if (!isset($cardIds['id'])) { diff --git a/apps/dav/lib/Command/RemoveInvalidShares.php b/apps/dav/lib/Command/RemoveInvalidShares.php index 6337a938fa943..3128bca03e25c 100644 --- a/apps/dav/lib/Command/RemoveInvalidShares.php +++ b/apps/dav/lib/Command/RemoveInvalidShares.php @@ -42,7 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int ->from('dav_shares') ->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $principaluri = $row['principaluri']; $p = $this->principalBackend->getPrincipalByPath($principaluri) ?? $this->remoteUserPrincipalBackend->getPrincipalByPath($principaluri); diff --git a/apps/dav/lib/Controller/InvitationResponseController.php b/apps/dav/lib/Controller/InvitationResponseController.php index 19eb4097b450c..425f491adef1c 100644 --- a/apps/dav/lib/Controller/InvitationResponseController.php +++ b/apps/dav/lib/Controller/InvitationResponseController.php @@ -140,7 +140,7 @@ private function getTokenInformation(string $token) { ->from('calendar_invitations') ->where($query->expr()->eq('token', $query->createNamedParameter($token))); $stmt = $query->executeQuery(); - $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $row = $stmt->fetchAssociative(); $stmt->closeCursor(); if (!$row) { diff --git a/apps/dav/lib/DAV/CustomPropertiesBackend.php b/apps/dav/lib/DAV/CustomPropertiesBackend.php index a0e99233e1164..8e7d489dad0cc 100644 --- a/apps/dav/lib/DAV/CustomPropertiesBackend.php +++ b/apps/dav/lib/DAV/CustomPropertiesBackend.php @@ -345,7 +345,7 @@ private function getPublishedProperties(string $path, array $requestedProperties ->where($qb->expr()->eq('propertypath', $qb->createNamedParameter($path))); $result = $qb->executeQuery(); $props = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $props[$row['propertyname']] = $this->decodeValueFromDatabase($row['propertyvalue'], $row['valuetype']); } $result->closeCursor(); @@ -376,7 +376,7 @@ private function cacheDirectory(string $path, Directory $node): void { $propsByPath = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $childPath = $prefix . $row['name']; if (!isset($propsByPath[$childPath])) { $propsByPath[$childPath] = []; @@ -474,13 +474,13 @@ private function getUserProperties(string $path, array $requestedProperties): ar foreach ($chunks as $chunk) { $qb->setParameter('requestedProperties', $chunk, IQueryBuilder::PARAM_STR_ARRAY); $result = $qb->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $props[$row['propertyname']] = $this->decodeValueFromDatabase($row['propertyvalue'], $row['valuetype']); } } } else { $result = $qb->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $props[$row['propertyname']] = $this->decodeValueFromDatabase($row['propertyvalue'], $row['valuetype']); } } diff --git a/apps/dav/lib/DAV/Sharing/SharingMapper.php b/apps/dav/lib/DAV/Sharing/SharingMapper.php index d6e52c63866d5..cab45907077d0 100644 --- a/apps/dav/lib/DAV/Sharing/SharingMapper.php +++ b/apps/dav/lib/DAV/Sharing/SharingMapper.php @@ -31,7 +31,7 @@ protected function getSharesForIdByAccess(int $resourceId, string $resourceType, } $result = $query->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $result->closeCursor(); return $rows; } @@ -54,7 +54,7 @@ public function getSharesForIds(array $resourceIds, string $resourceType): array ->groupBy(['principaluri', 'access', 'resourceid']) ->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $result->closeCursor(); return $rows; } @@ -133,7 +133,7 @@ public function getSharesByPrincipals(array $principals, string $resourceType): ->orderBy('id') ->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $result->closeCursor(); return $rows; @@ -149,7 +149,7 @@ public function deleteUnsharesByPrincipal(string $principal, string $resourceTyp } /** - * @return array{principaluri: string}[] + * @return list * @throws \OCP\DB\Exception */ public function getPrincipalUrisByPrefix(string $resourceType, string $prefix): array { @@ -168,14 +168,15 @@ public function getPrincipalUrisByPrefix(string $resourceType, string $prefix): ) ->executeQuery(); - $rows = $result->fetchAll(); + /** @var list $rows */ + $rows = $result->fetchAllAssociative(); $result->closeCursor(); return $rows; } /** - * @psalm-return array{uri: string, principaluri: string}[] + * @psalm-return list * @throws \OCP\DB\Exception */ public function getSharedCalendarsForRemoteUser( @@ -206,7 +207,8 @@ public function getSharedCalendarsForRemoteUser( IQueryBuilder::PARAM_STR, )); $result = $qb->executeQuery(); - $rows = $result->fetchAll(); + /** @var list $rows */ + $rows = $result->fetchAllAssociative(); $result->closeCursor(); return $rows; @@ -241,7 +243,7 @@ public function getSharesByPrincipalsAndResource( IQueryBuilder::PARAM_STR, )); $result = $qb->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $result->closeCursor(); return $rows; diff --git a/apps/dav/lib/Migration/BuildCalendarSearchIndexBackgroundJob.php b/apps/dav/lib/Migration/BuildCalendarSearchIndexBackgroundJob.php index c6a5c6250213e..d9642a09f38fc 100644 --- a/apps/dav/lib/Migration/BuildCalendarSearchIndexBackgroundJob.php +++ b/apps/dav/lib/Migration/BuildCalendarSearchIndexBackgroundJob.php @@ -66,7 +66,7 @@ private function buildIndex(int $offset, int $stopAt): int { ->setMaxResults(500); $result = $query->executeQuery(); - while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $result->fetchAssociative()) { $offset = $row['id']; $calendarData = $row['calendardata']; diff --git a/apps/dav/lib/Migration/BuildSocialSearchIndexBackgroundJob.php b/apps/dav/lib/Migration/BuildSocialSearchIndexBackgroundJob.php index 346c8725b109d..5b44df2b69ebe 100644 --- a/apps/dav/lib/Migration/BuildSocialSearchIndexBackgroundJob.php +++ b/apps/dav/lib/Migration/BuildSocialSearchIndexBackgroundJob.php @@ -62,7 +62,7 @@ private function buildIndex($offset, $stopAt) { ->where($query->expr()->like('carddata', $query->createNamedParameter('%SOCIALPROFILE%'))) ->andWhere($query->expr()->gt('id', $query->createNamedParameter((int)$offset, IQueryBuilder::PARAM_INT))) ->setMaxResults(100); - $social_cards = $query->executeQuery()->fetchAll(); + $social_cards = $query->executeQuery()->fetchAllAssociative(); if (empty($social_cards)) { return $stopAt; diff --git a/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php b/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php index 24e182e46eb1a..42c419a733b4a 100644 --- a/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php +++ b/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php @@ -88,7 +88,7 @@ protected function getInvalidObjects($pattern) { $query->setFirstResult($chunk * $chunkSize); $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { if (mb_strpos($row['calendardata'], $pattern) !== false) { unset($row['calendardata']); $rows[] = $row; @@ -112,7 +112,7 @@ protected function getInvalidObjects($pattern) { )); $result = $query->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $result->closeCursor(); return $rows; diff --git a/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php b/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php index 8f36e1e3762aa..2c98bf5f0cb8b 100644 --- a/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php +++ b/apps/dav/lib/Migration/RefreshWebcalJobRegistrar.php @@ -45,7 +45,7 @@ public function run(IOutput $output): void { $stmt = $query->executeQuery(); $count = 0; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetchAssociative()) { $args = [ 'principaluri' => $row['principaluri'], 'uri' => $row['uri'], diff --git a/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php b/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php index f0d208f4f335e..4aae1515f9e41 100644 --- a/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php +++ b/apps/dav/lib/Migration/RemoveClassifiedEventActivity.php @@ -58,7 +58,7 @@ protected function removePrivateEventActivity(): int { ->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_PRIVATE))); $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { if ($row['principaluri'] === null) { continue; } @@ -92,7 +92,7 @@ protected function removeConfidentialUncensoredEventActivity(): int { ->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_CONFIDENTIAL))); $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { if ($row['principaluri'] === null) { continue; } diff --git a/apps/dav/lib/Migration/RemoveDeletedUsersCalendarSubscriptions.php b/apps/dav/lib/Migration/RemoveDeletedUsersCalendarSubscriptions.php index 69d27404cdf12..29b586c08cb6b 100644 --- a/apps/dav/lib/Migration/RemoveDeletedUsersCalendarSubscriptions.php +++ b/apps/dav/lib/Migration/RemoveDeletedUsersCalendarSubscriptions.php @@ -88,7 +88,7 @@ private function checkSubscriptions(): void { ->setFirstResult($this->progress); $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $username = $this->getPrincipal($row['principaluri']); if (!$this->userManager->userExists($username)) { $this->orphanSubscriptionIds[] = (int)$row['id']; diff --git a/apps/dav/lib/Migration/Version1025Date20240308063933.php b/apps/dav/lib/Migration/Version1025Date20240308063933.php index d84acf8fea965..83a0b46a23edc 100644 --- a/apps/dav/lib/Migration/Version1025Date20240308063933.php +++ b/apps/dav/lib/Migration/Version1025Date20240308063933.php @@ -64,7 +64,7 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array ->setFirstResult($limit) ->setMaxResults(1); $oldestIdResult = $thresholdSelect->executeQuery(); - $oldestId = $oldestIdResult->fetchColumn(); + $oldestId = $oldestIdResult->fetchOne(); $oldestIdResult->closeCursor(); $qb = $this->db->getQueryBuilder(); diff --git a/apps/dav/lib/Settings/AvailabilitySettings.php b/apps/dav/lib/Settings/AvailabilitySettings.php index 37d30eb57e054..092c2a2db4f54 100644 --- a/apps/dav/lib/Settings/AvailabilitySettings.php +++ b/apps/dav/lib/Settings/AvailabilitySettings.php @@ -17,6 +17,7 @@ use OCP\IConfig; use OCP\Settings\ISettings; use OCP\User\IAvailabilityCoordinator; +use OCP\Util; use Psr\Log\LoggerInterface; class AvailabilitySettings implements ISettings { @@ -56,8 +57,8 @@ public function getForm(): TemplateResponse { } } - \OCP\Util::addStyle(Application::APP_ID, 'settings-personal-availability'); - \OCP\Util::addScript(Application::APP_ID, 'settings-personal-availability'); + Util::addStyle(Application::APP_ID, 'settings-personal-availability'); + Util::addScript(Application::APP_ID, 'settings-personal-availability'); return new TemplateResponse(Application::APP_ID, 'settings-personal-availability'); } diff --git a/apps/dav/lib/Settings/CalDAVSettings.php b/apps/dav/lib/Settings/CalDAVSettings.php index 9b71a002538b4..da48ae5db1b31 100644 --- a/apps/dav/lib/Settings/CalDAVSettings.php +++ b/apps/dav/lib/Settings/CalDAVSettings.php @@ -13,6 +13,7 @@ use OCP\IConfig; use OCP\IURLGenerator; use OCP\Settings\IDelegatedSettings; +use OCP\Util; class CalDAVSettings implements IDelegatedSettings { @@ -45,8 +46,8 @@ public function getForm(): TemplateResponse { $this->initialState->provideInitialState($key, $value === 'yes'); } - \OCP\Util::addScript(Application::APP_ID, 'settings-admin-caldav'); - \OCP\Util::addStyle(Application::APP_ID, 'settings-admin-caldav'); + Util::addScript(Application::APP_ID, 'settings-admin-caldav'); + Util::addStyle(Application::APP_ID, 'settings-admin-caldav'); return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav'); } diff --git a/apps/dav/lib/Settings/ExampleContentSettings.php b/apps/dav/lib/Settings/ExampleContentSettings.php index a4018ff94b024..c158ce1f13ca0 100644 --- a/apps/dav/lib/Settings/ExampleContentSettings.php +++ b/apps/dav/lib/Settings/ExampleContentSettings.php @@ -16,6 +16,7 @@ use OCP\AppFramework\Services\IAppConfig; use OCP\AppFramework\Services\IInitialState; use OCP\Settings\ISettings; +use OCP\Util; class ExampleContentSettings implements ISettings { public function __construct( @@ -53,8 +54,8 @@ public function getForm(): TemplateResponse { ); } - \OCP\Util::addStyle(Application::APP_ID, 'settings-admin-example-content'); - \OCP\Util::addScript(Application::APP_ID, 'settings-admin-example-content'); + Util::addStyle(Application::APP_ID, 'settings-admin-example-content'); + Util::addScript(Application::APP_ID, 'settings-admin-example-content'); return new TemplateResponse(Application::APP_ID, 'settings-admin-example-content'); } diff --git a/apps/dav/tests/unit/BackgroundJob/CleanupOrphanedChildrenJobTest.php b/apps/dav/tests/unit/BackgroundJob/CleanupOrphanedChildrenJobTest.php index 2065b8fe9468f..aed7cf1bcb3e6 100644 --- a/apps/dav/tests/unit/BackgroundJob/CleanupOrphanedChildrenJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/CleanupOrphanedChildrenJobTest.php @@ -87,7 +87,7 @@ public function testRunWithoutOrphans(): void { ->method('executeQuery') ->willReturn($result); $result->expects(self::once()) - ->method('fetchAll') + ->method('fetchAllAssociative') ->willReturn([]); $result->expects(self::once()) ->method('closeCursor'); @@ -115,7 +115,7 @@ public function testRunWithPartialBatch(): void { ->method('executeQuery') ->willReturn($result); $result->expects(self::once()) - ->method('fetchAll') + ->method('fetchAllAssociative') ->willReturn([ ['id' => 42], ['id' => 43], @@ -152,7 +152,7 @@ public function testRunWithFullBatch(): void { ->method('executeQuery') ->willReturn($result); $result->expects(self::once()) - ->method('fetchAll') + ->method('fetchAllAssociative') ->willReturn(array_map(static fn ($i) => ['id' => 42 + $i], range(0, 999))); $result->expects(self::once()) ->method('closeCursor'); diff --git a/apps/dav/tests/unit/CalDAV/Reminder/BackendTest.php b/apps/dav/tests/unit/CalDAV/Reminder/BackendTest.php index 561002ee59e08..29d4e11ea342c 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/BackendTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/BackendTest.php @@ -46,7 +46,7 @@ public function testCleanRemindersForEvent(): void { $rows = $query->select('*') ->from('calendar_reminders') ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(4, $rows); @@ -56,7 +56,7 @@ public function testCleanRemindersForEvent(): void { $rows = $query->select('*') ->from('calendar_reminders') ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(2, $rows); } @@ -66,7 +66,7 @@ public function testCleanRemindersForCalendar(): void { $rows = $query->select('*') ->from('calendar_reminders') ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(4, $rows); @@ -76,7 +76,7 @@ public function testCleanRemindersForCalendar(): void { $rows = $query->select('*') ->from('calendar_reminders') ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(1, $rows); } @@ -86,7 +86,7 @@ public function testRemoveReminder(): void { $rows = $query->select('*') ->from('calendar_reminders') ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(4, $rows); @@ -96,7 +96,7 @@ public function testRemoveReminder(): void { $rows = $query->select('*') ->from('calendar_reminders') ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(3, $rows); } @@ -193,7 +193,7 @@ public function testInsertReminder(): void { $rows = $query->select('*') ->from('calendar_reminders') ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(4, $rows); @@ -204,7 +204,7 @@ public function testInsertReminder(): void { $rows = $query->select('*') ->from('calendar_reminders') ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(5, $rows); @@ -231,7 +231,7 @@ public function testUpdateReminder(): void { $rows = $query->select('*') ->from('calendar_reminders') ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(4, $rows); @@ -247,7 +247,7 @@ public function testUpdateReminder(): void { ->from('calendar_reminders') ->where($query->expr()->eq('id', $query->createNamedParameter($reminderId))) ->executeQuery() - ->fetch(); + ->fetchAssociative(); $this->assertEquals((int)$row['notification_date'], 123700); } diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php index 00ab531dc90d9..2c5c4789fca09 100644 --- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php +++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php @@ -550,7 +550,7 @@ public function testUpdateProperties(): void { ->orderBy('name'); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertSame(2, count($result)); @@ -575,7 +575,7 @@ public function testUpdateProperties(): void { ->from('cards_properties'); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertSame(1, count($result)); @@ -620,7 +620,7 @@ public function testPurgeProperties(): void { ->from('cards_properties'); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertSame(1, count($result)); diff --git a/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php b/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php index 6caec9266368e..50ca649b431ff 100644 --- a/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php +++ b/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php @@ -71,7 +71,7 @@ private function selectShares(): array { ), )); $result = $query->executeQuery(); - $data = $result->fetchAll(); + $data = $result->fetchAllAssociative(); $result->closeCursor(); return $data; diff --git a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php index 15b18d6c1b1f6..a12f40beaf54c 100644 --- a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php +++ b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php @@ -421,9 +421,8 @@ private function buildQueryExpects(string $token, ?array $return, int $time): vo ]); $stmt->expects($this->once()) - ->method('fetch') - ->with(\PDO::FETCH_ASSOC) - ->willReturn($return); + ->method('fetchAssociative') + ->willReturn($return ?? false); $stmt->expects($this->once()) ->method('closeCursor'); diff --git a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php index 3e333bddabf80..a7ef373c98929 100644 --- a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php @@ -112,7 +112,7 @@ protected function getProps(string $user, string $path): array { $result = $query->executeQuery(); $data = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $value = $row['propertyvalue']; if ((int)$row['valuetype'] === CustomPropertiesBackend::PROPERTY_TYPE_HREF) { $value = new Href($value); diff --git a/apps/dav/tests/unit/Migration/RefreshWebcalJobRegistrarTest.php b/apps/dav/tests/unit/Migration/RefreshWebcalJobRegistrarTest.php index 105f1296b42a4..54162df72d2a4 100644 --- a/apps/dav/tests/unit/Migration/RefreshWebcalJobRegistrarTest.php +++ b/apps/dav/tests/unit/Migration/RefreshWebcalJobRegistrarTest.php @@ -58,8 +58,7 @@ public function testRun(): void { ->willReturn($statement); $statement->expects($this->exactly(4)) - ->method('fetch') - ->with(\PDO::FETCH_ASSOC) + ->method('fetchAssociative') ->willReturnOnConsecutiveCalls( [ 'principaluri' => 'foo1', @@ -73,7 +72,7 @@ public function testRun(): void { 'principaluri' => 'foo3', 'uri' => 'bar3', ], - null + false, ); $this->jobList->expects($this->exactly(3)) diff --git a/apps/dav/tests/unit/Migration/RemoveDeletedUsersCalendarSubscriptionsTest.php b/apps/dav/tests/unit/Migration/RemoveDeletedUsersCalendarSubscriptionsTest.php index b7e1e258a90f3..c7843c8f57ac4 100644 --- a/apps/dav/tests/unit/Migration/RemoveDeletedUsersCalendarSubscriptionsTest.php +++ b/apps/dav/tests/unit/Migration/RemoveDeletedUsersCalendarSubscriptionsTest.php @@ -80,7 +80,7 @@ public function testRun(array $subscriptions, array $userExists, int $deletions) ->willReturn(count($subscriptions)); $result - ->method('fetch') + ->method('fetchAssociative') ->willReturnOnConsecutiveCalls(...$subscriptions); $qb->method('delete') diff --git a/apps/dav/tests/unit/Paginate/PaginatePluginTest.php b/apps/dav/tests/unit/Paginate/PaginatePluginTest.php index 2f93b27044d61..8d3d4cc9f781e 100644 --- a/apps/dav/tests/unit/Paginate/PaginatePluginTest.php +++ b/apps/dav/tests/unit/Paginate/PaginatePluginTest.php @@ -134,7 +134,7 @@ private function initializePlugin(): void { private function expectSequentialCalls(MockObject $mock, string $method, array $expectedCalls): void { $mock->expects(self::exactly(\count($expectedCalls))) ->method($method) - ->willReturnCallback(function (...$args) use (&$expectedCalls) { + ->willReturnCallback(function (...$args) use (&$expectedCalls): void { $expected = array_shift($expectedCalls); self::assertNotNull($expected); self::assertSame($expected, $args); diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 8a2c12e0ac8bf..47ed3e893e927 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -271,7 +271,7 @@ protected function getShareFromExternalShareTable(IShare $share) { ->where($query->expr()->eq('user', $query->createNamedParameter($share->getShareOwner()))) ->andWhere($query->expr()->eq('mountpoint', $query->createNamedParameter($share->getTarget()))); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); if (isset($result[0]) && (int)$result[0]['remote_id'] > 0) { @@ -410,7 +410,7 @@ public function getRemoteId(IShare $share): string { $query->select('remote_id')->from('federated_reshares') ->where($query->expr()->eq('share_id', $query->createNamedParameter((int)$share->getId()))); $result = $query->executeQuery(); - $data = $result->fetch(); + $data = $result->fetchAssociative(); $result->closeCursor(); if (!is_array($data) || !isset($data['remote_id'])) { @@ -442,7 +442,7 @@ public function getChildren(IShare $parent): array { ->orderBy('id'); $cursor = $qb->executeQuery(); - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { $children[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -591,7 +591,7 @@ private function getSharesInFolderInternal(?string $userId, Folder $node, ?bool $cursor = $qb->executeQuery(); $shares = []; - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { $shares[$data['fileid']][] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -647,7 +647,7 @@ public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offs $cursor = $qb->executeQuery(); $shares = []; - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -667,7 +667,7 @@ public function getShareById($id, $recipientId = null) { ->andWhere($qb->expr()->in('share_type', $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY))); $cursor = $qb->executeQuery(); - $data = $cursor->fetch(); + $data = $cursor->fetchAssociative(); $cursor->closeCursor(); if ($data === false) { @@ -700,7 +700,7 @@ public function getSharesByPath(Node $path) { ->executeQuery(); $shares = []; - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -739,7 +739,7 @@ public function getSharedWith($userId, $shareType, $node, $limit, $offset) { $cursor = $qb->executeQuery(); - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -764,7 +764,7 @@ public function getShareByToken($token) { ->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token))) ->executeQuery(); - $data = $cursor->fetch(); + $data = $cursor->fetchAssociative(); if ($data === false) { throw new ShareNotFound('Share not found', $this->l->t('Could not find share')); @@ -794,7 +794,7 @@ private function getRawShare($id) { ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); $cursor = $qb->executeQuery(); - $data = $cursor->fetch(); + $data = $cursor->fetchAssociative(); $cursor->closeCursor(); if ($data === false) { @@ -907,7 +907,7 @@ public function groupDeleted($gid) { // This is not a typo, the group ID is really stored in the 'user' column ->andWhere($qb->expr()->eq('user', $qb->createNamedParameter($gid))); $cursor = $qb->executeQuery(); - $parentShareIds = $cursor->fetchAll(\PDO::FETCH_COLUMN); + $parentShareIds = $cursor->fetchFirstColumn(); $cursor->closeCursor(); if ($parentShareIds === []) { return; @@ -929,7 +929,7 @@ public function userDeletedFromGroup($uid, $gid) { // This is not a typo, the group ID is really stored in the 'user' column ->andWhere($qb->expr()->eq('user', $qb->createNamedParameter($gid))); $cursor = $qb->executeQuery(); - $parentShareIds = $cursor->fetchAll(\PDO::FETCH_COLUMN); + $parentShareIds = $cursor->fetchFirstColumn(); $cursor->closeCursor(); if ($parentShareIds === []) { return; @@ -1047,14 +1047,14 @@ public function getAccessList($nodes, $currentAccess) { $cursor = $qb->executeQuery(); if ($currentAccess === false) { - $remote = $cursor->fetch() !== false; + $remote = $cursor->fetchAssociative() !== false; $cursor->closeCursor(); return ['remote' => $remote]; } $remote = []; - while ($row = $cursor->fetch()) { + while ($row = $cursor->fetchAssociative()) { $remote[$row['share_with']] = [ 'node_id' => $row['file_source'], 'token' => $row['token'], @@ -1073,7 +1073,7 @@ public function getAllShares(): iterable { ->where($qb->expr()->in('share_type', $qb->createNamedParameter([IShare::TYPE_REMOTE_GROUP, IShare::TYPE_REMOTE], IQueryBuilder::PARAM_INT_ARRAY))); $cursor = $qb->executeQuery(); - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { try { $share = $this->createShareObject($data); } catch (InvalidShare $e) { diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php index 461a4b1948a85..176301a1f2b90 100644 --- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php @@ -482,7 +482,7 @@ private function unshare($id, array $notification) { ); $result = $qb->executeQuery(); - $share = $result->fetch(); + $share = $result->fetchAssociative(); $result->closeCursor(); if ($token && $id && !empty($share)) { diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 6ec0ca138529c..4acf7d12e0b57 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -169,7 +169,7 @@ public function testCreate(?\DateTime $expirationDate, ?string $expectedDataDate ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->executeQuery(); - $data = $stmt->fetch(); + $data = $stmt->fetchAssociative(); $stmt->closeCursor(); $expected = [ @@ -256,7 +256,7 @@ public function testCreateCouldNotFindServer(): void { ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->executeQuery(); - $data = $stmt->fetch(); + $data = $stmt->fetchAssociative(); $stmt->closeCursor(); $this->assertFalse($data); @@ -317,7 +317,7 @@ public function testCreateException(): void { ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->executeQuery(); - $data = $stmt->fetch(); + $data = $stmt->fetchAssociative(); $stmt->closeCursor(); $this->assertFalse($data); @@ -360,7 +360,7 @@ public function testCreateShareWithSelf(): void { ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->executeQuery(); - $data = $stmt->fetch(); + $data = $stmt->fetchAssociative(); $stmt->closeCursor(); $this->assertFalse($data); @@ -732,7 +732,7 @@ public function testDeleteUser(string $owner, string $initiator, string $recipie $qb->expr()->eq('id', $qb->createNamedParameter($id)) ); $cursor = $qb->executeQuery(); - $data = $cursor->fetchAll(); + $data = $cursor->fetchAllAssociative(); $cursor->closeCursor(); $this->assertCount($rowDeleted ? 0 : 1, $data); diff --git a/apps/federation/lib/DbHandler.php b/apps/federation/lib/DbHandler.php index a56539bb30c6c..1dac5a2f45fc9 100644 --- a/apps/federation/lib/DbHandler.php +++ b/apps/federation/lib/DbHandler.php @@ -84,14 +84,15 @@ public function getServerById(int $id): array { ->setParameter('id', $id, IQueryBuilder::PARAM_INT); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + /** @var array{id: int, url: string, url_hash: string, token: ?string, shared_secret: ?string, status: int, sync_token: ?string} $result */ + $result = $qResult->fetchAssociative(); $qResult->closeCursor(); - if (empty($result)) { + if ($result === false) { throw new \Exception('No Server found with ID: ' . $id); } - return $result[0]; + return $result; } /** @@ -105,7 +106,7 @@ public function getAllServer(): array { $query->select(['url', 'url_hash', 'id', 'status', 'shared_secret', 'sync_token']) ->from($this->dbTable); $statement = $query->executeQuery(); - $result = $statement->fetchAll(); + $result = $statement->fetchAllAssociative(); $statement->closeCursor(); return $result; } @@ -121,7 +122,7 @@ public function serverExists(string $url): bool { ->where($query->expr()->eq('url_hash', $query->createParameter('url_hash'))) ->setParameter('url_hash', $hash); $statement = $query->executeQuery(); - $result = $statement->fetchAll(); + $result = $statement->fetchAllAssociative(); $statement->closeCursor(); return !empty($result); @@ -153,7 +154,7 @@ public function getToken(string $url): string { ->setParameter('url_hash', $hash); $statement = $query->executeQuery(); - $result = $statement->fetch(); + $result = $statement->fetchAssociative(); $statement->closeCursor(); if (!isset($result['token'])) { @@ -188,7 +189,7 @@ public function getSharedSecret(string $url): string { ->setParameter('url_hash', $hash); $statement = $query->executeQuery(); - $result = $statement->fetch(); + $result = $statement->fetchAssociative(); $statement->closeCursor(); return (string)$result['shared_secret']; } @@ -219,7 +220,7 @@ public function getServerStatus(string $url): int { ->setParameter('url_hash', $hash); $statement = $query->executeQuery(); - $result = $statement->fetch(); + $result = $statement->fetchAssociative(); $statement->closeCursor(); return (int)$result['status']; } @@ -259,7 +260,7 @@ public function auth(string $username, string $password): bool { ->where($query->expr()->eq('shared_secret', $query->createNamedParameter($password))); $statement = $query->executeQuery(); - $result = $statement->fetch(); + $result = $statement->fetchAssociative(); $statement->closeCursor(); return !empty($result); } diff --git a/apps/federation/tests/DbHandlerTest.php b/apps/federation/tests/DbHandlerTest.php index 4e9e1bd2c88d7..def093f3685a4 100644 --- a/apps/federation/tests/DbHandlerTest.php +++ b/apps/federation/tests/DbHandlerTest.php @@ -37,7 +37,7 @@ protected function setUp(): void { $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertEmpty($result, 'we need to start with a empty trusted_servers table'); } @@ -62,7 +62,7 @@ public function testAddServer(string $url, string $expectedUrl, string $expected $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertCount(1, $result); $this->assertSame($expectedUrl, $result[0]['url']); @@ -86,7 +86,7 @@ public function testRemove(): void { $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertCount(2, $result); $this->assertSame('server1', $result[0]['url']); @@ -98,7 +98,7 @@ public function testRemove(): void { $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertCount(1, $result); $this->assertSame('server1', $result[0]['url']); @@ -147,7 +147,7 @@ public function XtestAddToken() { $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertCount(1, $result); $this->assertSame(null, $result[0]['token']); @@ -155,7 +155,7 @@ public function XtestAddToken() { $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertCount(1, $result); $this->assertSame('token', $result[0]['token']); @@ -174,7 +174,7 @@ public function XtestAddSharedSecret() { $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertCount(1, $result); $this->assertSame(null, $result[0]['shared_secret']); @@ -182,7 +182,7 @@ public function XtestAddSharedSecret() { $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertCount(1, $result); $this->assertSame('secret', $result[0]['shared_secret']); @@ -201,7 +201,7 @@ public function testSetServerStatus(): void { $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertCount(1, $result); $this->assertSame(TrustedServers::STATUS_PENDING, (int)$result[0]['status']); @@ -209,7 +209,7 @@ public function testSetServerStatus(): void { $query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertCount(1, $result); $this->assertSame(TrustedServers::STATUS_OK, (int)$result[0]['status']); diff --git a/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php b/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php index b925974f24a43..b4e38224812e9 100644 --- a/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php +++ b/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php @@ -81,7 +81,7 @@ protected function cleanUp(string $table, string $idCol, string $typeCol): int { $deletedInLastChunk = self::CHUNK_SIZE; while ($deletedInLastChunk === self::CHUNK_SIZE) { - $chunk = $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); + $chunk = $query->executeQuery()->fetchFirstColumn(); $deletedInLastChunk = count($chunk); $deleteQuery->setParameter('objectid', $chunk, IQueryBuilder::PARAM_INT_ARRAY); @@ -112,7 +112,7 @@ private function getItemIds(string $table, string $idCol, string $typeCol, int $ $minId = 0; while (true) { $query->setParameter('min_id', $minId); - $rows = $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); + $rows = $query->executeQuery()->fetchFirstColumn(); if (count($rows) > 0) { $minId = $rows[count($rows) - 1]; yield $rows; @@ -127,7 +127,7 @@ private function findMissingSources(array $ids): array { $qb->select('fileid') ->from('filecache') ->where($qb->expr()->in('fileid', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))); - $found = $qb->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); + $found = $qb->executeQuery()->fetchFirstColumn(); return array_diff($ids, $found); } diff --git a/apps/files/lib/BackgroundJob/ScanFiles.php b/apps/files/lib/BackgroundJob/ScanFiles.php index f3f9093d64819..d1c39d2c2944b 100644 --- a/apps/files/lib/BackgroundJob/ScanFiles.php +++ b/apps/files/lib/BackgroundJob/ScanFiles.php @@ -76,7 +76,7 @@ private function getUserToScan() { ->runAcrossAllShards(); $result = $query->executeQuery(); - while ($res = $result->fetch()) { + while ($res = $result->fetchAssociative()) { if ($res['user_id']) { return $res['user_id']; } @@ -114,7 +114,7 @@ private function getAllMountedStorages(): array { $query = $this->connection->getQueryBuilder(); $query->selectDistinct('storage_id') ->from('mounts'); - return $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); + return $query->executeQuery()->fetchFirstColumn(); } /** diff --git a/apps/files/lib/Command/DeleteOrphanedFiles.php b/apps/files/lib/Command/DeleteOrphanedFiles.php index 37cb3159f4a28..8f2ccbe055136 100644 --- a/apps/files/lib/Command/DeleteOrphanedFiles.php +++ b/apps/files/lib/Command/DeleteOrphanedFiles.php @@ -64,7 +64,7 @@ private function getReferencedStorages(): array { ->from('filecache') ->groupBy('storage') ->runAcrossAllShards(); - return $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); + return $query->executeQuery()->fetchFirstColumn(); } private function getExistingStorages(): array { @@ -72,7 +72,7 @@ private function getExistingStorages(): array { $query->select('numeric_id') ->from('storages') ->groupBy('numeric_id'); - return $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); + return $query->executeQuery()->fetchFirstColumn(); } /** @@ -89,7 +89,7 @@ private function getFileIdsForStorages(array $storageIds): array { $storageIdChunks = array_chunk($storageIds, self::CHUNK_SIZE); foreach ($storageIdChunks as $storageIdChunk) { $query->setParameter('storage_ids', $storageIdChunk, IQueryBuilder::PARAM_INT_ARRAY); - $chunk = $query->executeQuery()->fetchAll(); + $chunk = $query->executeQuery()->fetchAllAssociative(); foreach ($chunk as $row) { $result[$row['storage']][] = $row['fileid']; } @@ -155,7 +155,7 @@ private function cleanupOrphanedMounts(): int { while ($deletedInLastChunk === self::CHUNK_SIZE) { $deletedInLastChunk = 0; $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $deletedInLastChunk++; $deletedEntries += $deleteQuery->setParameter('storageid', (int)$row['storage_id']) ->executeStatement(); diff --git a/apps/files/lib/Command/RepairTree.php b/apps/files/lib/Command/RepairTree.php index 3f7da68fb229e..b8a7eeebd598b 100644 --- a/apps/files/lib/Command/RepairTree.php +++ b/apps/files/lib/Command/RepairTree.php @@ -78,7 +78,7 @@ private function getFileId(int $storage, string $path) { ->from('filecache') ->where($query->expr()->eq('storage', $query->createNamedParameter($storage))) ->andWhere($query->expr()->eq('path_hash', $query->createNamedParameter(md5($path)))); - return $query->executeQuery()->fetch(\PDO::FETCH_COLUMN); + return $query->executeQuery()->fetchOne(); } private function deleteById(int $fileId): void { @@ -108,6 +108,6 @@ private function findBrokenTreeBits(): array { $query->expr()->neq('f.storage', 'p.storage') )); - return $query->executeQuery()->fetchAll(); + return $query->executeQuery()->fetchAllAssociative(); } } diff --git a/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php b/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php index 17fd69a332c0b..5202037b6a1cc 100644 --- a/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php +++ b/apps/files/tests/BackgroundJob/DeleteOrphanedItemsJobTest.php @@ -44,7 +44,7 @@ protected function getMappings(string $table): array { $query->select('*') ->from($table); $result = $query->executeQuery(); - $mapping = $result->fetchAll(); + $mapping = $result->fetchAllAssociative(); $result->closeCursor(); return $mapping; diff --git a/apps/files/tests/Command/DeleteOrphanedFilesTest.php b/apps/files/tests/Command/DeleteOrphanedFilesTest.php index 18b484123b9f7..0abff62580780 100644 --- a/apps/files/tests/Command/DeleteOrphanedFilesTest.php +++ b/apps/files/tests/Command/DeleteOrphanedFilesTest.php @@ -62,7 +62,7 @@ protected function getFile(int $fileId): array { $query->select('*') ->from('filecache') ->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId))); - return $query->executeQuery()->fetchAll(); + return $query->executeQuery()->fetchAllAssociative(); } protected function getMounts(int $storageId): array { @@ -70,7 +70,7 @@ protected function getMounts(int $storageId): array { $query->select('*') ->from('mounts') ->where($query->expr()->eq('storage_id', $query->createNamedParameter($storageId))); - return $query->executeQuery()->fetchAll(); + return $query->executeQuery()->fetchAllAssociative(); } /** diff --git a/apps/files_external/lib/Command/Notify.php b/apps/files_external/lib/Command/Notify.php index 9f42d974ecfec..3706ad2fd3e8e 100644 --- a/apps/files_external/lib/Command/Notify.php +++ b/apps/files_external/lib/Command/Notify.php @@ -177,7 +177,7 @@ private function getStorageIds(int $mountId, string $path): array { ->where($qb->expr()->eq('mount_id', $qb->createNamedParameter($mountId, IQueryBuilder::PARAM_INT))) ->andWhere($qb->expr()->eq('path_hash', $qb->createNamedParameter($pathHash, IQueryBuilder::PARAM_STR))) ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); } private function updateParent(array $storageIds, string $parent): int { diff --git a/apps/files_external/lib/Migration/Version1015Date20211104103506.php b/apps/files_external/lib/Migration/Version1015Date20211104103506.php index 20a279d805c4b..e24a306d8b194 100644 --- a/apps/files_external/lib/Migration/Version1015Date20211104103506.php +++ b/apps/files_external/lib/Migration/Version1015Date20211104103506.php @@ -37,7 +37,7 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array throw new \Exception('Could not fetch existing mounts for migration'); } - while ($mount = $mounts->fetch()) { + while ($mount = $mounts->fetchAssociative()) { $config = $this->getStorageConfig((int)$mount['mount_id']); $hostname = $config['hostname']; $bucket = $config['bucket']; @@ -82,7 +82,7 @@ private function getStorageConfig(int $mountId): array { ->from('external_config') ->where($qb->expr()->eq('mount_id', $qb->createPositionalParameter($mountId))); $config = []; - foreach ($qb->executeQuery()->fetchAll() as $row) { + foreach ($qb->executeQuery()->fetchAllAssociative() as $row) { $config[$row['key']] = $row['value']; } return $config; diff --git a/apps/files_external/lib/Service/DBConfigService.php b/apps/files_external/lib/Service/DBConfigService.php index 984b9313e419d..f08f3442a478c 100644 --- a/apps/files_external/lib/Service/DBConfigService.php +++ b/apps/files_external/lib/Service/DBConfigService.php @@ -100,7 +100,7 @@ protected function modifyMountsOnDelete(string $applicableId, int $applicableTyp ) ->groupBy(['a.mount_id']); $stmt = $query->executeQuery(); - $result = $stmt->fetchAll(); + $result = $stmt->fetchAllAssociative(); $stmt->closeCursor(); foreach ($result as $row) { @@ -378,7 +378,7 @@ public function removeApplicable($mountId, $type, $value) { private function getMountsFromQuery(IQueryBuilder $query) { $result = $query->executeQuery(); - $mounts = $result->fetchAll(); + $mounts = $result->fetchAllAssociative(); $uniqueMounts = []; foreach ($mounts as $mount) { $id = $mount['mount_id']; @@ -429,7 +429,7 @@ private function selectForMounts($table, array $fields, array $mountIds) { ->where($builder->expr()->in('mount_id', $placeHolders)); $result = $query->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $result->closeCursor(); $result = []; @@ -519,6 +519,6 @@ public function hasHomeFolderOverwriteMount(): bool { ->where($builder->expr()->eq('mount_point', $builder->createNamedParameter('/'))) ->setMaxResults(1); $result = $query->executeQuery(); - return count($result->fetchAll()) > 0; + return count($result->fetchAllAssociative()) > 0; } } diff --git a/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php b/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php index ca4c82c03d756..2ecb504a9cec2 100644 --- a/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php +++ b/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php @@ -37,7 +37,7 @@ public function run($argument) { ->from('share_external'); $result = $qb->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $this->discoveryService->discover($row['remote'], 'FEDERATED_SHARING', true); try { $this->ocmDiscoveryService->discover($row['remote'], true); diff --git a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php index 809481e5c0fba..18d1c2a11570e 100644 --- a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php +++ b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php @@ -140,7 +140,7 @@ public function getRemoteStorages() { $remoteStorages = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $remoteStorages[$row['id']] = $row['numeric_id']; } $result->closeCursor(); @@ -156,7 +156,7 @@ public function getRemoteShareIds() { $remoteShareIds = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $cloudId = $this->cloudIdManager->getCloudId($row['owner'], $row['remote']); $remote = $cloudId->getRemote(); diff --git a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php index 63f057e3bf4fa..42b80d885cc5d 100644 --- a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php +++ b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php @@ -13,7 +13,6 @@ use OCP\BackgroundJob\TimedJob; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; -use PDO; use Psr\Log\LoggerInterface; use function array_map; @@ -82,7 +81,7 @@ public function run($argument) { do { $deleted = $this->atomic(function () use ($qbSelect, $deleteQb) { $result = $qbSelect->executeQuery(); - $ids = array_map('intval', $result->fetchAll(PDO::FETCH_COLUMN)); + $ids = array_map('intval', $result->fetchFirstColumn()); $result->closeCursor(); $deleteQb->setParameter('ids', $ids, IQueryBuilder::PARAM_INT_ARRAY); $deleted = $deleteQb->executeStatement(); @@ -99,7 +98,7 @@ private function shardingCleanup(): void { $qb = $this->db->getQueryBuilder(); $qb->selectDistinct('file_source') ->from('share', 's'); - $sourceFiles = $qb->executeQuery()->fetchAll(PDO::FETCH_COLUMN); + $sourceFiles = $qb->executeQuery()->fetchFirstColumn(); $deleteQb = $this->db->getQueryBuilder(); $deleteQb->delete('share') @@ -127,7 +126,7 @@ private function findMissingSources(array $ids): array { $qb->select('fileid') ->from('filecache') ->where($qb->expr()->in('fileid', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))); - $found = $qb->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); + $found = $qb->executeQuery()->fetchFirstColumn(); return array_diff($ids, $found); } } diff --git a/apps/files_sharing/lib/ExpireSharesJob.php b/apps/files_sharing/lib/ExpireSharesJob.php index b1c6c592e8037..c72048e0e1e37 100644 --- a/apps/files_sharing/lib/ExpireSharesJob.php +++ b/apps/files_sharing/lib/ExpireSharesJob.php @@ -58,7 +58,7 @@ public function run($argument) { ); $shares = $qb->executeQuery(); - while ($share = $shares->fetch()) { + while ($share = $shares->fetchAssociative()) { if ((int)$share['share_type'] === IShare::TYPE_LINK) { $id = 'ocinternal'; } elseif ((int)$share['share_type'] === IShare::TYPE_EMAIL) { diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 3f87153d5da9d..43cd7f8d12541 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -160,7 +160,7 @@ private function fetchShare(int $id): array|false { ->from('share_external') ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))) ->executeQuery(); - $share = $result->fetch(); + $share = $result->fetchAssociative(); $result->closeCursor(); return $share; } @@ -177,7 +177,7 @@ private function fetchShareByToken(string $token): array|false { ->from('share_external') ->where($qb->expr()->eq('share_token', $qb->createNamedParameter($token, IQueryBuilder::PARAM_STR))) ->executeQuery(); - $share = $result->fetch(); + $share = $result->fetchAssociative(); $result->closeCursor(); return $share; } @@ -191,7 +191,7 @@ private function fetchUserShare(int $parentId, string $uid): ?array { $qb->expr()->eq('user', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_STR)), )) ->executeQuery(); - $share = $result->fetch(); + $share = $result->fetchAssociative(); $result->closeCursor(); if ($share !== false) { return $share; @@ -621,7 +621,7 @@ public function removeShare($mountPoint): bool { ->where($qb->expr()->eq('mountpoint_hash', $qb->createNamedParameter($hash))) ->andWhere($qb->expr()->eq('user', $qb->createNamedParameter($this->uid))); $result = $qb->executeQuery(); - $share = $result->fetch(); + $share = $result->fetchAssociative(); $result->closeCursor(); if ($share !== false && (int)$share['share_type'] === IShare::TYPE_USER) { try { @@ -681,7 +681,7 @@ public function removeUserShares($uid): bool { ->where($qb->expr()->eq('user', $qb->createNamedParameter($uid))) ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USER))); $result = $qb->executeQuery(); - $shares = $result->fetchAll(); + $shares = $result->fetchAllAssociative(); $result->closeCursor(); foreach ($shares as $share) { @@ -720,7 +720,7 @@ public function removeGroupShares($gid): bool { ->where($qb->expr()->eq('user', $qb->createNamedParameter($gid))) ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))); $result = $qb->executeQuery(); - $shares = $result->fetchAll(); + $shares = $result->fetchAllAssociative(); $result->closeCursor(); $deletedGroupShares = []; @@ -799,7 +799,8 @@ private function getShares($accepted) { try { $result = $qb->executeQuery(); - $shares = $result->fetchAll(); + /** @var list $shares */ + $shares = $result->fetchAllAssociative(); $result->closeCursor(); // remove parent group share entry if we have a specific user share entry for the user diff --git a/apps/files_sharing/lib/External/MountProvider.php b/apps/files_sharing/lib/External/MountProvider.php index a5781d5d35ac5..a1b8092d03298 100644 --- a/apps/files_sharing/lib/External/MountProvider.php +++ b/apps/files_sharing/lib/External/MountProvider.php @@ -57,7 +57,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) { ->andWhere($qb->expr()->eq('accepted', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))); $result = $qb->executeQuery(); $mounts = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $row['manager'] = $this; $row['token'] = $row['share_token']; $mounts[] = $this->getMount($user, $row, $loader); diff --git a/apps/files_sharing/lib/OrphanHelper.php b/apps/files_sharing/lib/OrphanHelper.php index ca8c198667b9d..37505e46a4414 100644 --- a/apps/files_sharing/lib/OrphanHelper.php +++ b/apps/files_sharing/lib/OrphanHelper.php @@ -68,7 +68,7 @@ public function getAllShares(?string $owner = null, ?string $with = null) { } $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { yield [ 'id' => (int)$row['id'], 'owner' => (string)$row['uid_owner'], diff --git a/apps/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php index 2aa52ef1b7fb8..28835a8d0eb1e 100644 --- a/apps/files_sharing/lib/ShareBackend/File.php +++ b/apps/files_sharing/lib/ShareBackend/File.php @@ -191,7 +191,7 @@ protected static function resolveReshares($source) { $qb->expr()->eq('id', $qb->createNamedParameter($parent)) ); $result = $qb->executeQuery(); - $item = $result->fetch(); + $item = $result->fetchAssociative(); $result->closeCursor(); if (isset($item['parent'])) { $parent = $item['parent']; diff --git a/apps/files_sharing/lib/ShareBackend/Folder.php b/apps/files_sharing/lib/ShareBackend/Folder.php index 35dc0da3c24fb..ee288f307727e 100644 --- a/apps/files_sharing/lib/ShareBackend/Folder.php +++ b/apps/files_sharing/lib/ShareBackend/Folder.php @@ -24,7 +24,7 @@ public function getChildren($itemSource): array { ); $result = $qb->executeQuery(); - if (($row = $result->fetch()) !== false) { + if (($row = $result->fetchAssociative()) !== false) { $mimetype = (int)$row['id']; } else { $mimetype = -1; @@ -47,7 +47,7 @@ public function getChildren($itemSource): array { $result = $qb->executeQuery(); $parents = []; - while ($file = $result->fetch()) { + foreach ($result->iterateAssociative() as $file) { $children[] = ['source' => $file['fileid'], 'file_path' => $file['name']]; // If a child folder is found look inside it if ((int)$file['mimetype'] === $mimetype) { diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php index 692a6c8979ba6..7dc95533d7497 100644 --- a/apps/files_sharing/lib/SharedMount.php +++ b/apps/files_sharing/lib/SharedMount.php @@ -255,7 +255,7 @@ public function getNumericStorageId() { ->where($builder->expr()->eq('fileid', $builder->createNamedParameter($this->getStorageRootId()))); $result = $query->executeQuery(); - $row = $result->fetch(); + $row = $result->fetchAssociative(); $result->closeCursor(); if ($row) { return (int)$row['storage']; diff --git a/apps/files_sharing/lib/SharesReminderJob.php b/apps/files_sharing/lib/SharesReminderJob.php index 854ad196d6be9..dcf65b8482316 100644 --- a/apps/files_sharing/lib/SharesReminderJob.php +++ b/apps/files_sharing/lib/SharesReminderJob.php @@ -132,11 +132,11 @@ private function getSharesData(): array { ) ->setMaxResults(SharesReminderJob::CHUNK_SIZE); - $shares = $qb->executeQuery()->fetchAll(); - return array_values(array_map(fn ($share): array => [ + $shares = $qb->executeQuery()->fetchAllAssociative(); + return array_map(fn ($share): array => [ 'id' => (int)$share['id'], 'share_type' => (int)$share['share_type'], - ], $shares)); + ], $shares); } /** @@ -171,12 +171,12 @@ private function getSharesDataSharded(): array|\Iterator { ) ); - $shares = $qb->executeQuery()->fetchAll(); - $shares = array_values(array_map(fn ($share): array => [ + $shares = $qb->executeQuery()->fetchAllAssociative(); + $shares = array_map(fn ($share): array => [ 'id' => (int)$share['id'], 'share_type' => (int)$share['share_type'], 'file_source' => (int)$share['file_source'], - ], $shares)); + ], $shares); return $this->filterSharesWithEmptyFolders($shares, self::CHUNK_SIZE); } @@ -198,7 +198,7 @@ private function filterSharesWithEmptyFolders(array $shares, int $maxResults): a $chunkFileIds = array_map(fn ($share): int => $share['file_source'], $chunk); $chunkByFileId = array_combine($chunkFileIds, $chunk); $query->setParameter('fileids', $chunkFileIds, IQueryBuilder::PARAM_INT_ARRAY); - $chunkResults = $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); + $chunkResults = $query->executeQuery()->fetchFirstColumn(); foreach ($chunkResults as $folderId) { $results[] = $chunkByFileId[$folderId]; } diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 30a946c7847b9..93c9d6e817d97 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -5529,8 +5529,8 @@ public function testParentDownloadAttributeInherited(): void { $owner = $this->createMock(IUser::class); $storage = $this->createMock(SharedStorage::class); $originalShare = $this->createMock(IShare::class); - $attributes = $this->createMock(\OCP\Share\IAttributes::class); - $shareAttributes = $this->createMock(\OCP\Share\IAttributes::class); + $attributes = $this->createMock(IShareAttributes::class); + $shareAttributes = $this->createMock(IShareAttributes::class); $share->method('getSharedBy')->willReturn('sharedByUser'); $share->method('getNodeId')->willReturn(42); @@ -5565,7 +5565,7 @@ public function testFederatedStorageRespectsUserChoice(): void { $node = $this->createMock(File::class); $userFolder = $this->createMock(Folder::class); $owner = $this->createMock(IUser::class); - $storage = $this->createMock(\OCA\Files_Sharing\External\Storage::class); + $storage = $this->createMock(Storage::class); $share->method('getSharedBy')->willReturn('sharedByUser'); $share->method('getNodeId')->willReturn(42); @@ -5575,7 +5575,7 @@ public function testFederatedStorageRespectsUserChoice(): void { $node->method('getStorage')->willReturn($storage); $storage->method('instanceOfStorage')->willReturnMap([ [SharedStorage::class, false], - [\OCA\Files_Sharing\External\Storage::class, true] + [Storage::class, true] ]); $userFolder->method('getById')->with(42)->willReturn([$node]); diff --git a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php index 820c5e107f147..9e01f5cd4ad90 100644 --- a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php +++ b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php @@ -105,7 +105,7 @@ protected function tearDown(): void { private function getShares() { $shares = []; $result = $this->connection->executeQuery('SELECT * FROM `*PREFIX*share`'); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $shares[] = $row; } $result->closeCursor(); diff --git a/apps/files_sharing/tests/ExpireSharesJobTest.php b/apps/files_sharing/tests/ExpireSharesJobTest.php index e6db24241769b..00defc040bb86 100644 --- a/apps/files_sharing/tests/ExpireSharesJobTest.php +++ b/apps/files_sharing/tests/ExpireSharesJobTest.php @@ -85,7 +85,7 @@ private function getShares() { ->from('share') ->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $shares[] = $row; } $result->closeCursor(); diff --git a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php index 120b0318e5801..9afa188cbc7e0 100644 --- a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php +++ b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php @@ -91,7 +91,7 @@ public function testAddPasswordColumn(): void { $query->select('*') ->from('share'); $result = $query->executeQuery(); - $allShares = $result->fetchAll(); + $allShares = $result->fetchAllAssociative(); $result->closeCursor(); foreach ($allShares as $share) { diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 15d5cd73a12dc..dfe7d6c03d041 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -112,7 +112,7 @@ public static function getExtraData($user) { ->where($query->expr()->eq('user', $query->createNamedParameter($user))); $result = $query->executeQuery(); $array = []; - while ($row = $result->fetch()) { + foreach ($result->iterateAssociative() as $row) { $array[$row['id']][$row['timestamp']] = [ 'location' => (string)$row['location'], 'deletedBy' => (string)$row['deleted_by'], @@ -139,7 +139,7 @@ public static function getLocation($user, $filename, $timestamp) { ->andWhere($query->expr()->eq('timestamp', $query->createNamedParameter($timestamp))); $result = $query->executeQuery(); - $row = $result->fetch(); + $row = $result->fetchAssociative(); $result->closeCursor(); if (isset($row['location'])) { @@ -1017,7 +1017,7 @@ private static function getVersionsFromTrash($filename, $timestamp, string $user ->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern))); $result = $query->executeQuery(); - $entries = $result->fetchAll(); + $entries = $result->fetchAllAssociative(); $result->closeCursor(); /** @var CacheEntry[] $matches */ diff --git a/apps/files_trashbin/tests/Command/CleanUpTest.php b/apps/files_trashbin/tests/Command/CleanUpTest.php index b8c98110da9be..dd0352a6a19a7 100644 --- a/apps/files_trashbin/tests/Command/CleanUpTest.php +++ b/apps/files_trashbin/tests/Command/CleanUpTest.php @@ -65,7 +65,7 @@ public function initTable(): void { $result = $getAllQuery->select('id') ->from($this->trashTable) ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(10, $result); } @@ -97,7 +97,7 @@ public function testRemoveDeletedFiles(bool $nodeExists): void { ->from($this->trashTable); $qResult = $query->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertCount(5, $result); @@ -111,7 +111,7 @@ public function testRemoveDeletedFiles(bool $nodeExists): void { $result = $getAllQuery->select('id') ->from($this->trashTable) ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(10, $result); } } diff --git a/apps/files_versions/lib/Db/VersionsMapper.php b/apps/files_versions/lib/Db/VersionsMapper.php index 318dd8f0d822e..5ee997a3c26d3 100644 --- a/apps/files_versions/lib/Db/VersionsMapper.php +++ b/apps/files_versions/lib/Db/VersionsMapper.php @@ -95,7 +95,7 @@ private function getFileIdsGenerator(int $storageId, ?string $path): \Generator $filesIdsSelect->setParameter('offset', $offset, IQueryBuilder::PARAM_INT); $result = $filesIdsSelect->executeQuery(); - $fileIds = $result->fetchAll(\PDO::FETCH_COLUMN); + $fileIds = $result->fetchFirstColumn(); $offset = end($fileIds); yield $fileIds; diff --git a/apps/oauth2/lib/Migration/SetTokenExpiration.php b/apps/oauth2/lib/Migration/SetTokenExpiration.php index dc925e26bb22b..428153b51bc30 100644 --- a/apps/oauth2/lib/Migration/SetTokenExpiration.php +++ b/apps/oauth2/lib/Migration/SetTokenExpiration.php @@ -36,7 +36,7 @@ public function run(IOutput $output) { $cursor = $qb->executeQuery(); - while ($row = $cursor->fetch()) { + while ($row = $cursor->fetchAssociative()) { $token = AccessToken::fromRow($row); try { $appToken = $this->tokenProvider->getTokenById($token->getTokenId()); diff --git a/apps/oauth2/lib/Migration/Version011601Date20230522143227.php b/apps/oauth2/lib/Migration/Version011601Date20230522143227.php index f2998202e02ac..d206915f861e1 100644 --- a/apps/oauth2/lib/Migration/Version011601Date20230522143227.php +++ b/apps/oauth2/lib/Migration/Version011601Date20230522143227.php @@ -52,7 +52,7 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $qbSelect->select('id', 'secret') ->from('oauth2_clients'); $req = $qbSelect->executeQuery(); - while ($row = $req->fetch()) { + while ($row = $req->fetchAssociative()) { $id = $row['id']; $secret = $row['secret']; $encryptedSecret = $this->crypto->encrypt($secret); diff --git a/apps/oauth2/lib/Migration/Version011901Date20240829164356.php b/apps/oauth2/lib/Migration/Version011901Date20240829164356.php index 20f5754bf1138..3e97b29fdd145 100644 --- a/apps/oauth2/lib/Migration/Version011901Date20240829164356.php +++ b/apps/oauth2/lib/Migration/Version011901Date20240829164356.php @@ -35,7 +35,7 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $qbSelect->select('id', 'secret') ->from('oauth2_clients'); $req = $qbSelect->executeQuery(); - while ($row = $req->fetch()) { + while ($row = $req->fetchAssociative()) { $id = $row['id']; $storedEncryptedSecret = $row['secret']; $secret = $this->crypto->decrypt($storedEncryptedSecret); diff --git a/apps/settings/lib/Settings/Admin/Server.php b/apps/settings/lib/Settings/Admin/Server.php index c142c26dbd690..02a6cd2736b3d 100644 --- a/apps/settings/lib/Settings/Admin/Server.php +++ b/apps/settings/lib/Settings/Admin/Server.php @@ -70,7 +70,7 @@ protected function cronMaxAge(): int { ->setMaxResults(1); $result = $query->executeQuery(); - if ($row = $result->fetch()) { + if ($row = $result->fetchAssociative()) { $maxAge = (int)$row['last_checked']; } else { $maxAge = $this->timeFactory->getTime(); diff --git a/apps/settings/lib/SetupChecks/SupportedDatabase.php b/apps/settings/lib/SetupChecks/SupportedDatabase.php index 27e9b1f7772a3..5c75ba81462af 100644 --- a/apps/settings/lib/SetupChecks/SupportedDatabase.php +++ b/apps/settings/lib/SetupChecks/SupportedDatabase.php @@ -43,7 +43,7 @@ public function run(): SetupResult { if ($databasePlatform === IDBConnection::PLATFORM_MYSQL || $databasePlatform === IDBConnection::PLATFORM_MARIADB) { $statement = $this->connection->prepare("SHOW VARIABLES LIKE 'version';"); $result = $statement->execute(); - $row = $result->fetch(); + $row = $result->fetchAssociative(); $version = $row['Value']; $versionlc = strtolower($version); // we only care about X.Y not X.Y.Z differences @@ -89,7 +89,7 @@ public function run(): SetupResult { } elseif ($databasePlatform === IDBConnection::PLATFORM_POSTGRES) { $statement = $this->connection->prepare('SHOW server_version;'); $result = $statement->execute(); - $row = $result->fetch(); + $row = $result->fetchAssociative(); $version = $row['server_version']; $versionlc = strtolower($version); // we only care about X not X.Y or X.Y.Z differences diff --git a/apps/settings/tests/Command/AdminDelegation/AddTest.php b/apps/settings/tests/Command/AdminDelegation/AddTest.php index 9332bf69aca68..883da1323b979 100644 --- a/apps/settings/tests/Command/AdminDelegation/AddTest.php +++ b/apps/settings/tests/Command/AdminDelegation/AddTest.php @@ -11,6 +11,7 @@ use OC\Settings\AuthorizedGroup; use OCA\Settings\Command\AdminDelegation\Add; use OCA\Settings\Service\AuthorizedGroupService; +use OCA\Settings\Settings\Admin\Server; use OCP\IGroupManager; use OCP\Settings\IManager; use PHPUnit\Framework\MockObject\MockObject; @@ -45,7 +46,7 @@ protected function setUp(): void { } public function testExecuteSuccessfulDelegation(): void { - $settingClass = \OCA\Settings\Settings\Admin\Server::class; + $settingClass = Server::class; $groupId = 'testgroup'; // Mock valid delegated settings class @@ -93,7 +94,7 @@ public function testExecuteInvalidSettingClass(): void { } public function testExecuteNonExistentGroup(): void { - $settingClass = \OCA\Settings\Settings\Admin\Server::class; + $settingClass = Server::class; $groupId = 'nonexistentgroup'; $this->input->expects($this->exactly(2)) diff --git a/apps/sharebymail/lib/Settings/Admin.php b/apps/sharebymail/lib/Settings/Admin.php index af0526e80dcbd..48592e74ff670 100644 --- a/apps/sharebymail/lib/Settings/Admin.php +++ b/apps/sharebymail/lib/Settings/Admin.php @@ -10,6 +10,7 @@ use OCP\AppFramework\Services\IInitialState; use OCP\IL10N; use OCP\Settings\IDelegatedSettings; +use OCP\Util; class Admin implements IDelegatedSettings { public function __construct( @@ -26,8 +27,8 @@ public function getForm() { $this->initialState->provideInitialState('sendPasswordMail', $this->settingsManager->sendPasswordByMail()); $this->initialState->provideInitialState('replyToInitiator', $this->settingsManager->replyToInitiator()); - \OCP\Util::addStyle('sharebymail', 'admin-settings'); - \OCP\Util::addScript('sharebymail', 'admin-settings'); + Util::addStyle('sharebymail', 'admin-settings'); + Util::addScript('sharebymail', 'admin-settings'); return new TemplateResponse('sharebymail', 'settings-admin', [], ''); } diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index c443459a7127b..16e3068b15b90 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -650,7 +650,7 @@ public function getChildren(IShare $parent): array { ->orderBy('id'); $cursor = $qb->executeQuery(); - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { $children[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -845,7 +845,7 @@ public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offs $cursor = $qb->executeQuery(); $shares = []; - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -865,7 +865,7 @@ public function getShareById($id, $recipientId = null): IShare { ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))); $cursor = $qb->executeQuery(); - $data = $cursor->fetch(); + $data = $cursor->fetchAssociative(); $cursor->closeCursor(); if ($data === false) { @@ -896,7 +896,7 @@ public function getSharesByPath(Node $path): array { ->executeQuery(); $shares = []; - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -935,7 +935,7 @@ public function getSharedWith($userId, $shareType, $node, $limit, $offset): arra $cursor = $qb->executeQuery(); - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -958,7 +958,7 @@ public function getShareByToken($token): IShare { ->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token))) ->executeQuery(); - $data = $cursor->fetch(); + $data = $cursor->fetchAssociative(); if ($data === false) { throw new ShareNotFound('Share not found', $this->l->t('Could not find share')); @@ -1099,7 +1099,7 @@ protected function getRawShare(int $id): array { ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); $cursor = $qb->executeQuery(); - $data = $cursor->fetch(); + $data = $cursor->fetchAssociative(); $cursor->closeCursor(); if ($data === false) { @@ -1153,7 +1153,7 @@ private function getSharesInFolderInternal(?string $userId, Folder $node, ?bool $cursor = $qb->executeQuery(); $shares = []; - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { $shares[$data['fileid']][] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -1180,7 +1180,7 @@ public function getAccessList($nodes, $currentAccess): array { $public = false; $mail = []; - while ($row = $cursor->fetch()) { + while ($row = $cursor->fetchAssociative()) { $public = true; if ($currentAccess === false) { $mail[] = $row['share_with']; @@ -1208,7 +1208,7 @@ public function getAllShares(): iterable { ); $cursor = $qb->executeQuery(); - while ($data = $cursor->fetch()) { + while ($data = $cursor->fetchAssociative()) { try { $share = $this->createShareObject($data); } catch (InvalidShare $e) { diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index 68e7e8691fa22..3386e55abd88d 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -747,7 +747,7 @@ public function testAddShareToDB(): void { ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); $qResult = $qb->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertSame(1, count($result)); @@ -800,7 +800,7 @@ public function testUpdate(): void { ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); $qResult = $qb->executeQuery(); - $result = $qResult->fetchAll(); + $result = $qResult->fetchAllAssociative(); $qResult->closeCursor(); $this->assertSame(1, count($result)); @@ -1032,7 +1032,7 @@ public function testRemoveShareFromTable(): void { ->where($query->expr()->eq('id', $query->createNamedParameter($id))); $result = $query->executeQuery(); - $before = $result->fetchAll(); + $before = $result->fetchAllAssociative(); $result->closeCursor(); $this->assertTrue(is_array($before)); @@ -1045,7 +1045,7 @@ public function testRemoveShareFromTable(): void { ->where($query->expr()->eq('id', $query->createNamedParameter($id))); $result = $query->executeQuery(); - $after = $result->fetchAll(); + $after = $result->fetchAllAssociative(); $result->closeCursor(); $this->assertTrue(is_array($after)); @@ -1068,7 +1068,7 @@ public function testUserDeleted(): void { $query->select('*')->from('share'); $result = $query->executeQuery(); - $before = $result->fetchAll(); + $before = $result->fetchAllAssociative(); $result->closeCursor(); $this->assertTrue(is_array($before)); @@ -1083,7 +1083,7 @@ public function testUserDeleted(): void { $query->select('*')->from('share'); $result = $query->executeQuery(); - $after = $result->fetchAll(); + $after = $result->fetchAllAssociative(); $result->closeCursor(); $this->assertTrue(is_array($after)); diff --git a/apps/theming/lib/Jobs/MigrateBackgroundImages.php b/apps/theming/lib/Jobs/MigrateBackgroundImages.php index 62e58f5e72223..685e7c9cc8cc1 100644 --- a/apps/theming/lib/Jobs/MigrateBackgroundImages.php +++ b/apps/theming/lib/Jobs/MigrateBackgroundImages.php @@ -68,7 +68,7 @@ protected function runPreparation(): void { ->andWhere($selector->expr()->eq('configvalue', $selector->createNamedParameter('custom', IQueryBuilder::PARAM_STR), IQueryBuilder::PARAM_STR)) ->executeQuery(); - $userIds = $result->fetchAll(\PDO::FETCH_COLUMN); + $userIds = $result->fetchFirstColumn(); $this->storeUserIdsToProcess($userIds); } catch (\Throwable $t) { $this->jobList->add(self::class, ['stage' => self::STAGE_PREPARE]); diff --git a/apps/theming/lib/Jobs/RestoreBackgroundImageColor.php b/apps/theming/lib/Jobs/RestoreBackgroundImageColor.php index 42662dacef2a1..a2b2778cc7dff 100644 --- a/apps/theming/lib/Jobs/RestoreBackgroundImageColor.php +++ b/apps/theming/lib/Jobs/RestoreBackgroundImageColor.php @@ -75,7 +75,7 @@ protected function runPreparation(): void { ->andWhere($qb2->expr()->isNull('b.userid')) ->executeQuery(); - $userIds = $result->fetchAll(\PDO::FETCH_COLUMN); + $userIds = $result->fetchFirstColumn(); $this->logger->info('Prepare to restore background information for {users} users', ['users' => count($userIds)]); $this->storeUserIdsToProcess($userIds); } catch (\Throwable $t) { diff --git a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php index c880b3df78f2c..ad277d3b15bd0 100644 --- a/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php +++ b/apps/twofactor_backupcodes/lib/Migration/Version1002Date20170607113030.php @@ -55,7 +55,7 @@ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $result = $query->executeQuery(); $output->startProgress(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $output->advance(); $insert diff --git a/apps/twofactor_backupcodes/lib/Settings/Personal.php b/apps/twofactor_backupcodes/lib/Settings/Personal.php index c9405b59b62b9..77b3b447b48e4 100644 --- a/apps/twofactor_backupcodes/lib/Settings/Personal.php +++ b/apps/twofactor_backupcodes/lib/Settings/Personal.php @@ -14,11 +14,12 @@ use OCP\Server; use OCP\Template\ITemplate; use OCP\Template\ITemplateManager; +use OCP\Util; class Personal implements IPersonalProviderSettings { public function getBody(): ITemplate { - \OCP\Util::addScript(Application::APP_ID, 'settings-personal'); - \OCP\Util::addStyle(Application::APP_ID, 'settings-personal'); + Util::addScript(Application::APP_ID, 'settings-personal'); + Util::addStyle(Application::APP_ID, 'settings-personal'); return Server::get(ITemplateManager::class) ->getTemplate('twofactor_backupcodes', 'personal'); } diff --git a/apps/user_ldap/lib/Db/GroupMembershipMapper.php b/apps/user_ldap/lib/Db/GroupMembershipMapper.php index b3d6c31dda651..c81ee7010aeea 100644 --- a/apps/user_ldap/lib/Db/GroupMembershipMapper.php +++ b/apps/user_ldap/lib/Db/GroupMembershipMapper.php @@ -30,7 +30,7 @@ public function getKnownGroups(): array { ->from($this->getTableName()) ->executeQuery(); - $groups = array_column($result->fetchAll(), 'groupid'); + $groups = array_column($result->fetchAllAssociative(), 'groupid'); $result->closeCursor(); return $groups; } diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php index fdcc15535ead8..338d49ad03b4a 100644 --- a/apps/user_ldap/lib/Mapping/AbstractMapping.php +++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php @@ -98,7 +98,7 @@ protected function useCacheByUserCount(): bool { ->from($this->getTableName()); $q->setMaxResults(self::LOCAL_CACHE_OBJECT_THRESHOLD + 1); $result = $q->executeQuery(); - $row = $result->fetch(); + $row = $result->fetchAssociative(); $result->closeCursor(); $use = (int)$row['count'] <= self::LOCAL_CACHE_OBJECT_THRESHOLD; @@ -275,7 +275,7 @@ protected function prepareListOfIdsQuery(array $hashList): IQueryBuilder { protected function collectResultsFromListOfIdsQuery(IQueryBuilder $qb, array &$results): void { $stmt = $qb->executeQuery(); - while ($entry = $stmt->fetch(\Doctrine\DBAL\FetchMode::ASSOCIATIVE)) { + while ($entry = $stmt->fetchAssociative()) { $results[$entry['ldap_dn']] = $entry['owncloud_name']; $this->cache[$entry['ldap_dn']] = $entry['owncloud_name']; } @@ -345,7 +345,7 @@ public function getNamesBySearch(string $search, string $prefixMatch = '', strin return []; } $names = []; - while ($row = $res->fetch()) { + while ($row = $res->fetchAssociative()) { $names[] = $row['owncloud_name']; } return $names; @@ -390,7 +390,7 @@ public function getList(int $offset = 0, ?int $limit = null, bool $invalidatedOn } $result = $select->executeQuery(); - $entries = $result->fetchAll(); + $entries = $result->fetchAllAssociative(); $result->closeCursor(); return $entries; diff --git a/apps/user_ldap/lib/Migration/GroupMappingMigration.php b/apps/user_ldap/lib/Migration/GroupMappingMigration.php index 7dfb870577069..8bafff2f80db3 100644 --- a/apps/user_ldap/lib/Migration/GroupMappingMigration.php +++ b/apps/user_ldap/lib/Migration/GroupMappingMigration.php @@ -35,7 +35,7 @@ protected function copyGroupMappingData(string $sourceTable, string $destination $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $insert ->setParameter('ldap_dn', $row['ldap_dn']) ->setParameter('owncloud_name', $row['owncloud_name']) diff --git a/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php b/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php index dc3823bf77118..a6e071811e090 100644 --- a/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php +++ b/apps/user_ldap/lib/Migration/Version1120Date20210917155206.php @@ -72,7 +72,7 @@ protected function handleIDs(string $table, bool $emitHooks) { $update = $this->getUpdateQuery($table); $result = $select->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $newId = hash('sha256', $row['owncloud_name'], false); if ($emitHooks) { $this->emitUnassign($row['owncloud_name'], true); diff --git a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php index 2457acd840d00..406c1633fc80a 100644 --- a/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php +++ b/apps/user_ldap/lib/Migration/Version1130Date20211102154716.php @@ -137,7 +137,7 @@ protected function handleDNHashes(string $table): void { $update = $this->getUpdateQuery($table); $result = $select->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $dnHash = hash('sha256', $row['ldap_dn'], false); $update->setParameter('name', $row['owncloud_name']); $update->setParameter('dn_hash', $dnHash); diff --git a/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php b/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php index 85b046ab7c944..7099712073fd5 100644 --- a/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php +++ b/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php @@ -80,7 +80,7 @@ protected function copyGroupMembershipData(): void { ->from('ldap_group_members'); $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $knownUsers = unserialize($row['owncloudusers']); if (!is_array($knownUsers)) { /* Unserialize failed or data was incorrect in database, ignore */ diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php index c402f84c83002..44d4c71b4f0f0 100644 --- a/apps/workflowengine/lib/Manager.php +++ b/apps/workflowengine/lib/Manager.php @@ -104,7 +104,7 @@ public function getAllConfiguredEvents() { $result = $query->executeQuery(); $operations = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $eventNames = \json_decode($row['events']); $operation = $row['class']; @@ -152,7 +152,7 @@ public function getAllConfiguredScopesForOperation(string $operationClass): arra $result = $query->executeQuery(); $scopesByOperation[$operationClass] = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $scope = new ScopeContext($row['type'], $row['value']); if (!$operation->isAvailableForScope((int)$row['type'])) { @@ -187,7 +187,7 @@ public function getAllOperations(ScopeContext $scopeContext): array { $result = $query->executeQuery(); $this->operations[$scopeContext->getHash()] = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { try { /** @var IOperation $operation */ $operation = $this->container->get($row['class']); @@ -226,7 +226,7 @@ protected function getOperation($id) { ->from('flow_operations') ->where($query->expr()->eq('id', $query->createNamedParameter($id))); $result = $query->executeQuery(); - $row = $result->fetch(); + $row = $result->fetchAssociative(); $result->closeCursor(); if ($row) { @@ -540,7 +540,7 @@ public function getChecks(array $checkIds): array { ->where($query->expr()->in('id', $query->createNamedParameter($checkIds, IQueryBuilder::PARAM_INT_ARRAY))); $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { /** @var Check $row */ $this->checks[(int)$row['id']] = $row; $checks[(int)$row['id']] = $row; @@ -569,7 +569,7 @@ protected function addCheck(string $class, string $operator, string $value): int ->where($query->expr()->eq('hash', $query->createNamedParameter($hash))); $result = $query->executeQuery(); - if ($row = $result->fetch()) { + if ($row = $result->fetchAssociative()) { $result->closeCursor(); return (int)$row['id']; } diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 71d9fe016a481..8a049d4b7058c 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -879,7 +879,6 @@ - @@ -2809,9 +2808,6 @@ - - - diff --git a/core/BackgroundJobs/MovePreviewJob.php b/core/BackgroundJobs/MovePreviewJob.php index e0a9d5b5517c8..1442b22b32776 100644 --- a/core/BackgroundJobs/MovePreviewJob.php +++ b/core/BackgroundJobs/MovePreviewJob.php @@ -94,7 +94,7 @@ private function processQueryResult(IResult $result): bool { $foundPreview = false; $fileIds = []; $flatFileIds = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $pathSplit = explode('/', $row['path']); assert(count($pathSplit) >= 2); $fileId = (int)$pathSplit[count($pathSplit) - 2]; @@ -161,7 +161,7 @@ private function processPreviews(int $fileId, bool $flatPath): void { ->setMaxResults(1); $result = $qb->executeQuery(); - $result = $result->fetchAll(); + $result = $result->fetchAllAssociative(); if (count($result) > 0) { foreach ($previewFiles as $previewFile) { diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php index 2c74e9e517f5f..4e7e8c604f3dc 100644 --- a/core/Command/Db/ConvertType.php +++ b/core/Command/Db/ConvertType.php @@ -342,7 +342,7 @@ protected function copyTable(Connection $fromDB, Connection $toDB, Table $table, try { $toDB->beginTransaction(); - while ($row = $result->fetch()) { + foreach ($result->iterateAssociative() as $row) { $progress->advance(); if (!$parametersCreated) { foreach ($row as $key => $value) { diff --git a/core/Command/Info/FileUtils.php b/core/Command/Info/FileUtils.php index bc07535a289af..e106fc7a77aa2 100644 --- a/core/Command/Info/FileUtils.php +++ b/core/Command/Info/FileUtils.php @@ -253,7 +253,7 @@ public function getStorage(int $id): ?array { ->leftJoin('s', 'mounts', 'm', $query->expr()->eq('s.numeric_id', 'm.storage_id')) ->where($query->expr()->eq('s.numeric_id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT))) ->groupBy('s.numeric_id', 's.id', 's.available', 's.last_checked', 'mount_id'); - $row = $query->executeQuery()->fetch(); + $row = $query->executeQuery()->fetchAssociative(); if ($row) { return [ 'numeric_id' => $row['numeric_id'], @@ -286,7 +286,7 @@ public function listStorages(?int $limit): \Iterator { $query->setMaxResults($limit); } $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { yield [ 'numeric_id' => $row['numeric_id'], 'id' => $row['id'], diff --git a/core/Command/Maintenance/RepairShareOwnership.php b/core/Command/Maintenance/RepairShareOwnership.php index 16675545afea7..6556d7ee7074a 100644 --- a/core/Command/Maintenance/RepairShareOwnership.php +++ b/core/Command/Maintenance/RepairShareOwnership.php @@ -92,7 +92,7 @@ protected function getWrongShareOwnership(): array { ->where($qb->expr()->neq('m.user_id', 's.uid_owner')) ->andWhere($qb->expr()->eq($qb->func()->concat($qb->expr()->literal('/'), 'm.user_id', $qb->expr()->literal('/')), 'm.mount_point')) ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $found = []; @@ -126,7 +126,7 @@ protected function getWrongShareOwnershipForUser(IUser $user): array { ->andWhere($qb->expr()->eq($qb->func()->concat($qb->expr()->literal('/'), 'm.user_id', $qb->expr()->literal('/')), 'm.mount_point')) ->andWhere($qb->expr()->eq('s.share_with', $qb->createNamedParameter($user->getUID()))) ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $found = []; diff --git a/core/Controller/OCMController.php b/core/Controller/OCMController.php index 851f2c1635a3b..9ad45ea9d8f35 100644 --- a/core/Controller/OCMController.php +++ b/core/Controller/OCMController.php @@ -20,7 +20,6 @@ use OCP\AppFramework\Http\DataResponse; use OCP\IAppConfig; use OCP\IRequest; -use OCP\Server; use Psr\Log\LoggerInterface; /** diff --git a/core/Listener/PasswordUpdatedListener.php b/core/Listener/PasswordUpdatedListener.php index b88abc067294c..4830c76744239 100644 --- a/core/Listener/PasswordUpdatedListener.php +++ b/core/Listener/PasswordUpdatedListener.php @@ -19,7 +19,7 @@ */ class PasswordUpdatedListener implements IEventListener { public function __construct( - readonly private IVerificationToken $verificationToken, + private readonly IVerificationToken $verificationToken, ) { } diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index ed8c57f52e5d2..9c58ba18b5174 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -1017,7 +1017,7 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array ->setValue('propertyvalue', $insert->createParameter('propertyvalue')) ->setValue('userid', $insert->createParameter('userid')); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { preg_match('/(calendar)\/([A-z0-9-@_]+)\//', $row['propertypath'], $match); $insert->setParameter('propertypath', (string)$row['propertypath']) ->setParameter('propertyname', (string)$row['propertyname']) diff --git a/core/Migrations/Version20000Date20201109081918.php b/core/Migrations/Version20000Date20201109081918.php index f85c34f47a2af..6ae20c11035db 100644 --- a/core/Migrations/Version20000Date20201109081918.php +++ b/core/Migrations/Version20000Date20201109081918.php @@ -78,7 +78,7 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array ->setValue('credentials', $insert->createParameter('credentials')); $result = $query->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { $insert->setParameter('user', (string)$row['user']) ->setParameter('identifier', (string)$row['identifier']) ->setParameter('credentials', (string)$row['credentials']); diff --git a/core/Migrations/Version28000Date20240828142927.php b/core/Migrations/Version28000Date20240828142927.php index e36c27add1c64..30382e778d344 100644 --- a/core/Migrations/Version28000Date20240828142927.php +++ b/core/Migrations/Version28000Date20240828142927.php @@ -63,7 +63,7 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array ->setFirstResult($offset) ->executeQuery(); - $jobs = $result->fetchAll(); + $jobs = $result->fetchAllAssociative(); $count = count($jobs); foreach ($jobs as $jobRow) { diff --git a/core/Migrations/Version32000Date20250731062008.php b/core/Migrations/Version32000Date20250731062008.php index 5976be55a5413..3068c47caa1cd 100644 --- a/core/Migrations/Version32000Date20250731062008.php +++ b/core/Migrations/Version32000Date20250731062008.php @@ -61,7 +61,7 @@ private function cleanupDuplicateCategories(IOutput $output): void { $seen = []; $duplicateCount = 0; - while ($category = $result->fetch()) { + while ($category = $result->fetchAssociative()) { $key = $category['uid'] . '|' . $category['type'] . '|' . $category['category']; $categoryId = (int)$category['id']; @@ -135,7 +135,7 @@ private function cleanupDuplicateAssignments(IOutput $output, int $categoryId, i $duplicatedAssignments = $selectQb->executeQuery(); $count = 0; - while ($row = $duplicatedAssignments->fetch()) { + while ($row = $duplicatedAssignments->fetchAssociative()) { $deleteQb ->setParameters($row) ->executeStatement(); diff --git a/core/Migrations/Version33000Date20251023120529.php b/core/Migrations/Version33000Date20251023120529.php index bcc6d691a7a44..5c04b3942084d 100644 --- a/core/Migrations/Version33000Date20251023120529.php +++ b/core/Migrations/Version33000Date20251023120529.php @@ -50,7 +50,7 @@ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $set = []; - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { // Iterate over all the rows with duplicated rows $id = $row['id']; @@ -65,7 +65,7 @@ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array ->andWhere($qb->expr()->neq('id', $qb->createNamedParameter($authoritativeId))); $result = $qb->executeQuery(); - while ($row = $result->fetch()) { + while ($row = $result->fetchAssociative()) { // Update previews entries to the now de-duplicated id $qb = $this->connection->getQueryBuilder(); $qb->update('previews') diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index a9aa48a6c212a..be701f3da53d8 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -82,7 +82,7 @@ public function __construct( private readonly PresetManager $presetManager, protected LoggerInterface $logger, protected ICrypto $crypto, - readonly CacheFactory $cacheFactory, + public readonly CacheFactory $cacheFactory, ) { if ($config->getSystemValueBool('cache_app_config', true) && $cacheFactory->isLocalCacheAvailable()) { $cacheFactory->withServerVersionPrefix(function (ICacheFactory $factory) { diff --git a/lib/private/DB/ArrayResult.php b/lib/private/DB/ArrayResult.php index b567ad23d577f..525b59e768d2b 100644 --- a/lib/private/DB/ArrayResult.php +++ b/lib/private/DB/ArrayResult.php @@ -9,6 +9,7 @@ namespace OC\DB; use OCP\DB\IResult; +use Override; use PDO; /** @@ -18,16 +19,19 @@ class ArrayResult implements IResult { protected int $count; public function __construct( + /** @var array $rows */ protected array $rows, ) { $this->count = count($this->rows); } + #[Override] public function closeCursor(): bool { // noop return true; } + #[Override] public function fetch(int $fetchMode = PDO::FETCH_ASSOC) { $row = array_shift($this->rows); if (!$row) { @@ -42,23 +46,22 @@ public function fetch(int $fetchMode = PDO::FETCH_ASSOC) { } + #[Override] public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array { return match ($fetchMode) { PDO::FETCH_ASSOC => $this->rows, - PDO::FETCH_NUM => array_map(function ($row) { - return array_values($row); - }, $this->rows), - PDO::FETCH_COLUMN => array_map(function ($row) { - return current($row); - }, $this->rows), + PDO::FETCH_NUM => array_map(static fn (array $row): array => array_values($row), $this->rows), + PDO::FETCH_COLUMN => array_map(static fn (array $row): mixed => current($row), $this->rows), default => throw new \InvalidArgumentException('Fetch mode not supported for array result'), }; } + #[Override] public function fetchColumn() { return $this->fetchOne(); } + #[Override] public function fetchOne() { $row = $this->fetch(); if ($row) { @@ -68,7 +71,65 @@ public function fetchOne() { } } + #[Override] + public function fetchAssociative(): array|false { + $row = $this->fetch(); + if ($row) { + /** @var array $row */ + return $row; + } else { + return false; + } + } + + #[Override] + public function fetchNumeric(): array|false { + $row = $this->fetch(PDO::FETCH_NUM); + if ($row) { + /** @var list $row */ + return $row; + } else { + return false; + } + } + + #[Override] + public function fetchAllNumeric(): array { + /** @var list> $result */ + $result = $this->fetchAll(PDO::FETCH_NUM); + return $result; + } + + #[Override] + public function fetchAllAssociative(): array { + /** @var list> $result */ + $result = $this->fetchAll(); + return $result; + } + + #[Override] + public function fetchFirstColumn(): array { + /** @var list $result */ + $result = $this->fetchAll(PDO::FETCH_COLUMN); + return $result; + } + + #[Override] public function rowCount(): int { return $this->count; } + + #[Override] + public function iterateNumeric(): \Traversable { + while (($row = $this->fetchNumeric()) !== false) { + yield $row; + } + } + + #[Override] + public function iterateAssociative(): \Traversable { + while (($row = $this->fetchAssociative()) !== false) { + yield $row; + } + } } diff --git a/lib/private/DB/ResultAdapter.php b/lib/private/DB/ResultAdapter.php index 95a7620e0ffb8..0f365b6732189 100644 --- a/lib/private/DB/ResultAdapter.php +++ b/lib/private/DB/ResultAdapter.php @@ -10,25 +10,26 @@ use Doctrine\DBAL\Result; use OCP\DB\IResult; +use Override; use PDO; /** * Adapts DBAL 2.6 API for DBAL 3.x for backwards compatibility of a leaked type */ class ResultAdapter implements IResult { - /** @var Result */ - private $inner; - - public function __construct(Result $inner) { - $this->inner = $inner; + public function __construct( + private readonly Result $inner, + ) { } + #[Override] public function closeCursor(): bool { $this->inner->free(); return true; } + #[Override] public function fetch(int $fetchMode = PDO::FETCH_ASSOC) { return match ($fetchMode) { PDO::FETCH_ASSOC => $this->inner->fetchAssociative(), @@ -38,6 +39,22 @@ public function fetch(int $fetchMode = PDO::FETCH_ASSOC) { }; } + #[Override] + public function fetchAssociative(): array|false { + return $this->inner->fetchAssociative(); + } + + #[Override] + public function fetchNumeric(): array|false { + return $this->inner->fetchNumeric(); + } + + #[Override] + public function fetchOne(): mixed { + return $this->inner->fetchOne(); + } + + #[Override] public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array { return match ($fetchMode) { PDO::FETCH_ASSOC => $this->inner->fetchAllAssociative(), @@ -47,15 +64,38 @@ public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array { }; } + #[Override] public function fetchColumn($columnIndex = 0) { return $this->inner->fetchOne(); } - public function fetchOne() { - return $this->inner->fetchOne(); - } - + #[Override] public function rowCount(): int { return $this->inner->rowCount(); } + + #[Override] + public function fetchAllAssociative(): array { + return $this->inner->fetchAllAssociative(); + } + + #[Override] + public function fetchAllNumeric(): array { + return $this->inner->fetchAllNumeric(); + } + + #[Override] + public function fetchFirstColumn(): array { + return $this->inner->fetchFirstColumn(); + } + + #[Override] + public function iterateNumeric(): \Traversable { + yield from $this->inner->iterateNumeric(); + } + + #[Override] + public function iterateAssociative(): \Traversable { + yield from $this->inner->iterateAssociative(); + } } diff --git a/lib/private/Preview/BackgroundCleanupJob.php b/lib/private/Preview/BackgroundCleanupJob.php index f6122fd0e1255..70579d3b9d1cd 100644 --- a/lib/private/Preview/BackgroundCleanupJob.php +++ b/lib/private/Preview/BackgroundCleanupJob.php @@ -22,9 +22,9 @@ class BackgroundCleanupJob extends TimedJob { public function __construct( ITimeFactory $timeFactory, - readonly private IDBConnection $connection, - readonly private PreviewService $previewService, - readonly private bool $isCLI, + private readonly IDBConnection $connection, + private readonly PreviewService $previewService, + private readonly bool $isCLI, ) { parent::__construct($timeFactory); // Run at most once an hour diff --git a/lib/private/Preview/Storage/ObjectStorePreviewStorage.php b/lib/private/Preview/Storage/ObjectStorePreviewStorage.php index 7eab3985eac2a..713d39f9b0b38 100644 --- a/lib/private/Preview/Storage/ObjectStorePreviewStorage.php +++ b/lib/private/Preview/Storage/ObjectStorePreviewStorage.php @@ -36,7 +36,7 @@ class ObjectStorePreviewStorage implements IPreviewStorage { public function __construct( private readonly PrimaryObjectStoreConfig $objectStoreConfig, IConfig $config, - readonly private PreviewMapper $previewMapper, + private readonly PreviewMapper $previewMapper, ) { $this->isMultibucketPreviewDistributionEnabled = $config->getSystemValueBool('objectstore.multibucket.preview-distribution'); } diff --git a/lib/public/DB/IResult.php b/lib/public/DB/IResult.php index 347919ab3366b..c3c4b37447060 100644 --- a/lib/public/DB/IResult.php +++ b/lib/public/DB/IResult.php @@ -8,7 +8,9 @@ */ namespace OCP\DB; +use OCP\AppFramework\Attribute\Consumable; use PDO; +use Traversable; /** * This interface represents the result of a database query. @@ -19,12 +21,15 @@ * $qb = $this->db->getQueryBuilder(); * $qb->select(...); * $result = $query->executeQuery(); - * ``` * - * This interface must not be implemented in your application. + * foreach ($result->iterateAssociative() as $row) { + * $id = $row['id']; + * } + * ``` * * @since 21.0.0 */ +#[Consumable(since: '21.0.0')] interface IResult { /** * @return true @@ -39,34 +44,78 @@ public function closeCursor(): bool; * @return mixed * * @since 21.0.0 + * @note Since 33.0.0, prefer using fetchAssociative/fetchNumeric/fetchOne or iterateAssociate/iterateNumeric instead. */ public function fetch(int $fetchMode = PDO::FETCH_ASSOC); + /** + * Returns the next row of the result as an associative array or FALSE if there are no more rows. + * + * @return array|false + * + * @since 33.0.0 + */ + public function fetchAssociative(): array|false; + + /** + * Returns the next row of the result as a numeric array or FALSE if there are no more rows. + * + * @return list|false + * + * @since 33.0.0 + */ + public function fetchNumeric(): array|false; + + /** + * Returns the first value of the next row of the result or FALSE if there are no more rows. + * + * @return false|mixed + * + * @since 21.0.0 + */ + public function fetchOne(); + /** * @param int $fetchMode (one of PDO::FETCH_ASSOC, PDO::FETCH_NUM or PDO::FETCH_COLUMN (2, 3 or 7) * * @return mixed[] * * @since 21.0.0 + * @note Since 33.0.0, prefer using fetchAllAssociative/fetchAllNumeric/fetchFirstColumn or iterateAssociate/iterateNumeric instead. */ public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array; /** - * @return mixed + * Returns an array containing all the result rows represented as associative arrays. * - * @since 21.0.0 - * @deprecated 21.0.0 use \OCP\DB\IResult::fetchOne + * @return list> + * @since 33.0.0 */ - public function fetchColumn(); + public function fetchAllAssociative(): array; /** - * Returns the first value of the next row of the result or FALSE if there are no more rows. + * Returns an array containing all the result rows represented as numeric arrays. * - * @return false|mixed + * @return list> + * @since 33.0.0 + */ + public function fetchAllNumeric(): array; + + /** + * Returns the value of the first column of all rows. + * + * @return list + * @since 33.0.0 + */ + public function fetchFirstColumn(): array; + + /** + * @return mixed * * @since 21.0.0 + * @deprecated 21.0.0 use \OCP\DB\IResult::fetchOne */ - public function fetchOne(); + public function fetchColumn(); /** * @return int @@ -74,4 +123,22 @@ public function fetchOne(); * @since 21.0.0 */ public function rowCount(): int; + + /** + * Returns an iterator over rows represented as numeric arrays. + * + * @return Traversable> + * + * @since 33.0.0 + */ + public function iterateNumeric(): Traversable; + + /** + * Returns an iterator over rows represented as associative arrays. + * + * @return Traversable> + * + * @since 33.0.0 + */ + public function iterateAssociative(): Traversable; } diff --git a/tests/lib/AllConfigTest.php b/tests/lib/AllConfigTest.php index 9c1020028b045..9eb0fc832a3a3 100644 --- a/tests/lib/AllConfigTest.php +++ b/tests/lib/AllConfigTest.php @@ -54,7 +54,7 @@ public function testDeleteUserValue(): void { $result = $this->connection->executeQuery( 'SELECT COUNT(*) AS `count` FROM `*PREFIX*preferences` WHERE `userid` = ?', ['userDelete'] - )->fetch(); + )->fetchAssociative(); $actualCount = $result['count']; $this->assertEquals(0, $actualCount, 'There was one value in the database and after the tests there should be no entry left.'); @@ -66,7 +66,7 @@ public function testSetUserValue(): void { $config->setUserValue('userSet', 'appSet', 'keySet', 'valueSet'); - $result = $this->connection->executeQuery($selectAllSQL, ['userSet'])->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userSet'])->fetchAllAssociative(); $this->assertEquals(1, count($result)); $this->assertEquals([ @@ -79,7 +79,7 @@ public function testSetUserValue(): void { // test if the method overwrites existing database entries $config->setUserValue('userSet', 'appSet', 'keySet', 'valueSet2'); - $result = $this->connection->executeQuery($selectAllSQL, ['userSet'])->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userSet'])->fetchAllAssociative(); $this->assertEquals(1, count($result)); $this->assertEquals([ @@ -103,7 +103,7 @@ public function testSetUserValueSettingsEmail(): void { $config->setUserValue('userSet', 'settings', 'email', 'mixed.CASE@domain.COM'); - $result = $this->connection->executeQuery($selectAllSQL, ['userSet'])->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userSet'])->fetchAllAssociative(); $this->assertEquals(1, count($result)); $this->assertEquals([ @@ -121,7 +121,7 @@ public function testSetUserValueWithPreCondition(): void { $config->setUserValue('userPreCond', 'appPreCond', 'keyPreCond', 'valuePreCond'); - $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond'])->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond'])->fetchAllAssociative(); $this->assertEquals(1, count($result)); $this->assertEquals([ @@ -134,7 +134,7 @@ public function testSetUserValueWithPreCondition(): void { // test if the method overwrites existing database entries with valid precond $config->setUserValue('userPreCond', 'appPreCond', 'keyPreCond', 'valuePreCond2', 'valuePreCond'); - $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond'])->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond'])->fetchAllAssociative(); $this->assertEquals(1, count($result)); $this->assertEquals([ @@ -178,7 +178,7 @@ public function testSetUserValueWithPreConditionFailure(): void { $config->setUserValue('userPreCond1', 'appPreCond', 'keyPreCond', 'valuePreCond'); - $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond1'])->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond1'])->fetchAllAssociative(); $this->assertEquals(1, count($result)); $this->assertEquals([ @@ -191,7 +191,7 @@ public function testSetUserValueWithPreConditionFailure(): void { // test if the method overwrites existing database entries with valid precond $config->setUserValue('userPreCond1', 'appPreCond', 'keyPreCond', 'valuePreCond2', 'valuePreCond3'); - $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond1'])->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond1'])->fetchAllAssociative(); $this->assertEquals(1, count($result)); $this->assertEquals([ @@ -214,7 +214,7 @@ public function testSetUserValueWithPreConditionFailureWhenResultStillMatches(): $config->setUserValue('userPreCond1', 'appPreCond', 'keyPreCond', 'valuePreCond'); - $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond1'])->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond1'])->fetchAllAssociative(); $this->assertCount(1, $result); $this->assertEquals([ @@ -227,7 +227,7 @@ public function testSetUserValueWithPreConditionFailureWhenResultStillMatches(): // test if the method throws with invalid precondition when the value is the same $config->setUserValue('userPreCond1', 'appPreCond', 'keyPreCond', 'valuePreCond', 'valuePreCond3'); - $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond1'])->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond1'])->fetchAllAssociative(); $this->assertCount(1, $result); $this->assertEquals([ @@ -278,7 +278,7 @@ public function testGetUserValue(): void { $result = $this->connection->executeQuery( 'SELECT `userid`, `appid`, `configkey`, `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ?', ['userGet'] - )->fetchAll(); + )->fetchAllAssociative(); $this->assertEquals(1, count($result)); $this->assertEquals([ @@ -299,7 +299,7 @@ public function testGetUserValue(): void { $result = $this->connection->executeQuery( 'SELECT `userid`, `appid`, `configkey`, `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ?', ['userGet'] - )->fetchAll(); + )->fetchAllAssociative(); $this->assertEquals(0, count($result)); } @@ -434,7 +434,7 @@ public function testDeleteAllUserValues(): void { $result = $this->connection->executeQuery( 'SELECT COUNT(*) AS `count` FROM `*PREFIX*preferences`' - )->fetch(); + )->fetchAssociative(); $actualCount = $result['count']; $this->assertEquals(1, $actualCount, 'After removing `userFetch3` there should be exactly 1 entry left.'); @@ -468,7 +468,7 @@ public function testDeleteAppFromAllUsers(): void { $result = $this->connection->executeQuery( 'SELECT COUNT(*) AS `count` FROM `*PREFIX*preferences`' - )->fetch(); + )->fetchAssociative(); $actualCount = $result['count']; $this->assertEquals(4, $actualCount, 'After removing `appFetch1` there should be exactly 4 entries left.'); @@ -477,7 +477,7 @@ public function testDeleteAppFromAllUsers(): void { $result = $this->connection->executeQuery( 'SELECT COUNT(*) AS `count` FROM `*PREFIX*preferences`' - )->fetch(); + )->fetchAssociative(); $actualCount = $result['count']; $this->assertEquals(2, $actualCount, 'After removing `appFetch2` there should be exactly 2 entries left.'); diff --git a/tests/lib/AppConfigIntegrationTest.php b/tests/lib/AppConfigIntegrationTest.php index 7259acb10c54d..b0e400dd9e3fc 100644 --- a/tests/lib/AppConfigIntegrationTest.php +++ b/tests/lib/AppConfigIntegrationTest.php @@ -115,7 +115,7 @@ protected function setUp(): void { $sql->select('*') ->from('appconfig'); $result = $sql->executeQuery(); - $this->originalConfig = $result->fetchAll(); + $this->originalConfig = $result->fetchAllAssociative(); $result->closeCursor(); $sql = $this->connection->getQueryBuilder(); diff --git a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php index 2f99024e0f4c6..d64c2dde81da9 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php @@ -116,7 +116,7 @@ private function getNumberOfTokens() { $result = $qb->select($qb->func()->count('*', 'count')) ->from('authtoken') ->executeQuery() - ->fetch(); + ->fetchAssociative(); return (int)$result['count']; } @@ -239,7 +239,7 @@ public function testGetById(): void { ->from('authtoken') ->where($qb->expr()->eq('token', $qb->createNamedParameter('9c5a2e661482b65597408a6bb6c4a3d1af36337381872ac56e445a06cdb7fea2b1039db707545c11027a4966919918b19d875a8b774840b18c6cbb7ae56fe206'))); $result = $qb->executeQuery(); - $id = $result->fetch()['id']; + $id = $result->fetchAssociative()['id']; $token = $this->mapper->getTokenById((int)$id); $this->assertEquals('user1', $token->getUID()); @@ -251,7 +251,7 @@ public function testDeleteByName(): void { ->from('authtoken') ->where($qb->expr()->eq('token', $qb->createNamedParameter('9c5a2e661482b65597408a6bb6c4a3d1af36337381872ac56e445a06cdb7fea2b1039db707545c11027a4966919918b19d875a8b774840b18c6cbb7ae56fe206'))); $result = $qb->executeQuery(); - $name = $result->fetch()['name']; + $name = $result->fetchAssociative()['name']; $this->mapper->deleteByName($name); $this->assertEquals(4, $this->getNumberOfTokens()); } diff --git a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php index bd52dc21821d5..81c01b7b28ba7 100644 --- a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php @@ -69,7 +69,7 @@ public function testPersist(): void { ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter('user123'))) ->andWhere($qb->expr()->eq('enabled', $qb->createNamedParameter(0))); $res = $q->executeQuery(); - $data = $res->fetchAll(); + $data = $res->fetchAllAssociative(); $res->closeCursor(); $this->assertCount(1, $data); } @@ -87,7 +87,7 @@ public function testPersistTwice(): void { ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter('user123'))) ->andWhere($qb->expr()->eq('enabled', $qb->createNamedParameter(1))); $res = $q->executeQuery(); - $data = $res->fetchAll(); + $data = $res->fetchAllAssociative(); $res->closeCursor(); $this->assertCount(1, $data); @@ -106,7 +106,7 @@ public function testPersistSameStateTwice(): void { ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter('user123'))) ->andWhere($qb->expr()->eq('enabled', $qb->createNamedParameter(1))); $res = $q->executeQuery(); - $data = $res->fetchAll(); + $data = $res->fetchAllAssociative(); $res->closeCursor(); $this->assertCount(1, $data); diff --git a/tests/lib/Calendar/ResourcesRoomsUpdaterTest.php b/tests/lib/Calendar/ResourcesRoomsUpdaterTest.php index ecad5150fb018..6d61cea0d2b88 100644 --- a/tests/lib/Calendar/ResourcesRoomsUpdaterTest.php +++ b/tests/lib/Calendar/ResourcesRoomsUpdaterTest.php @@ -216,7 +216,7 @@ public function testUpdateBoth(): void { $rows = []; $ids = []; $stmt = $query->executeQuery(); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetchAssociative()) { $ids[$row['backend_id'] . '::' . $row['resource_id']] = $row['id']; unset($row['id']); $rows[] = $row; @@ -286,7 +286,7 @@ public function testUpdateBoth(): void { $rows2 = []; $stmt = $query2->executeQuery(); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetchAssociative()) { unset($row['id']); $rows2[] = $row; } diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php index e658085478476..9672bbfcd6bda 100644 --- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php @@ -1021,7 +1021,7 @@ function ($appName, $key, $default) { $this->instantiatePlugin(IShare::TYPE_USER); - /** @var \OCP\IUser | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */ $currentUser = $this->createMock('\OCP\IUser'); $currentUser->expects($this->any()) @@ -1043,7 +1043,7 @@ function ($appName, $key, $default) { $this->groupManager->expects($this->any()) ->method('getUserGroupIds') - ->willReturnCallback(function (\OCP\IUser $user) use ($userToGroupMapping) { + ->willReturnCallback(function (IUser $user) use ($userToGroupMapping) { return $userToGroupMapping[$user->getUID()]; }); diff --git a/tests/lib/Config/UserConfigTest.php b/tests/lib/Config/UserConfigTest.php index ca51319997f35..a353f73856455 100644 --- a/tests/lib/Config/UserConfigTest.php +++ b/tests/lib/Config/UserConfigTest.php @@ -190,7 +190,7 @@ protected function setUp(): void { $sql->select('*') ->from('preferences'); $result = $sql->executeQuery(); - $this->originalPreferences = $result->fetchAll(); + $this->originalPreferences = $result->fetchAllAssociative(); $result->closeCursor(); $sql = $this->connection->getQueryBuilder(); diff --git a/tests/lib/DB/AdapterTest.php b/tests/lib/DB/AdapterTest.php index 689dbcca04dd7..09496871508ff 100644 --- a/tests/lib/DB/AdapterTest.php +++ b/tests/lib/DB/AdapterTest.php @@ -64,6 +64,142 @@ private function getRows(string $configKey): array { ->where($qb->expr()->eq('appid', $qb->createNamedParameter($this->appId))) ->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter($configKey))) ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); + } + + public function fetchAssociative(): void { + $insert = $this->connection->getQueryBuilder(); + $insert->insert('appconfig') + ->values([ + 'appid' => $this->appId, + 'configkey' => 'test', + 'configvalue' => '1', + ]) + ->executeStatement(); + + // fetch all associative + $qb = $this->connection->getQueryBuilder(); + $result = $qb->select(['configkey', 'configvalue', 'appid']) + ->from('appconfig') + ->executeQuery(); + + $rows = $result->fetchAllAssociative(); + $this->assertEquals([ + [ + 'appid' => $this->appId, + 'configkey' => 'test', + 'configvalue' => '1', + ] + ], $rows); + + // fetch associative + $qb = $this->connection->getQueryBuilder(); + $result = $qb->select(['configkey', 'configvalue', 'appid']) + ->from('appconfig') + ->executeQuery(); + $row = $result->fetchAssociative(); + $this->assertEquals([ + 'appid' => $this->appId, + 'configkey' => 'test', + 'configvalue' => '1', + ], $row); + + // iterate associative + $qb = $this->connection->getQueryBuilder(); + $result = $qb->select(['configkey', 'configvalue', 'appid']) + ->from('appconfig') + ->executeQuery(); + $row = iterator_to_array($result->iterateAssociative()); + $this->assertEquals([ + 'appid' => $this->appId, + 'configkey' => 'test', + 'configvalue' => '1', + ], $row); + } + + public function fetchNumeric(): void { + $insert = $this->connection->getQueryBuilder(); + $insert->insert('appconfig') + ->values([ + 'appid' => $this->appId, + 'configkey' => 'test', + 'configvalue' => '1', + ]) + ->executeStatement(); + + // fetch all associative + $qb = $this->connection->getQueryBuilder(); + $result = $qb->select(['configkey', 'configvalue', 'appid']) + ->from('appconfig') + ->executeQuery(); + + $rows = $result->fetchAllNumeric(); + $this->assertEquals([ + [ + 0 => $this->appId, + 1 => 'test', + 2 => '1', + ] + ], $rows); + + // fetch associative + $qb = $this->connection->getQueryBuilder(); + $result = $qb->select(['configkey', 'configvalue', 'appid']) + ->from('appconfig') + ->executeQuery(); + $row = $result->fetchNumeric(); + $this->assertEquals([ + 0 => $this->appId, + 1 => 'test', + 2 => '1', + ], $row); + + // iterate associative + $qb = $this->connection->getQueryBuilder(); + $result = $qb->select(['configkey', 'configvalue', 'appid']) + ->from('appconfig') + ->executeQuery(); + $row = iterator_to_array($result->iterateNumeric()); + $this->assertEquals([ + 0 => $this->appId, + 1 => 'test', + 2 => '1', + ], $row); + } + + public function fetchOne(): void { + $insert = $this->connection->getQueryBuilder(); + $insert->insert('appconfig') + ->values([ + 'appid' => $this->appId, + 'configkey' => 'test', + 'configvalue' => '1', + ]) + ->executeStatement(); + + // fetch all associative + $qb = $this->connection->getQueryBuilder(); + $result = $qb->select(['configkey', 'configvalue', 'appid']) + ->from('appconfig') + ->executeQuery(); + + $rows = $result->fetchFirstColumn(); + $this->assertEquals($this->appId, $rows); + + // fetch associative + $qb = $this->connection->getQueryBuilder(); + $result = $qb->select(['configkey', 'configvalue', 'appid']) + ->from('appconfig') + ->executeQuery(); + $row = $result->fetchFirstColumn(); + $this->assertEquals($this->appId, $row); + + // iterate associative + $qb = $this->connection->getQueryBuilder(); + $result = $qb->select(['configkey', 'configvalue', 'appid']) + ->from('appconfig') + ->executeQuery(); + $rows = iterator_to_array($result->iterateNumeric()); + $this->assertEquals([$this->appId], $rows); } } diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php index 112bfe2ca162d..4d0cd853d8ff2 100644 --- a/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php +++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php @@ -135,7 +135,7 @@ public function testLongText(): void { ->andWhere($query->expr()->eq('configvalue', $query->createNamedParameter('myvalue', IQueryBuilder::PARAM_STR), IQueryBuilder::PARAM_STR)); $result = $query->executeQuery(); - $entries = $result->fetchAll(); + $entries = $result->fetchAllAssociative(); $result->closeCursor(); self::assertCount(1, $entries); self::assertEquals('myvalue', $entries[0]['configvalue']); @@ -153,7 +153,7 @@ public function testDateTimeEquals(): void { ->from('testing') ->where($query->expr()->eq('datetime', $query->createNamedParameter($dateTime, IQueryBuilder::PARAM_DATETIME_MUTABLE))) ->executeQuery(); - $entries = $result->fetchAll(); + $entries = $result->fetchAllAssociative(); $result->closeCursor(); self::assertCount(1, $entries); } @@ -171,7 +171,7 @@ public function testDateTimeLess(): void { ->from('testing') ->where($query->expr()->lt('datetime', $query->createNamedParameter($dateTimeCompare, IQueryBuilder::PARAM_DATETIME_MUTABLE))) ->executeQuery(); - $entries = $result->fetchAll(); + $entries = $result->fetchAllAssociative(); $result->closeCursor(); self::assertCount(1, $entries); } @@ -189,7 +189,7 @@ public function testDateTimeGreater(): void { ->from('testing') ->where($query->expr()->gt('datetime', $query->createNamedParameter($dateTimeCompare, IQueryBuilder::PARAM_DATETIME_MUTABLE))) ->executeQuery(); - $entries = $result->fetchAll(); + $entries = $result->fetchAllAssociative(); $result->closeCursor(); self::assertCount(1, $entries); } diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php index 4adf6618e8159..5effc2f14692f 100644 --- a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php @@ -409,7 +409,7 @@ public function testClobComparisons($function, $value, $type, $compareKeyToValue $result = $query->executeQuery(); - $this->assertEquals(['count' => $expected], $result->fetch()); + $this->assertEquals(['count' => $expected], $result->fetchAssociative()); $result->closeCursor(); $query = $this->connection->getQueryBuilder(); diff --git a/tests/lib/Files/Cache/SearchBuilderTest.php b/tests/lib/Files/Cache/SearchBuilderTest.php index 28fe6aefc77c1..aa936598a96fd 100644 --- a/tests/lib/Files/Cache/SearchBuilderTest.php +++ b/tests/lib/Files/Cache/SearchBuilderTest.php @@ -129,7 +129,7 @@ private function search(ISearchOperator $operator) { $this->builder->andWhere($dbOperator); $result = $this->builder->executeQuery(); - $rows = $result->fetchAll(\PDO::FETCH_COLUMN); + $rows = $result->fetchFirstColumn(); $result->closeCursor(); return $rows; diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php index 31a2ea369984b..c0a419aaa084a 100644 --- a/tests/lib/Files/Config/UserMountCacheTest.php +++ b/tests/lib/Files/Config/UserMountCacheTest.php @@ -413,7 +413,7 @@ private function createCacheEntry($internalPath, $storageId, $size = 0) { ->from('filecache') ->where($query->expr()->eq('storage', $query->createNamedParameter($storageId))) ->andWhere($query->expr()->eq('path_hash', $query->createNamedParameter(md5($internalPath)))); - $id = (int)$query->executeQuery()->fetchColumn(); + $id = (int)$query->executeQuery()->fetchOne(); } else { throw $e; } diff --git a/tests/lib/Files/Template/TemplateManagerTest.php b/tests/lib/Files/Template/TemplateManagerTest.php index fcd7ca1aa92a8..be65657aba967 100644 --- a/tests/lib/Files/Template/TemplateManagerTest.php +++ b/tests/lib/Files/Template/TemplateManagerTest.php @@ -13,6 +13,7 @@ use OC\AppFramework\Bootstrap\RegistrationContext; use OC\Files\FilenameValidator; use OC\Files\Template\TemplateManager; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Folder; use OCP\Files\GenericFileException; use OCP\Files\IRootFolder; @@ -21,6 +22,9 @@ use OCP\IDBConnection; use OCP\IL10N; use OCP\IPreview; +use OCP\IServerContainer; +use OCP\IUserManager; +use OCP\IUserSession; use OCP\L10N\IFactory; use Psr\Log\NullLogger; use Test\TestCase; @@ -53,14 +57,14 @@ protected function setUp(): void { $logger, ); - $serverContainer = $this->createMock(\OCP\IServerContainer::class); - $eventDispatcher = $this->createMock(\OCP\EventDispatcher\IEventDispatcher::class); + $serverContainer = $this->createMock(IServerContainer::class); + $eventDispatcher = $this->createMock(IEventDispatcher::class); $this->bootstrapCoordinator = $this->createMock(Coordinator::class); $this->bootstrapCoordinator->method('getRegistrationContext') ->willReturn(new RegistrationContext($logger)); $this->rootFolder = $this->createMock(IRootFolder::class); - $userSession = $this->createMock(\OCP\IUserSession::class); - $userManager = $this->createMock(\OCP\IUserManager::class); + $userSession = $this->createMock(IUserSession::class); + $userManager = $this->createMock(IUserManager::class); $previewManager = $this->createMock(IPreview::class); $this->templateManager = new TemplateManager( diff --git a/tests/lib/Files/Type/LoaderTest.php b/tests/lib/Files/Type/LoaderTest.php index a2edcd0bcf8ef..1c9ffb65a31ad 100644 --- a/tests/lib/Files/Type/LoaderTest.php +++ b/tests/lib/Files/Type/LoaderTest.php @@ -64,7 +64,7 @@ public function testStore(): void { ->where($qb->expr()->eq('id', $qb->createPositionalParameter($mimetypeId))); $result = $qb->executeQuery(); - $mimetype = $result->fetch(); + $mimetype = $result->fetchAssociative(); $result->closeCursor(); $this->assertEquals('testing/mymimetype', $mimetype['mimetype']); diff --git a/tests/lib/Repair/OldGroupMembershipSharesTest.php b/tests/lib/Repair/OldGroupMembershipSharesTest.php index a385c1c9fc000..6eb1a63fd4e41 100644 --- a/tests/lib/Repair/OldGroupMembershipSharesTest.php +++ b/tests/lib/Repair/OldGroupMembershipSharesTest.php @@ -76,7 +76,7 @@ public function testRun(): void { ->from('share') ->orderBy('id', 'ASC') ->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $this->assertEquals([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member], ['id' => $notAMember]], $rows); $result->closeCursor(); @@ -92,7 +92,7 @@ public function testRun(): void { ->from('share') ->orderBy('id', 'ASC') ->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $this->assertEquals([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member]], $rows); $result->closeCursor(); } diff --git a/tests/lib/Repair/Owncloud/UpdateLanguageCodesTest.php b/tests/lib/Repair/Owncloud/UpdateLanguageCodesTest.php index 2c735b7bc6df2..7773fac7f5925 100644 --- a/tests/lib/Repair/Owncloud/UpdateLanguageCodesTest.php +++ b/tests/lib/Repair/Owncloud/UpdateLanguageCodesTest.php @@ -74,7 +74,7 @@ public function testRun(): void { ->orderBy('userid') ->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $result->closeCursor(); $this->assertSame($users, $rows, 'Asserts that the entries are the ones from the test data set'); @@ -115,7 +115,7 @@ public function testRun(): void { ->orderBy('userid') ->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $result->closeCursor(); // value has changed for one user diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php index 2171a34a6f07e..3ffb1726e19a1 100644 --- a/tests/lib/Repair/RepairInvalidSharesTest.php +++ b/tests/lib/Repair/RepairInvalidSharesTest.php @@ -104,7 +104,7 @@ public function testSharesNonExistingParent(): void { ->from('share') ->orderBy('id', 'ASC') ->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $this->assertEquals([['id' => $parent], ['id' => $validChild], ['id' => $invalidChild]], $rows); $result->closeCursor(); @@ -120,7 +120,7 @@ public function testSharesNonExistingParent(): void { ->from('share') ->orderBy('id', 'ASC') ->executeQuery(); - $rows = $result->fetchAll(); + $rows = $result->fetchAllAssociative(); $this->assertEquals([['id' => $parent], ['id' => $validChild]], $rows); $result->closeCursor(); } @@ -180,7 +180,7 @@ public function testFileSharePermissions($itemType, $testPerms, $expectedPerms): ->from('share') ->orderBy('permissions', 'ASC') ->executeQuery() - ->fetchAll(); + ->fetchAllAssociative(); $this->assertCount(1, $results); diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index d79dbbada3d84..2ceb77aeb5008 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -494,7 +494,7 @@ public function testDeleteSingleShare(): void { ->from('share'); $cursor = $qb->executeQuery(); - $result = $cursor->fetchAll(); + $result = $cursor->fetchAllAssociative(); $cursor->closeCursor(); $this->assertEmpty($result); @@ -527,7 +527,7 @@ public function testDeleteSingleShareLazy(): void { ->from('share'); $cursor = $qb->executeQuery(); - $result = $cursor->fetchAll(); + $result = $cursor->fetchAllAssociative(); $cursor->closeCursor(); $this->assertEmpty($result); @@ -592,7 +592,7 @@ public function testDeleteGroupShareWithUserGroupShares(): void { ->from('share'); $cursor = $qb->executeQuery(); - $result = $cursor->fetchAll(); + $result = $cursor->fetchAllAssociative(); $cursor->closeCursor(); $this->assertEmpty($result); @@ -1553,7 +1553,7 @@ public function testDeleteFromSelfGroupNoCustomShare(): void { ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(2))) ->executeQuery(); - $shares = $stmt->fetchAll(); + $shares = $stmt->fetchAllAssociative(); $stmt->closeCursor(); $this->assertCount(1, $shares); @@ -1625,7 +1625,7 @@ public function testDeleteFromSelfGroupAlreadyCustomShare(): void { ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(2))) ->executeQuery(); - $shares = $stmt->fetchAll(); + $shares = $stmt->fetchAllAssociative(); $stmt->closeCursor(); $this->assertCount(1, $shares); @@ -1763,7 +1763,7 @@ public function testDeleteFromSelfUser(): void { ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) ->executeQuery(); - $shares = $stmt->fetchAll(); + $shares = $stmt->fetchAllAssociative(); $stmt->closeCursor(); $this->assertCount(0, $shares); @@ -2188,7 +2188,7 @@ function ($groupId) use ($groups) { ->orderBy('id') ->executeQuery(); - $shares = $stmt->fetchAll(); + $shares = $stmt->fetchAllAssociative(); $this->assertSame('user0', $shares[0]['share_with']); $this->assertSame('user4', $shares[0]['uid_initiator']); @@ -2329,7 +2329,7 @@ public function testDeleteUser($type, $owner, $initiator, $recipient, $deletedUs $qb->expr()->eq('id', $qb->createNamedParameter($id)) ); $cursor = $qb->executeQuery(); - $data = $cursor->fetchAll(); + $data = $cursor->fetchAllAssociative(); $cursor->closeCursor(); $this->assertCount($rowDeleted ? 0 : 1, $data); @@ -2388,7 +2388,7 @@ public function testDeleteUserGroup($owner, $initiator, $recipient, $deletedUser $qb->expr()->eq('id', $qb->createNamedParameter($userGroupId)) ); $cursor = $qb->executeQuery(); - $data = $cursor->fetchAll(); + $data = $cursor->fetchAllAssociative(); $cursor->closeCursor(); $this->assertCount($userGroupShareDeleted ? 0 : 1, $data); @@ -2399,7 +2399,7 @@ public function testDeleteUserGroup($owner, $initiator, $recipient, $deletedUser $qb->expr()->eq('id', $qb->createNamedParameter($groupId)) ); $cursor = $qb->executeQuery(); - $data = $cursor->fetchAll(); + $data = $cursor->fetchAllAssociative(); $cursor->closeCursor(); $this->assertCount($groupShareDeleted ? 0 : 1, $data); } @@ -2492,7 +2492,7 @@ public function testGroupDeleted($shares, $groupToDelete, $shouldBeDeleted): voi ->from('share') ->where($qb->expr()->in('id', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) ->executeQuery(); - $data = $cursor->fetchAll(); + $data = $cursor->fetchAllAssociative(); $cursor->closeCursor(); $this->assertCount($shouldBeDeleted ? 0 : count($ids), $data); @@ -2550,7 +2550,7 @@ public function testUserDeletedFromGroup($group, $user, $toDelete): void { ->from('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($id2))); $cursor = $qb->executeQuery(); - $data = $cursor->fetchAll(); + $data = $cursor->fetchAllAssociative(); $cursor->closeCursor(); $this->assertCount($toDelete ? 0 : 1, $data); diff --git a/tests/lib/SubAdminTest.php b/tests/lib/SubAdminTest.php index 4c0b1c3343435..1446cab040d87 100644 --- a/tests/lib/SubAdminTest.php +++ b/tests/lib/SubAdminTest.php @@ -111,7 +111,7 @@ public function testCreateSubAdmin(): void { ->where($qb->expr()->eq('gid', $qb->createNamedParameter($this->groups[0]->getGID()))) ->andWHere($qb->expr()->eq('uid', $qb->createNamedParameter($this->users[0]->getUID()))) ->executeQuery() - ->fetch(); + ->fetchAssociative(); $this->assertEquals( [ 'gid' => $this->groups[0]->getGID(), @@ -137,7 +137,7 @@ public function testDeleteSubAdmin(): void { ->where($qb->expr()->eq('gid', $qb->createNamedParameter($this->groups[0]->getGID()))) ->andWHere($qb->expr()->eq('uid', $qb->createNamedParameter($this->users[0]->getUID()))) ->executeQuery() - ->fetch(); + ->fetchAssociative(); $this->assertEmpty($result); }