Compare commits

..

22 Commits

Author SHA1 Message Date
Chandrika Mohan 65316c3391 fix(settings): correctly detect Chrome on Android in devices & sessions
Signed-off-by: Chandrika Mohan <chandrikalov@gmail.com>

common logic to detect ua

Signed-off-by: Chandrika Mohan <chandrikalov@gmail.com>
2026-03-18 16:07:41 +01:00
Louis 56dcfc4b86 Merge pull request #45036 from iLinaza/fix/45034-clear-cached-user-groups-on-pre-hooks
fix(usergroups): clear cached user groups on pre hooks
2026-03-12 16:03:44 +01:00
Benjamin Gaussorgues 7a96dbc20c Merge pull request #58875 from nextcloud/chore/update-ignred-files 2026-03-12 15:35:49 +01:00
Benjamin Gaussorgues 8c6d314b0e Merge pull request #58798 from AIlkiv/fix-UserMountCache-for-postgresql 2026-03-12 12:11:29 +01:00
Kate ddf79066b9 Merge pull request #58689 from nextcloud/fix/federated-reshare 2026-03-12 12:01:24 +01:00
Sebastian Krupinski ed3a230403 Merge pull request #58679 from nextcloud/feat/add-default-reminder-setting-caldav
feat: add default reminder setting caldav
2026-03-12 06:26:12 -04:00
provokateurin 5dbbe2ccf9 fix(dav): Use share initiator to get the share node, because the owner might on another server
Signed-off-by: provokateurin <kate@provokateurin.de>
2026-03-12 10:31:25 +01:00
provokateurin 045ad43237 fix(federatedfilesharing): Do not set the share id for an existing share
Signed-off-by: provokateurin <kate@provokateurin.de>
2026-03-12 10:31:25 +01:00
Carl Schwan 83956e9f04 Merge pull request #58854 from nextcloud/jtr/refactor-View-getLocalFile
refactor(view): `getLocalFile` path handling
2026-03-12 10:05:19 +01:00
Kate c8380b1b62 Merge pull request #58869 from nextcloud/fix/pwd-confirmation 2026-03-12 09:54:15 +01:00
Nextcloud bot 5ff62d5baf fix(l10n): Update translations from Transifex
Signed-off-by: Nextcloud bot <bot@nextcloud.com>
2026-03-12 00:19:26 +00:00
Josh eb5a9085ee Merge pull request #58855 from nextcloud/jtr/test-drop-testTouchFloat
tests - Fix `Implicit conversion from float 500.5 to int loses precision` in ViewTest
2026-03-11 15:07:57 -04:00
Benjamin Gaussorgues e07be2b189 chore(buuld): update list of ignored files
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
2026-03-11 17:50:11 +01:00
Grigory Vodyanov e3c2920c18 feat: add default reminder setting caldav
Signed-off-by: Grigory Vodyanov <scratchx@gmx.com>
2026-03-11 12:45:04 -04:00
Ferdinand Thiessen 9b54b06de5 fix(SecurityMiddleware): return header to distinguish error type
Currently we return a 403 (Forbidden) when the password confirmation
failed - which itself seems to be inappropriate as its basically a login
failing so a 401 (not authorized) is more appropriate.

This is especially a problem because APIs might return 403 internally
for good reason (e.g. user missing permission) but 401 would not be a
problem.

But as this is a breaking change so my solution to be able to
distinguish API error from password confirmation error is:

Add a header inside the response that marks failed password confirmation
`X-NC-Auth-NotConfirmed`.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2026-03-11 15:11:29 +01:00
Josh 8895970019 test(ViewTest): disable Nextcloud not PHP - drop testTouchFloat()
Our interface contract (and implementations) in IStorage are:
`public function touch(string $path, ?int $mtime = null): bool {`

This wasn't always the case but it is today, so testTouchFloat() no longer makes sense; it's not testing our code, just PHP.

Signed-off-by: Josh <josh.t.richards@gmail.com>
2026-03-10 22:12:42 -04:00
Josh 0a7420d0a4 chore(View): fixup for php-cs
Signed-off-by: Josh <josh.t.richards@gmail.com>
2026-03-10 21:40:44 -04:00
Josh 14e837ce11 refactor(View): add typing to getAbsolutePath and clarify contract
Signed-off-by: Josh <josh.t.richards@gmail.com>
2026-03-10 19:42:16 -04:00
Josh af78da59bc refactor(View): improve readability of getLocalFile and resolvePath
Signed-off-by: Josh <josh.t.richards@gmail.com>
2026-03-10 19:21:47 -04:00
ailkiv e958fa0113 fix: PostgreSQL transaction aborts when caching user mounts
Signed-off-by: ailkiv <a.ilkiv.ye@gmail.com>
2026-03-09 10:02:40 +00:00
Côme Chilliet 842f3a44cb Merge branch 'master' into fix/45034-clear-cached-user-groups-on-pre-hooks
Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
2026-03-05 16:00:17 +01:00
iLinaza d33cac0a2f fix: #45034 clear cached user groups on pre hooks
Signed-off-by: iLinaza <i.linaza@gmail.com>
2024-04-25 16:49:56 +02:00
106 changed files with 807 additions and 619 deletions
+29
View File
@@ -4,6 +4,7 @@
# Global exclude
.editorconfig
.envrc
.git
.git-blame-ignore-revs
.gitattributes
@@ -11,12 +12,40 @@
.gitignore
.gitmodules
.idea
.jshint
.l10nignore
.mailmap
.nextcloudignore
.noopenapi
.npmignore
.php-cs-fixer*
.pre-commit-config.yaml
.tag
.tx
CHANGELOG.md
CODE_OF_CONDUCT.md
COPYING-README
DESIGN.md
Makefile
README.md
SECURITY.md
codecov.yml
cs-fixer
csfixer
cypress
eslint.config.js
flake.lock
flake.nix
openapi-extractor
phpunit
psalm
psalm*.xml
rector
stylelint.config.js
tests
tsconfig.json
vitest.config.ts
window.d.ts
# Server specific
/.devcontainer
+1 -1
View File
@@ -10,7 +10,7 @@
<name>WebDAV</name>
<summary>WebDAV endpoint</summary>
<description>WebDAV endpoint</description>
<version>1.37.0</version>
<version>1.38.0</version>
<licence>agpl</licence>
<author>owncloud.org</author>
<namespace>DAV</namespace>
+1 -2
View File
@@ -92,7 +92,6 @@ $server = $serverFactory->createServer(
}
$share = $authBackend->getShare();
$owner = $share->getShareOwner();
$isReadable = $share->getPermissions() & Constants::PERMISSION_READ;
$fileId = $share->getNodeId();
@@ -107,7 +106,7 @@ $server = $serverFactory->createServer(
Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
$rootFolder = Server::get(IRootFolder::class);
$userFolder = $rootFolder->getUserFolder($owner);
$userFolder = $rootFolder->getUserFolder($share->getSharedBy());
$node = $userFolder->getFirstNodeById($fileId);
if (!$node) {
throw new \Sabre\DAV\Exception\NotFound();
+1 -2
View File
@@ -99,7 +99,6 @@ $server = $serverFactory->createServer(true, $baseuri, $requestUri, $authPlugin,
}
$share = $authBackend->getShare();
$owner = $share->getShareOwner();
$isReadable = $share->getPermissions() & Constants::PERMISSION_READ;
$fileId = $share->getNodeId();
@@ -135,7 +134,7 @@ $server = $serverFactory->createServer(true, $baseuri, $requestUri, $authPlugin,
Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
$rootFolder = Server::get(IRootFolder::class);
$userFolder = $rootFolder->getUserFolder($owner);
$userFolder = $rootFolder->getUserFolder($share->getSharedBy());
$node = $userFolder->getFirstNodeById($fileId);
if (!$node) {
throw new NotFound();
@@ -389,6 +389,7 @@ return array(
'OCA\\DAV\\Migration\\Version1034Date20250605132605' => $baseDir . '/../lib/Migration/Version1034Date20250605132605.php',
'OCA\\DAV\\Migration\\Version1034Date20250813093701' => $baseDir . '/../lib/Migration/Version1034Date20250813093701.php',
'OCA\\DAV\\Migration\\Version1036Date20251202000000' => $baseDir . '/../lib/Migration/Version1036Date20251202000000.php',
'OCA\\DAV\\Migration\\Version1038Date20260302000000' => $baseDir . '/../lib/Migration/Version1038Date20260302000000.php',
'OCA\\DAV\\Model\\ExampleEvent' => $baseDir . '/../lib/Model/ExampleEvent.php',
'OCA\\DAV\\Paginate\\LimitedCopyIterator' => $baseDir . '/../lib/Paginate/LimitedCopyIterator.php',
'OCA\\DAV\\Paginate\\PaginateCache' => $baseDir . '/../lib/Paginate/PaginateCache.php',
@@ -404,6 +404,7 @@ class ComposerStaticInitDAV
'OCA\\DAV\\Migration\\Version1034Date20250605132605' => __DIR__ . '/..' . '/../lib/Migration/Version1034Date20250605132605.php',
'OCA\\DAV\\Migration\\Version1034Date20250813093701' => __DIR__ . '/..' . '/../lib/Migration/Version1034Date20250813093701.php',
'OCA\\DAV\\Migration\\Version1036Date20251202000000' => __DIR__ . '/..' . '/../lib/Migration/Version1036Date20251202000000.php',
'OCA\\DAV\\Migration\\Version1038Date20260302000000' => __DIR__ . '/..' . '/../lib/Migration/Version1038Date20260302000000.php',
'OCA\\DAV\\Model\\ExampleEvent' => __DIR__ . '/..' . '/../lib/Model/ExampleEvent.php',
'OCA\\DAV\\Paginate\\LimitedCopyIterator' => __DIR__ . '/..' . '/../lib/Paginate/LimitedCopyIterator.php',
'OCA\\DAV\\Paginate\\PaginateCache' => __DIR__ . '/..' . '/../lib/Paginate/PaginateCache.php',
+3 -6
View File
@@ -151,6 +151,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
'{http://apple.com/ns/ical/}calendar-order' => ['calendarorder', 'int'],
'{http://apple.com/ns/ical/}calendar-color' => ['calendarcolor', 'string'],
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}deleted-at' => ['deleted_at', 'int'],
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}default-alarm' => ['default_alarm', 'int'],
];
/**
@@ -1570,12 +1571,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
}
if ($forceDeletePermanently || $this->config->getAppValue(Application::APP_ID, RetentionService::RETENTION_CONFIG_KEY) === '0') {
$qb = $this->db->getQueryBuilder();
$qb->delete('calendarobjects')
->where($qb->expr()->eq('calendarid', $qb->createNamedParameter($calendarId)))
->andWhere($qb->expr()->eq('uri', $qb->createNamedParameter($objectUri)))
->andWhere($qb->expr()->eq('calendartype', $qb->createNamedParameter($calendarType)))
->executeStatement();
$stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarobjects` WHERE `calendarid` = ? AND `uri` = ? AND `calendartype` = ?');
$stmt->execute([$calendarId, $objectUri, $calendarType]);
$this->purgeProperties($calendarId, $data['id']);
@@ -43,7 +43,7 @@ class PublicLinkCheckPlugin extends ServerPlugin {
}
public function beforeMethod(RequestInterface $request, ResponseInterface $response) {
// verify that the owner didn't have their share permissions revoked
// verify that the initiator didn't have their share permissions revoked
if ($this->fileInfo && !$this->fileInfo->isShareable()) {
throw new NotFound();
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\Attributes\AddColumn;
use OCP\Migration\Attributes\ColumnType;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
#[AddColumn(table: 'calendars', name: 'default_alarm', type: ColumnType::STRING)]
class Version1038Date20260302000000 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$calendarsTable = $schema->getTable('calendars');
if (!$calendarsTable->hasColumn('default_alarm')) {
$calendarsTable->addColumn('default_alarm', Types::INTEGER, [
'notnull' => false,
'default' => null,
]);
}
return $schema;
}
}
@@ -1881,4 +1881,43 @@ EOD;
);
}
public function testDefaultAlarmProperty(): void {
$calendarId = $this->createTestCalendar();
// Test setting default alarm property to 15 minutes before (-900 seconds)
$patch = new PropPatch([
'{http://nextcloud.com/ns}default-alarm' => -900
]);
$this->backend->updateCalendar($calendarId, $patch);
$patch->commit();
// Verify the property was set
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
$this->assertCount(1, $calendars);
$this->assertEquals(-900, $calendars[0]['{http://nextcloud.com/ns}default-alarm']);
// Test updating to a different value (1 day before = -86400 seconds)
$patch = new PropPatch([
'{http://nextcloud.com/ns}default-alarm' => -86400
]);
$this->backend->updateCalendar($calendarId, $patch);
$patch->commit();
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
$this->assertEquals(-86400, $calendars[0]['{http://nextcloud.com/ns}default-alarm']);
// Test setting to "none"
$patch = new PropPatch([
'{http://nextcloud.com/ns}default-alarm' => null
]);
$this->backend->updateCalendar($calendarId, $patch);
$patch->commit();
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
$this->assertEquals(null, $calendars[0]['{http://nextcloud.com/ns}default-alarm']);
// Clean up
$this->backend->deleteCalendar($calendars[0]['id'], true);
}
}
@@ -128,30 +128,30 @@ class FederatedShareProvider implements IShareProvider, IShareProviderSupportsAl
$share->setSharedWith($cloudId->getId());
try {
$remoteShare = $this->getShareFromExternalShareTable($share);
$remoteShare = $this->getShareFromExternalShareTable($share->getShareOwner(), $share->getTarget());
} catch (ShareNotFound $e) {
$remoteShare = null;
}
if ($remoteShare) {
try {
$ownerCloudId = $this->cloudIdManager->getCloudId($remoteShare['owner'], $remoteShare['remote']);
$shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time(), $shareType, $expirationDate);
$share->setId($shareId);
[$token, $remoteId] = $this->askOwnerToReShare($shareWith, $share, $shareId);
// remote share was create successfully if we get a valid token as return
$send = is_string($token) && $token !== '';
} catch (\Exception $e) {
// fall back to old re-share behavior if the remote server
// doesn't support flat re-shares (was introduced with Nextcloud 9.1)
$this->removeShareFromTable($share);
$shareId = $this->createFederatedShare($share);
}
if ($send) {
$ownerCloudId = $this->cloudIdManager->getCloudId($remoteShare['owner'], $remoteShare['remote']);
$shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time(), $shareType, $expirationDate);
[$token, $remoteId] = $this->notifications->requestReShare(
$remoteShare['share_token'],
$remoteShare['remote_id'],
$shareId,
$remoteShare['remote'],
$shareWith,
$permissions,
$share->getNode()->getName(),
$shareType,
);
// remote share was create successfully if we get a valid token as return
if (is_string($token) && $token !== '') {
$this->updateSuccessfulReshare($shareId, $token);
$this->storeRemoteId($shareId, $remoteId);
} else {
$this->removeShareFromTable($share);
$this->removeShareFromTable($shareId);
$message_t = $this->l->t('File is already shared with %s', [$shareWith]);
throw new \Exception($message_t);
}
@@ -216,7 +216,7 @@ class FederatedShareProvider implements IShareProvider, IShareProviderSupportsAl
}
if ($failure) {
$this->removeShareFromTableById($shareId);
$this->removeShareFromTable($shareId);
$message_t = $this->l->t('Sharing %1$s failed, could not find %2$s, maybe the server is currently unreachable or uses a self-signed certificate.',
[$share->getNode()->getName(), $share->getSharedWith()]);
throw new \Exception($message_t);
@@ -225,45 +225,17 @@ class FederatedShareProvider implements IShareProvider, IShareProviderSupportsAl
return $shareId;
}
/**
* @param string $shareWith
* @param IShare $share
* @param string $shareId internal share Id
* @return array
* @throws \Exception
*/
protected function askOwnerToReShare($shareWith, IShare $share, $shareId) {
$remoteShare = $this->getShareFromExternalShareTable($share);
$token = $remoteShare['share_token'];
$remoteId = $remoteShare['remote_id'];
$remote = $remoteShare['remote'];
[$token, $remoteId] = $this->notifications->requestReShare(
$token,
$remoteId,
$shareId,
$remote,
$shareWith,
$share->getPermissions(),
$share->getNode()->getName(),
$share->getShareType(),
);
return [$token, $remoteId];
}
/**
* get federated share from the share_external table but exclude mounted link shares
*
* @param IShare $share
* @return array
* @throws ShareNotFound
*/
protected function getShareFromExternalShareTable(IShare $share) {
protected function getShareFromExternalShareTable(string $owner, string $target) {
$query = $this->dbConnection->getQueryBuilder();
$query->select('*')->from($this->externalShareTable)
->where($query->expr()->eq('user', $query->createNamedParameter($share->getShareOwner())))
->andWhere($query->expr()->eq('mountpoint', $query->createNamedParameter($share->getTarget())));
->where($query->expr()->eq('user', $query->createNamedParameter($owner)))
->andWhere($query->expr()->eq('mountpoint', $query->createNamedParameter($target)));
$qResult = $query->executeQuery();
$result = $qResult->fetchAllAssociative();
$qResult->closeCursor();
@@ -468,7 +440,7 @@ class FederatedShareProvider implements IShareProvider, IShareProviderSupportsAl
// only remove the share when all messages are send to not lose information
// about the share to early
$this->removeShareFromTable($share);
$this->removeShareFromTable($share->getId());
}
/**
@@ -493,19 +465,10 @@ class FederatedShareProvider implements IShareProvider, IShareProviderSupportsAl
}
}
/**
* remove share from table
*
* @param IShare $share
*/
public function removeShareFromTable(IShare $share) {
$this->removeShareFromTableById($share->getId());
}
/**
* Remove share from table.
*/
private function removeShareFromTableById(string $shareId): void {
public function removeShareFromTable(string $shareId): void {
$qb = $this->dbConnection->getQueryBuilder();
$qb->delete('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($shareId)))
@@ -382,7 +382,7 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider {
* @throws ShareNotFound
*/
protected function executeDeclineShare(IShare $share): void {
$this->federatedShareProvider->removeShareFromTable($share);
$this->federatedShareProvider->removeShareFromTable($share->getId());
$user = $this->getCorrectUser($share);
@@ -420,7 +420,7 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider {
$share = $this->federatedShareProvider->getShareById($id);
$this->verifyShare($share, $token);
$this->federatedShareProvider->removeShareFromTable($share);
$this->federatedShareProvider->removeShareFromTable($share->getId());
return [];
}
@@ -249,18 +249,18 @@ class FederatedShareProviderReshareRemoteTest extends \Test\TestCase {
$qb6->method('executeQuery')->willReturn($result6);
$queryBuilderMatcher = $this->exactly(8);
$queryBuilderMatcher = $this->exactly(7);
$this->connection
->expects($queryBuilderMatcher)
->method('getQueryBuilder')
->willReturnCallback(function () use ($queryBuilderMatcher, $qb1, $qb2, $qb3, $qb4, $qb5, $qb6) {
return match ($queryBuilderMatcher->numberOfInvocations()) {
1, 2 => $qb1,
3, 5 => $qb2,
3 => $qb2,
4 => $qb3,
6 => $qb4,
7 => $qb5,
8 => $qb6,
5 => $qb4,
6 => $qb5,
7 => $qb6,
default => throw new LogicException('Unexpected number of invocations for getQueryBuilder')
};
});
@@ -133,7 +133,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setExpirationDate($expirationDate)
->setNode($node);
->setNode($node)
->setTarget('');
$this->tokenHandler->method('generateToken')->willReturn('token');
@@ -215,7 +216,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner('shareOwner')
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
->setNode($node)
->setTarget('');
$this->tokenHandler->method('generateToken')->willReturn('token');
@@ -268,7 +270,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner('shareOwner')
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
->setNode($node)
->setTarget('');
$this->tokenHandler->method('generateToken')->willReturn('token');
@@ -359,7 +362,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner('shareOwner')
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
->setNode($node)
->setTarget('');
$this->tokenHandler->method('generateToken')->willReturn('token');
@@ -431,7 +435,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setExpirationDate(new \DateTime('2019-02-01T01:02:03'))
->setNode($node);
->setNode($node)
->setTarget('');
$this->tokenHandler->method('generateToken')->willReturn('token');
$this->addressHandler->expects($this->any())->method('generateRemoteURL')
@@ -504,7 +509,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner('shareOwner')
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
->setNode($node)
->setTarget('');
$this->provider->create($share);
$share2 = $this->shareManager->newShare();
@@ -513,7 +519,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner('shareOwner')
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
->setNode($node)
->setTarget('');
$this->provider->create($share2);
$shares = $this->provider->getSharesBy('sharedBy', IShare::TYPE_REMOTE, null, false, -1, 0);
@@ -548,7 +555,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner('shareOwner')
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
->setNode($node)
->setTarget('');
$this->provider->create($share);
$node2 = $this->getMockBuilder(File::class)->getMock();
@@ -561,7 +569,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner('shareOwner')
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setNode($node2);
->setNode($node2)
->setTarget('');
$this->provider->create($share2);
$shares = $this->provider->getSharesBy('sharedBy', IShare::TYPE_REMOTE, $node2, false, -1, 0);
@@ -595,7 +604,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner('shareOwner')
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
->setNode($node)
->setTarget('');
$this->provider->create($share);
$share2 = $this->shareManager->newShare();
@@ -604,7 +614,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner('shareOwner')
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
->setNode($node)
->setTarget('');
$this->provider->create($share2);
$shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_REMOTE, null, true, -1, 0);
@@ -645,7 +656,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner('shareOwner')
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
->setNode($node)
->setTarget('');
$this->provider->create($share);
$share2 = $this->shareManager->newShare();
@@ -654,7 +666,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner('shareOwner')
->setPermissions(19)
->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
->setNode($node)
->setTarget('');
$this->provider->create($share2);
$shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_REMOTE, null, true, 1, 1);
@@ -835,7 +848,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner($u1->getUID())
->setPermissions(Constants::PERMISSION_READ)
->setShareType(IShare::TYPE_REMOTE)
->setNode($file1);
->setNode($file1)
->setTarget('');
$this->provider->create($share1);
$share2 = $this->shareManager->newShare();
@@ -844,7 +858,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner($u1->getUID())
->setPermissions(Constants::PERMISSION_READ)
->setShareType(IShare::TYPE_REMOTE)
->setNode($file2);
->setNode($file2)
->setTarget('');
$this->provider->create($share2);
$result = $this->provider->getSharesInFolder($u1->getUID(), $folder1, false);
@@ -895,7 +910,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner($u1->getUID())
->setPermissions(Constants::PERMISSION_READ)
->setShareType(IShare::TYPE_REMOTE)
->setNode($file1);
->setNode($file1)
->setTarget('');
$this->provider->create($share1);
$share2 = $this->shareManager->newShare();
@@ -904,7 +920,8 @@ class FederatedShareProviderTest extends \Test\TestCase {
->setShareOwner($u1->getUID())
->setPermissions(Constants::PERMISSION_READ)
->setShareType(IShare::TYPE_REMOTE)
->setNode($file1);
->setNode($file1)
->setTarget('');
$this->provider->create($share2);
$result = $this->provider->getAccessList([$file1], true);
+4
View File
@@ -122,6 +122,7 @@ OC.L10N.register(
"General" : "Yleiset",
"Sort favorites first" : "Järjestä suosikit ensiksi",
"Sort folders before files" : "Järjestä kansiot ennen tiedostoja",
"Enable folder tree view" : "Käytä kansiopuunäkymää",
"Default view" : "Oletusnäkymä",
"All files" : "Kaikki tiedostot",
"Personal files" : "Henkilökohtaiset tiedostot",
@@ -131,6 +132,8 @@ OC.L10N.register(
"Selection" : "Valinta",
"Select all files" : "Valitse kaikki tiedostot",
"Deselect all" : "Poista valinnat",
"Select or deselect" : "Valitse tai poista valinta",
"Select a range" : "Valitse väliltä",
"Navigation" : "Navigointi",
"Go to parent folder" : "Siirry ylätason kansioon",
"Go to file above" : "Siirry yllä olevaan tiedostoon",
@@ -139,6 +142,7 @@ OC.L10N.register(
"Go right in grid" : "Siirry oikealle ruudukossa",
"View" : "Näytä",
"Toggle grid view" : "Ruudukkonäkymä päälle/pois",
"Show those shortcuts" : "Näytä pikanäppäimet",
"Warnings" : "Varoitukset",
"Warn before changing a file extension" : "Varoita ennen tiedostopäätteen muuttamista",
"Warn before deleting a file" : "Varoita ennen tiedoston poistamista",
+4
View File
@@ -120,6 +120,7 @@
"General" : "Yleiset",
"Sort favorites first" : "Järjestä suosikit ensiksi",
"Sort folders before files" : "Järjestä kansiot ennen tiedostoja",
"Enable folder tree view" : "Käytä kansiopuunäkymää",
"Default view" : "Oletusnäkymä",
"All files" : "Kaikki tiedostot",
"Personal files" : "Henkilökohtaiset tiedostot",
@@ -129,6 +130,8 @@
"Selection" : "Valinta",
"Select all files" : "Valitse kaikki tiedostot",
"Deselect all" : "Poista valinnat",
"Select or deselect" : "Valitse tai poista valinta",
"Select a range" : "Valitse väliltä",
"Navigation" : "Navigointi",
"Go to parent folder" : "Siirry ylätason kansioon",
"Go to file above" : "Siirry yllä olevaan tiedostoon",
@@ -137,6 +140,7 @@
"Go right in grid" : "Siirry oikealle ruudukossa",
"View" : "Näytä",
"Toggle grid view" : "Ruudukkonäkymä päälle/pois",
"Show those shortcuts" : "Näytä pikanäppäimet",
"Warnings" : "Varoitukset",
"Warn before changing a file extension" : "Varoita ennen tiedostopäätteen muuttamista",
"Warn before deleting a file" : "Varoita ennen tiedoston poistamista",
@@ -104,10 +104,7 @@ class DeleteOrphanedFilesTest extends TestCase {
$this->assertEquals(1, $this->getMountsCount($numericStorageId), 'Asserts that mount is still available');
$qb = $this->connection->getQueryBuilder();
$deletedRows = $qb->delete('storages')
->where($qb->expr()->eq('id', $qb->createNamedParameter($storageId)))
->executeStatement();
$deletedRows = $this->connection->executeUpdate('DELETE FROM `*PREFIX*storages` WHERE `id` = ?', [$storageId]);
$this->assertNotNull($deletedRows, 'Asserts that storage got deleted');
$this->assertSame(1, $deletedRows, 'Asserts that storage got deleted');
+3
View File
@@ -165,6 +165,7 @@ OC.L10N.register(
"Unshare" : "Lopeta jakaminen",
"Cannot copy, please copy the link manually" : "Kopioiminen ei onnistu. Kopioi linkki manuaalisesti",
"Copy internal link" : "Kopioi sisäinen linkki",
"For people who already have access" : "Henkilöille, joilla on jo käyttöoikeus",
"Internal link" : "Sisäinen linkki",
"Shared via link by {initiator}" : "Jaettu linkin kautta käyttäjältä {initiator}",
"File request ({label})" : "Tiedostopyyntö ({label})",
@@ -247,6 +248,7 @@ OC.L10N.register(
"Toggle list of others with access to this directory" : "Vaihda näkymää kansioon käyttöoikeuden omaavista käyttäjistä",
"Toggle list of others with access to this file" : "Vaihda näkymää tiedostoon käyttöoikeuden omaavista käyttäjistä",
"Shares" : "Jaot",
"Shares from apps or other sources which are not included in internal or external shares." : "Jaot muista sovelluksista tai lähteistä, jotka eivät sisälly sisäisiin tai ulkoisiin jakoihin.",
"Type names or teams" : "Kirjoita nimet tai tiimit",
"Type an email" : "Kirjoita sähköpostiosoite",
"Unable to load the shares list" : "Jakolistan haku epäonnistui",
@@ -255,6 +257,7 @@ OC.L10N.register(
"Shared with you by {owner}" : "{owner} jakoi tämän kanssasi",
"Internal shares" : "Sisäiset jaot",
"External shares" : "Ulkoiset jaot",
"Additional shares" : "Muut jaot",
"Link to a file" : "Linkki tiedostoon",
"_Accept share_::_Accept shares_" : ["Hyväksy jako","Hyväksy jaot"],
"Open in Files" : "Avaa tiedostosovelluksessa",
+3
View File
@@ -163,6 +163,7 @@
"Unshare" : "Lopeta jakaminen",
"Cannot copy, please copy the link manually" : "Kopioiminen ei onnistu. Kopioi linkki manuaalisesti",
"Copy internal link" : "Kopioi sisäinen linkki",
"For people who already have access" : "Henkilöille, joilla on jo käyttöoikeus",
"Internal link" : "Sisäinen linkki",
"Shared via link by {initiator}" : "Jaettu linkin kautta käyttäjältä {initiator}",
"File request ({label})" : "Tiedostopyyntö ({label})",
@@ -245,6 +246,7 @@
"Toggle list of others with access to this directory" : "Vaihda näkymää kansioon käyttöoikeuden omaavista käyttäjistä",
"Toggle list of others with access to this file" : "Vaihda näkymää tiedostoon käyttöoikeuden omaavista käyttäjistä",
"Shares" : "Jaot",
"Shares from apps or other sources which are not included in internal or external shares." : "Jaot muista sovelluksista tai lähteistä, jotka eivät sisälly sisäisiin tai ulkoisiin jakoihin.",
"Type names or teams" : "Kirjoita nimet tai tiimit",
"Type an email" : "Kirjoita sähköpostiosoite",
"Unable to load the shares list" : "Jakolistan haku epäonnistui",
@@ -253,6 +255,7 @@
"Shared with you by {owner}" : "{owner} jakoi tämän kanssasi",
"Internal shares" : "Sisäiset jaot",
"External shares" : "Ulkoiset jaot",
"Additional shares" : "Muut jaot",
"Link to a file" : "Linkki tiedostoon",
"_Accept share_::_Accept shares_" : ["Hyväksy jako","Hyväksy jaot"],
"Open in Files" : "Avaa tiedostosovelluksessa",
@@ -70,7 +70,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase {
$this->connection = Server::get(IDBConnection::class);
// clear occasional leftover shares from other tests
$this->connection->getQueryBuilder()->delete('share')->executeStatement();
$this->connection->executeUpdate('DELETE FROM `*PREFIX*share`');
$this->user1 = $this->getUniqueID('user1_');
$this->user2 = $this->getUniqueID('user2_');
@@ -85,7 +85,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase {
}
protected function tearDown(): void {
$this->connection->getQueryBuilder()->delete('share')->executeStatement();
$this->connection->executeUpdate('DELETE FROM `*PREFIX*share`');
$userManager = Server::get(IUserManager::class);
$user1 = $userManager->get($this->user1);
@@ -104,10 +104,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase {
private function getShares() {
$shares = [];
$result = $this->connection->getQueryBuilder()
->select('*')
->from('share')
->executeQuery();
$result = $this->connection->executeQuery('SELECT * FROM `*PREFIX*share`');
while ($row = $result->fetchAssociative()) {
$shares[] = $row;
}
@@ -51,7 +51,7 @@ class SharesReminderJobTest extends \Test\TestCase {
$this->mailer = $this->createMock(IMailer::class);
// Clear occasional leftover shares from other tests
$this->db->getQueryBuilder()->delete('share')->executeStatement();
$this->db->executeUpdate('DELETE FROM `*PREFIX*share`');
$this->user1 = $this->getUniqueID('user1_');
$this->user2 = $this->getUniqueID('user2_');
@@ -78,7 +78,7 @@ class SharesReminderJobTest extends \Test\TestCase {
}
protected function tearDown(): void {
$this->db->getQueryBuilder()->delete('share')->executeStatement();
$this->db->executeUpdate('DELETE FROM `*PREFIX*share`');
$userManager = Server::get(IUserManager::class);
$user1 = $userManager->get($this->user1);
+1 -1
View File
@@ -144,7 +144,7 @@ class TrashbinTest extends \Test\TestCase {
// clear trash table
$connection = Server::get(IDBConnection::class);
$connection->getQueryBuilder()->delete('files_trash')->executeStatement();
$connection->executeUpdate('DELETE FROM `*PREFIX*files_trash`');
parent::tearDown();
}
+1 -1
View File
@@ -4,7 +4,7 @@ OC.L10N.register(
"Profile" : "Profil",
"This application provides the profile" : "Denne applikation leverer profilen",
"Provides a customisable user profile interface." : "Leverer en brugerdefinerbar brugerprofil grænseflade.",
"Searching …" : "Søger ...",
"Searching …" : "Søger …",
"Not found" : "Ikke fundet",
"Insert" : "Indsæt",
"You have not added any info yet" : "Du har ikke tilføjet nogen information endnu",
+1 -1
View File
@@ -2,7 +2,7 @@
"Profile" : "Profil",
"This application provides the profile" : "Denne applikation leverer profilen",
"Provides a customisable user profile interface." : "Leverer en brugerdefinerbar brugerprofil grænseflade.",
"Searching …" : "Søger ...",
"Searching …" : "Søger …",
"Not found" : "Ikke fundet",
"Insert" : "Indsæt",
"You have not added any info yet" : "Du har ikke tilføjet nogen information endnu",
@@ -0,0 +1,55 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { describe, expect, it } from 'vitest'
import { detect } from '../utils/userAgentDetect.ts'
describe('Android Chrome detection', () => {
it('modern Android Chrome (no Build/ string, post-2021) should match androidChrome', () => {
const ua = 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Mobile Safari/537.36'
expect(detect(ua)).toEqual({
id: 'androidChrome',
version: '132',
})
})
it('legacy Android Chrome (with Build/ string, pre-2021) should match androidChrome', () => {
const ua = 'Mozilla/5.0 (Linux; Android 10; SM-G973F Build/QP1A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36'
expect(detect(ua)).toEqual({
id: 'androidChrome',
version: '130',
})
})
it('Android Chrome on tablet (no "Mobile" in UA) should match androidChrome', () => {
const ua = 'Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
expect(detect(ua)).toEqual({
id: 'androidChrome',
version: '131',
})
})
})
describe('Desktop Chrome regression tests', () => {
it('Desktop Chrome on Linux should still match chrome', () => {
const ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36'
expect(detect(ua)).toEqual({
id: 'chrome',
version: '132',
os: 'Linux',
})
})
})
describe('Desktop Firefox regression tests', () => {
it('Desktop Firefox on Linux should still match firefox', () => {
const ua = 'Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0'
expect(detect(ua)).toEqual({
id: 'firefox',
version: '124',
os: 'Linux',
})
})
})
+2 -40
View File
@@ -100,35 +100,8 @@ import NcDateTime from '@nextcloud/vue/components/NcDateTime'
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
import NcTextField from '@nextcloud/vue/components/NcTextField'
import { TokenType, useAuthTokenStore } from '../store/authtoken.ts'
import { detect } from '../utils/userAgentDetect.ts'
// When using capture groups the following parts are extracted the first is used as the version number, the second as the OS
const userAgentMap = {
ie: /(?:MSIE|Trident|Trident\/7.0; rv)[ :](\d+)/,
// Microsoft Edge User Agent from https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
edge: /^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/[0-9.]+ (?:Mobile Safari|Safari)\/[0-9.]+ Edge\/[0-9.]+$/,
// Firefox User Agent from https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference
firefox: /^Mozilla\/5\.0 \([^)]*(Windows|OS X|Linux)[^)]+\) Gecko\/[0-9.]+ Firefox\/(\d+)(?:\.\d)?$/,
// Chrome User Agent from https://developer.chrome.com/multidevice/user-agent
chrome: /^Mozilla\/5\.0 \([^)]*(Windows|OS X|Linux)[^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/(\d+)[0-9.]+ (?:Mobile Safari|Safari)\/[0-9.]+$/,
// Safari User Agent from http://www.useragentstring.com/pages/Safari/
safari: /^Mozilla\/5\.0 \([^)]*(Windows|OS X)[^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\)(?: Version\/([0-9]+)[0-9.]+)? Safari\/[0-9.A-Z]+$/,
// Android Chrome user agent: https://developers.google.com/chrome/mobile/docs/user-agent
androidChrome: /Android.*(?:; (.*) Build\/).*Chrome\/(\d+)[0-9.]+/,
iphone: / *CPU +iPhone +OS +([0-9]+)_(?:[0-9_])+ +like +Mac +OS +X */,
ipad: /\(iPad; *CPU +OS +([0-9]+)_(?:[0-9_])+ +like +Mac +OS +X */,
iosClient: /^Mozilla\/5\.0 \(iOS\) (?:ownCloud|Nextcloud)-iOS.*$/,
androidClient: /^Mozilla\/5\.0 \(Android\) (?:ownCloud|Nextcloud)-android.*$/,
iosTalkClient: /^Mozilla\/5\.0 \(iOS\) Nextcloud-Talk.*$/,
androidTalkClient: /^Mozilla\/5\.0 \(Android\) Nextcloud-Talk.*$/,
// DAVx5/3.3.8-beta2-gplay (2021/01/02; dav4jvm; okhttp/4.9.0) Android/10
davx5: /DAV(?:droid|x5)\/([^ ]+)/,
// Mozilla/5.0 (U; Linux; Maemo; Jolla; Sailfish; like Android 4.3) AppleWebKit/538.1 (KHTML, like Gecko) WebPirate/2.0 like Mobile Safari/538.1 (compatible)
webPirate: /(Sailfish).*WebPirate\/(\d+)/,
// Mozilla/5.0 (Maemo; Linux; U; Jolla; Sailfish; Mobile; rv:31.0) Gecko/31.0 Firefox/31.0 SailfishBrowser/1.0
sailfishBrowser: /(Sailfish).*SailfishBrowser\/(\d+)/,
// Neon 1.0.0+1
neon: /Neon \d+\.\d+\.\d+\+\d+/,
}
const nameMap = {
edge: 'Microsoft Edge',
firefox: 'Firefox',
@@ -203,18 +176,7 @@ export default defineComponent({
}
}
for (const client in userAgentMap) {
const matches = this.token.name.match(userAgentMap[client])
if (matches) {
return {
id: client,
os: matches[2] && matches[1],
version: matches[2] ?? matches[1],
}
}
}
return null
return detect(this.token.name)
},
/**
@@ -0,0 +1,33 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { userAgentMap } from './userAgentMap.ts'
export interface DetectedUserAgent {
id: string
version?: string
os?: string
}
/**
* Detect the client from a user agent string.
*
* @param ua Raw user agent string
* @return Detected client information or null if unknown
*/
export function detect(ua: string): DetectedUserAgent | null {
for (const id in userAgentMap) {
const matches = ua.match(userAgentMap[id])
if (matches) {
return {
id,
version: matches[2] ?? matches[1],
os: matches[2] && matches[1],
}
}
}
return null
}
+35
View File
@@ -0,0 +1,35 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
// When using capture groups the following parts are extracted
// the first is used as the version number, the second as the OS
// Exception: single-group regexes (ie, androidChrome) use the first group as the version.
export const userAgentMap = {
ie: /(?:MSIE|Trident|Trident\/7.0; rv)[ :](\d+)/,
// Microsoft Edge User Agent from https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
edge: /^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/[0-9.]+ (?:Mobile Safari|Safari)\/[0-9.]+ Edge\/[0-9.]+$/,
// Firefox User Agent from https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference
firefox: /^Mozilla\/5\.0 \((?![^)]*Android)[^)]*(Windows|OS X|Linux)[^)]+\) Gecko\/[0-9.]+ Firefox\/(\d+)(?:\.\d)?$/,
// Android Chrome user agent: https://developers.google.com/chrome/mobile/docs/user-agent
androidChrome: /^Mozilla\/5\.0 \(Linux; Android[^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/(\d+)[0-9.]+ (?:Mobile )?Safari\/[0-9.]+$/,
// Chrome User Agent from https://developer.chrome.com/multidevice/user-agent
chrome: /^Mozilla\/5\.0 \((?![^)]*Android)[^)]*(Windows|OS X|Linux)[^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/(\d+)[0-9.]+ (?:Mobile Safari|Safari)\/[0-9.]+$/,
// Safari User Agent from http://www.useragentstring.com/pages/Safari/
safari: /^Mozilla\/5\.0 \([^)]*(Windows|OS X)[^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\)(?: Version\/([0-9]+)[0-9.]+)? Safari\/[0-9.A-Z]+$/,
iphone: / *CPU +iPhone +OS +([0-9]+)_(?:[0-9_])+ +like +Mac +OS +X */,
ipad: /\(iPad; *CPU +OS +([0-9]+)_(?:[0-9_])+ +like +Mac +OS +X */,
iosClient: /^Mozilla\/5\.0 \(iOS\) (?:ownCloud|Nextcloud)-iOS.*$/,
androidClient: /^Mozilla\/5\.0 \(Android\) (?:ownCloud|Nextcloud)-android.*$/,
iosTalkClient: /^Mozilla\/5\.0 \(iOS\) Nextcloud-Talk.*$/,
androidTalkClient: /^Mozilla\/5\.0 \(Android\) Nextcloud-Talk.*$/,
// DAVx5/3.3.8-beta2-gplay (2021/01/02; dav4jvm; okhttp/4.9.0) Android/10
davx5: /DAV(?:droid|x5)\/([^ ]+)/,
// Mozilla/5.0 (U; Linux; Maemo; Jolla; Sailfish; like Android 4.3) AppleWebKit/538.1 (KHTML, like Gecko) WebPirate/2.0 like Mobile Safari/538.1 (compatible)
webPirate: /(Sailfish).*WebPirate\/(\d+)/,
// Mozilla/5.0 (Maemo; Linux; U; Jolla; Sailfish; Mobile; rv:31.0) Gecko/31.0 Firefox/31.0 SailfishBrowser/1.0
sailfishBrowser: /(Sailfish).*SailfishBrowser\/(\d+)/,
// Neon 1.0.0+1
neon: /Neon \d+\.\d+\.\d+\+\d+/,
}
+44 -35
View File
@@ -8,6 +8,7 @@
namespace OCA\User_LDAP\Mapping;
use Doctrine\DBAL\Exception;
use OCP\DB\IPreparedStatement;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IAppConfig;
use OCP\ICache;
@@ -153,6 +154,23 @@ abstract class AbstractMapping {
}
}
/**
* Performs a DELETE or UPDATE query to the database.
*
* @param IPreparedStatement $statement
* @param array $parameters
* @return bool true if at least one row was modified, false otherwise
*/
protected function modify(IPreparedStatement $statement, $parameters) {
try {
$result = $statement->execute($parameters);
$updated = $result->rowCount() > 0;
$result->closeCursor();
return $updated;
} catch (Exception $e) {
return false;
}
}
/**
* Gets the LDAP DN based on the provided name.
@@ -181,16 +199,13 @@ abstract class AbstractMapping {
*/
public function setDNbyUUID($fdn, $uuid) {
$oldDn = $this->getDnByUUID($uuid);
$qb = $this->dbc->getQueryBuilder();
try {
$r = $qb->update($this->getTableName(false))
->set('ldap_dn_hash', $qb->createNamedParameter($this->getDNHash($fdn)))
->set('ldap_dn', $qb->createNamedParameter($fdn))
->where($qb->expr()->eq('directory_uuid', $qb->createNamedParameter($uuid)))
->executeStatement() > 0;
} catch (Exception $e) {
$r = false;
}
$statement = $this->dbc->prepare('
UPDATE `' . $this->getTableName() . '`
SET `ldap_dn_hash` = ?, `ldap_dn` = ?
WHERE `directory_uuid` = ?
');
$r = $this->modify($statement, [$this->getDNHash($fdn), $fdn, $uuid]);
if ($r) {
if (is_string($oldDn) && isset($this->cache[$oldDn])) {
$userId = $this->cache[$oldDn];
@@ -216,17 +231,15 @@ abstract class AbstractMapping {
* @return bool
*/
public function setUUIDbyDN($uuid, $fdn): bool {
$statement = $this->dbc->prepare('
UPDATE `' . $this->getTableName() . '`
SET `directory_uuid` = ?
WHERE `ldap_dn_hash` = ?
');
unset($this->cache[$fdn]);
$qb = $this->dbc->getQueryBuilder();
try {
return $qb->update($this->getTableName(false))
->set('directory_uuid', $qb->createNamedParameter($uuid))
->where($qb->expr()->eq('ldap_dn_hash', $qb->createNamedParameter($this->getDNHash($fdn))))
->executeStatement() > 0;
} catch (Exception $e) {
return false;
}
return $this->modify($statement, [$uuid, $this->getDNHash($fdn)]);
}
/**
@@ -320,14 +333,14 @@ abstract class AbstractMapping {
* @return string[]
*/
public function getNamesBySearch(string $search, string $prefixMatch = '', string $postfixMatch = ''): array {
$qb = $this->dbc->getQueryBuilder();
$statement = $this->dbc->prepare('
SELECT `owncloud_name`
FROM `' . $this->getTableName() . '`
WHERE `owncloud_name` LIKE ?
');
try {
$res = $qb->select('owncloud_name')
->from($this->getTableName(false))
->where($qb->expr()->like('owncloud_name', $qb->createNamedParameter(
$prefixMatch . $this->dbc->escapeLikeParameter($search) . $postfixMatch
)))
->executeQuery();
$res = $statement->execute([$prefixMatch . $this->dbc->escapeLikeParameter($search) . $postfixMatch]);
} catch (Exception $e) {
return [];
}
@@ -335,7 +348,6 @@ abstract class AbstractMapping {
while ($row = $res->fetchAssociative()) {
$names[] = $row['owncloud_name'];
}
$res->closeCursor();
return $names;
}
@@ -431,20 +443,17 @@ abstract class AbstractMapping {
* @return bool
*/
public function unmap($name) {
$statement = $this->dbc->prepare('
DELETE FROM `' . $this->getTableName() . '`
WHERE `owncloud_name` = ?');
$dn = array_search($name, $this->cache, true);
if ($dn !== false) {
unset($this->cache[$dn]);
}
$this->localNameToDnCache?->remove($name);
$qb = $this->dbc->getQueryBuilder();
try {
return $qb->delete($this->getTableName(false))
->where($qb->expr()->eq('owncloud_name', $qb->createNamedParameter($name)))
->executeStatement() > 0;
} catch (Exception $e) {
return false;
}
return $this->modify($statement, [$name]);
}
/**
+1
View File
@@ -204,6 +204,7 @@ OC.L10N.register(
"Search people" : "Etsi ihmisiä",
"People" : "Ihmiset",
"Filter in current view" : "Suodata nykyisessä näkymässä",
"Search connected services" : "Etsi liitetyistä palveluista",
"Results" : "Tulokset",
"Load more results" : "Lataa lisää tuloksia",
"Search in" : "Etsi kohteesta",
+1
View File
@@ -202,6 +202,7 @@
"Search people" : "Etsi ihmisiä",
"People" : "Ihmiset",
"Filter in current view" : "Suodata nykyisessä näkymässä",
"Search connected services" : "Etsi liitetyistä palveluista",
"Results" : "Tulokset",
"Load more results" : "Lataa lisää tuloksia",
"Search in" : "Etsi kohteesta",
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,5 +1,5 @@
/* extracted by css-entry-points-plugin */
@import './theming-theming-settings-personal-BGvZ2soH.chunk.css';
@import './theming-theming-settings-personal-Tw2nBJ_u.chunk.css';
@import './createElementId-DhjFt1I9-C_oBIsvc.chunk.css';
@import './autolink-U5pBzLgI-R3us1MM8.chunk.css';
@import './NcModal-DHryP_87-CU2wYsLf.chunk.css';
@@ -1 +0,0 @@
.theming__preview[data-v-13bf6aae]{--ratio: 16;position:relative;display:flex;justify-content:flex-start}.theming__preview[data-v-13bf6aae],.theming__preview[data-v-13bf6aae] *{-webkit-user-select:none;user-select:none}.theming__preview-image[data-v-13bf6aae]{flex-basis:calc(16px * var(--ratio));flex-shrink:0;height:calc(10px * var(--ratio));margin-inline-end:var(--gap);cursor:pointer;border-radius:var(--border-radius);background-repeat:no-repeat;background-position:top left;background-size:cover}.theming__preview-explanation[data-v-13bf6aae]{margin-bottom:10px}.theming__preview-description[data-v-13bf6aae]{display:flex;flex-direction:column}.theming__preview-description h3[data-v-13bf6aae]{font-weight:700;margin-bottom:0}.theming__preview-description label[data-v-13bf6aae]{padding:12px 0}.theming__preview-warning[data-v-13bf6aae]{background-color:var(--color-warning);color:var(--color-warning-text)}@media(max-width:682.6666666667px){.theming__preview[data-v-13bf6aae]{flex-direction:column}.theming__preview-image[data-v-13bf6aae]{margin:0}}._userSectionAppMenu__selector_1hkl7_2{margin-block:12px}._backgroundSelect_l1nhm_2{display:flex;flex-wrap:wrap;justify-content:center}._backgroundSelect_l1nhm_2 ._backgroundSelect__entry_l1nhm_7{display:flex;flex-direction:column;justify-content:center;align-items:center;overflow:hidden;height:96px;width:168px;margin:var(--default-grid-baseline);text-align:center;overflow-wrap:break-word;-webkit-hyphens:auto;hyphens:auto;border:2px solid var(--color-main-background);border-radius:var(--border-radius-large);background-position:center center;background-size:cover;--color-content: var(--color-background-plain-text)}._backgroundSelect_l1nhm_2 ._backgroundSelect__entry_l1nhm_7:hover,._backgroundSelect_l1nhm_2 ._backgroundSelect__entry_l1nhm_7:focus{outline:2px solid var(--color-main-text)!important;border-color:var(--color-main-background)!important}._backgroundSelect_l1nhm_2 ._backgroundSelect__entry_l1nhm_7>*{color:var(--color-content);opacity:1}._backgroundSelect_l1nhm_2 ._backgroundSelect__entryColor_l1nhm_38{background-color:var(--color-background-plain)}._backgroundSelect_l1nhm_2 ._backgroundSelect__entryFilePicker_l1nhm_42{--color-content: var(--color-main-text);background-color:var(--color-background-dark)}._backgroundSelect_l1nhm_2 ._backgroundSelect__entryFilePicker_l1nhm_42[aria-pressed=true]{--color-content: var(--color-background-plain-text);background-image:var(--image-background)}._backgroundSelect_l1nhm_2 ._backgroundSelect__entryDefault_l1nhm_52{background-image:linear-gradient(to bottom,#17171780,#17171780),var(--cf2ff408)}._userPrimaryColor_3oh6f_1{display:flex;flex-direction:row;flex-wrap:wrap;gap:12px}._userPrimaryColor_3oh6f_1 ._userPrimaryColor__trigger_3oh6f_8{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;margin:0!important;background-color:var(--color-primary);color:var(--color-primary-text);height:96px;width:168px;overflow-wrap:break-word;-webkit-hyphens:auto;hyphens:auto;border:2px solid var(--color-main-background);border-radius:var(--border-radius-large)}._userPrimaryColor_3oh6f_1 ._userPrimaryColor__trigger_3oh6f_8:active{background-color:var(--color-primary-hover)!important}._userPrimaryColor_3oh6f_1 ._userPrimaryColor__trigger_3oh6f_8:hover,._userPrimaryColor_3oh6f_1 ._userPrimaryColor__trigger_3oh6f_8:focus,._userPrimaryColor_3oh6f_1 ._userPrimaryColor__trigger_3oh6f_8:focus-visible{border-color:var(--color-main-background)!important;outline:2px solid var(--color-main-text)!important}.theming p[data-v-50195b4f]{max-width:800px}.theming[data-v-50195b4f] a{font-weight:700}.theming[data-v-50195b4f] a:hover,.theming[data-v-50195b4f] a:focus{text-decoration:underline}.theming__preview-list[data-v-50195b4f]{--gap: 30px;display:grid;margin-top:var(--gap);column-gap:var(--gap);row-gap:var(--gap)}.background__grid[data-v-50195b4f]{margin-top:30px}@media(max-width:1440px){.theming__preview-list[data-v-50195b4f]{display:flex;flex-direction:column}}
@@ -0,0 +1 @@
.theming__preview[data-v-13bf6aae]{--ratio: 16;position:relative;display:flex;justify-content:flex-start}.theming__preview[data-v-13bf6aae],.theming__preview[data-v-13bf6aae] *{-webkit-user-select:none;user-select:none}.theming__preview-image[data-v-13bf6aae]{flex-basis:calc(16px * var(--ratio));flex-shrink:0;height:calc(10px * var(--ratio));margin-inline-end:var(--gap);cursor:pointer;border-radius:var(--border-radius);background-repeat:no-repeat;background-position:top left;background-size:cover}.theming__preview-explanation[data-v-13bf6aae]{margin-bottom:10px}.theming__preview-description[data-v-13bf6aae]{display:flex;flex-direction:column}.theming__preview-description h3[data-v-13bf6aae]{font-weight:700;margin-bottom:0}.theming__preview-description label[data-v-13bf6aae]{padding:12px 0}.theming__preview-warning[data-v-13bf6aae]{background-color:var(--color-warning);color:var(--color-warning-text)}@media(max-width:682.6666666667px){.theming__preview[data-v-13bf6aae]{flex-direction:column}.theming__preview-image[data-v-13bf6aae]{margin:0}}._userSectionAppMenu__selector_1hkl7_2{margin-block:12px}._backgroundSelect_l1nhm_2{display:flex;flex-wrap:wrap;justify-content:center}._backgroundSelect_l1nhm_2 ._backgroundSelect__entry_l1nhm_7{display:flex;flex-direction:column;justify-content:center;align-items:center;overflow:hidden;height:96px;width:168px;margin:var(--default-grid-baseline);text-align:center;overflow-wrap:break-word;hyphens:auto;border:2px solid var(--color-main-background);border-radius:var(--border-radius-large);background-position:center center;background-size:cover;--color-content: var(--color-background-plain-text)}._backgroundSelect_l1nhm_2 ._backgroundSelect__entry_l1nhm_7:hover,._backgroundSelect_l1nhm_2 ._backgroundSelect__entry_l1nhm_7:focus{outline:2px solid var(--color-main-text)!important;border-color:var(--color-main-background)!important}._backgroundSelect_l1nhm_2 ._backgroundSelect__entry_l1nhm_7>*{color:var(--color-content);opacity:1}._backgroundSelect_l1nhm_2 ._backgroundSelect__entryColor_l1nhm_38{background-color:var(--color-background-plain)}._backgroundSelect_l1nhm_2 ._backgroundSelect__entryFilePicker_l1nhm_42{--color-content: var(--color-main-text);background-color:var(--color-background-dark)}._backgroundSelect_l1nhm_2 ._backgroundSelect__entryFilePicker_l1nhm_42[aria-pressed=true]{--color-content: var(--color-background-plain-text);background-image:var(--image-background)}._backgroundSelect_l1nhm_2 ._backgroundSelect__entryDefault_l1nhm_52{background-image:linear-gradient(to bottom,#17171780,#17171780),var(--cf2ff408)}._userPrimaryColor_3oh6f_1{display:flex;flex-direction:row;flex-wrap:wrap;gap:12px}._userPrimaryColor_3oh6f_1 ._userPrimaryColor__trigger_3oh6f_8{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;margin:0!important;background-color:var(--color-primary);color:var(--color-primary-text);height:96px;width:168px;overflow-wrap:break-word;hyphens:auto;border:2px solid var(--color-main-background);border-radius:var(--border-radius-large)}._userPrimaryColor_3oh6f_1 ._userPrimaryColor__trigger_3oh6f_8:active{background-color:var(--color-primary-hover)!important}._userPrimaryColor_3oh6f_1 ._userPrimaryColor__trigger_3oh6f_8:hover,._userPrimaryColor_3oh6f_1 ._userPrimaryColor__trigger_3oh6f_8:focus,._userPrimaryColor_3oh6f_1 ._userPrimaryColor__trigger_3oh6f_8:focus-visible{border-color:var(--color-main-background)!important;outline:2px solid var(--color-main-text)!important}.theming p[data-v-50195b4f]{max-width:800px}.theming[data-v-50195b4f] a{font-weight:700}.theming[data-v-50195b4f] a:hover,.theming[data-v-50195b4f] a:focus{text-decoration:underline}.theming__preview-list[data-v-50195b4f]{--gap: 30px;display:grid;margin-top:var(--gap);column-gap:var(--gap);row-gap:var(--gap)}.background__grid[data-v-50195b4f]{margin-top:30px}@media(max-width:1440px){.theming__preview-list[data-v-50195b4f]{display:flex;flex-direction:column}}
+2 -2
View File
@@ -269,7 +269,7 @@ class OC {
$result = $qb->select($qb->func()->count('*', 'user_count'))
->from('ldap_user_mapping')
->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
$tooBig = ($row['user_count'] > 50);
@@ -280,7 +280,7 @@ class OC {
$result = $qb->select($qb->func()->count('*', 'user_count'))
->from('user_saml_users')
->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
$tooBig = ($row['user_count'] > 50);
+2 -2
View File
@@ -197,7 +197,7 @@ class AccountManager implements IAccountManager {
->where($query->expr()->eq('uid', $query->createParameter('uid')))
->setParameter('uid', $uid);
$result = $query->executeQuery();
$accountData = $result->fetchAllAssociative();
$accountData = $result->fetchAll();
$result->closeCursor();
if (empty($accountData)) {
@@ -233,7 +233,7 @@ class AccountManager implements IAccountManager {
$query->setParameter('values', $chunk, IQueryBuilder::PARAM_STR_ARRAY);
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$matches[$row['uid']] = $row['value'];
}
$result->closeCursor();
+1 -1
View File
@@ -1360,7 +1360,7 @@ class AppConfig implements IAppConfig {
}
$result = $qb->executeQuery();
$rows = $result->fetchAllAssociative();
$rows = $result->fetchAll();
foreach ($rows as $row) {
// most of the time, 'lazy' is not in the select because its value is already known
if ($lazy && ((int)$row['lazy']) === 1) {
@@ -14,6 +14,7 @@ use OC\AppFramework\Middleware\Security\Exceptions\AppNotEnabledException;
use OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException;
use OC\AppFramework\Middleware\Security\Exceptions\ExAppRequiredException;
use OC\AppFramework\Middleware\Security\Exceptions\NotAdminException;
use OC\AppFramework\Middleware\Security\Exceptions\NotConfirmedException;
use OC\AppFramework\Middleware\Security\Exceptions\NotLoggedInException;
use OC\AppFramework\Middleware\Security\Exceptions\SecurityException;
use OC\AppFramework\Middleware\Security\Exceptions\StrictCookieMissingException;
@@ -280,6 +281,9 @@ class SecurityMiddleware extends Middleware {
}
}
if ($exception instanceof NotConfirmedException) {
$response->addHeader('X-NC-Auth-NotConfirmed', 'true');
}
$this->logger->debug($exception->getMessage(), [
'exception' => $exception,
]);
@@ -75,7 +75,7 @@ class PublicKeyTokenMapper extends QBMapper {
->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT)))
->executeQuery();
$data = $result->fetchAssociative();
$data = $result->fetch();
$result->closeCursor();
if ($data === false) {
throw new DoesNotExistException('token does not exist');
@@ -97,7 +97,7 @@ class PublicKeyTokenMapper extends QBMapper {
->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT)))
->executeQuery();
$data = $result->fetchAssociative();
$data = $result->fetch();
$result->closeCursor();
if ($data === false) {
throw new DoesNotExistException('token does not exist');
@@ -123,7 +123,7 @@ class PublicKeyTokenMapper extends QBMapper {
->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT)))
->setMaxResults(1000);
$result = $qb->executeQuery();
$data = $result->fetchAllAssociative();
$data = $result->fetchAll();
$result->closeCursor();
$entities = array_map(function ($row) {
@@ -178,7 +178,7 @@ class PublicKeyTokenMapper extends QBMapper {
->setMaxResults(1);
$cursor = $qb->executeQuery();
$data = $cursor->fetchAllAssociative();
$data = $cursor->fetchAll();
$cursor->closeCursor();
return count($data) === 1;
@@ -242,7 +242,7 @@ class PublicKeyTokenMapper extends QBMapper {
->orderBy('id');
$result = $qb->executeQuery();
$data = $result->fetchAssociative();
$data = $result->fetch();
$result->closeCursor();
if ($data === false) {
return null;
@@ -37,7 +37,7 @@ class ProviderUserAssignmentDao {
->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid)));
$result = $query->executeQuery();
$providers = [];
foreach ($result->fetchAllAssociative() as $row) {
foreach ($result->fetchAll() as $row) {
$providers[(string)$row['provider_id']] = (int)$row['enabled'] === 1;
}
$result->closeCursor();
@@ -80,7 +80,7 @@ class ProviderUserAssignmentDao {
->from(self::TABLE_NAME)
->where($qb1->expr()->eq('uid', $qb1->createNamedParameter($uid)));
$selectResult = $selectQuery->executeQuery();
$rows = $selectResult->fetchAllAssociative();
$rows = $selectResult->fetchAll();
$selectResult->closeCursor();
$qb2 = $this->conn->getQueryBuilder();
+6 -6
View File
@@ -129,7 +129,7 @@ class JobList implements IJobList {
->setMaxResults(1);
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
return (bool)$row;
@@ -158,7 +158,7 @@ class JobList implements IJobList {
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$job = $this->buildJob($row);
if ($job) {
yield $job;
@@ -190,7 +190,7 @@ class JobList implements IJobList {
}
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if ($row) {
@@ -293,7 +293,7 @@ class JobList implements IJobList {
->from('jobs')
->where($query->expr()->eq('id', $query->createNamedParameter($id)));
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if ($row) {
@@ -407,7 +407,7 @@ class JobList implements IJobList {
try {
$result = $query->executeQuery();
$hasReservedJobs = $result->fetchAssociative() !== false;
$hasReservedJobs = $result->fetch() !== false;
$result->closeCursor();
return $hasReservedJobs;
} catch (Exception $e) {
@@ -429,7 +429,7 @@ class JobList implements IJobList {
$jobs = [];
while (($row = $result->fetchAssociative()) !== false) {
while (($row = $result->fetch()) !== false) {
/**
* @var array{count:int, class:class-string<IJob>} $row
*/
@@ -344,7 +344,7 @@ class ResourcesRoomsUpdater {
->from($table)
->where($query->expr()->eq($foreignKey, $query->createNamedParameter($id)));
$result = $query->executeQuery();
$rows = $result->fetchAllAssociative();
$rows = $result->fetchAll();
$result->closeCursor();
$metadata = [];
@@ -370,7 +370,7 @@ class ResourcesRoomsUpdater {
->from($tableName)
->where($query->expr()->eq('backend_id', $query->createNamedParameter($backendId)));
$result = $query->executeQuery();
$rows = $result->fetchAllAssociative();
$rows = $result->fetchAll();
$result->closeCursor();
return array_map(function ($row): string {
@@ -130,7 +130,7 @@ readonly class UserPlugin implements ISearchPlugin {
->where($qb->expr()->eq($qb->func()->lower('value'), $qb->createNamedParameter($lowerSearch)))
->andWhere($qb->expr()->in('name', $qb->createNamedParameter(['email', 'additional_mail'], IQueryBuilder::PARAM_STR_ARRAY)));
$result = $qb->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$uid = $row['uid'];
$email = $row['value'];
$isAdditional = $row['name'] === 'additional_mail';
@@ -46,7 +46,7 @@ class Manager implements IManager {
->from(self::TABLE_COLLECTIONS)
->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if (!$row) {
@@ -75,7 +75,7 @@ class Manager implements IManager {
)
->where($query->expr()->eq('c.id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if (!$row) {
@@ -120,7 +120,7 @@ class Manager implements IManager {
$collections = [];
$foundResults = 0;
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$foundResults++;
$access = $row['access'] === null ? null : (bool)$row['access'];
$collection = new Collection($this, $this->connection, (int)$row['id'], (string)$row['name'], $user, $access);
@@ -179,7 +179,7 @@ class Manager implements IManager {
->where($query->expr()->eq('r.resource_type', $query->createNamedParameter($type, IQueryBuilder::PARAM_STR)))
->andWhere($query->expr()->eq('r.resource_id', $query->createNamedParameter($id, IQueryBuilder::PARAM_STR)));
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if (!$row) {
@@ -216,7 +216,7 @@ class Manager implements IManager {
$resources = [];
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$access = $row['access'] === null ? null : (bool)$row['access'];
$resources[] = new Resource($this, $this->connection, $row['resource_type'], $row['resource_id'], $user, $access);
}
@@ -310,7 +310,7 @@ class Manager implements IManager {
$hasAccess = null;
$result = $query->executeQuery();
if ($row = $result->fetchAssociative()) {
if ($row = $result->fetch()) {
$hasAccess = (bool)$row['access'];
}
$result->closeCursor();
@@ -330,7 +330,7 @@ class Manager implements IManager {
$hasAccess = null;
$result = $query->executeQuery();
if ($row = $result->fetchAssociative()) {
if ($row = $result->fetch()) {
$hasAccess = (bool)$row['access'];
}
$result->closeCursor();
@@ -103,7 +103,7 @@ class Resource implements IResource {
->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($this->getId())));
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$collections[] = $this->manager->getCollection((int)$row['collection_id']);
}
$result->closeCursor();
+16 -16
View File
@@ -180,7 +180,7 @@ class Manager implements ICommentsManager {
->setParameter('id', $id);
$resultStatement = $query->executeQuery();
$data = $resultStatement->fetchNumeric();
$data = $resultStatement->fetch(\PDO::FETCH_NUM);
$resultStatement->closeCursor();
$children = (int)$data[0];
@@ -255,7 +255,7 @@ class Manager implements ICommentsManager {
->setParameter('id', $id, IQueryBuilder::PARAM_INT)
->executeQuery();
$data = $resultStatement->fetchAssociative();
$data = $resultStatement->fetch();
$resultStatement->closeCursor();
if (!$data) {
throw new NotFoundException();
@@ -290,7 +290,7 @@ class Manager implements ICommentsManager {
}
$resultStatement = $query->executeQuery();
while ($data = $resultStatement->fetchAssociative()) {
while ($data = $resultStatement->fetch()) {
$comment = $this->getCommentFromData($data);
$this->cache($comment);
$tree['replies'][] = [
@@ -349,7 +349,7 @@ class Manager implements ICommentsManager {
}
$resultStatement = $query->executeQuery();
while ($data = $resultStatement->fetchAssociative()) {
while ($data = $resultStatement->fetch()) {
$comment = $this->getCommentFromData($data);
$this->cache($comment);
$comments[] = $comment;
@@ -511,7 +511,7 @@ class Manager implements ICommentsManager {
}
$resultStatement = $query->executeQuery();
while ($data = $resultStatement->fetchAssociative()) {
while ($data = $resultStatement->fetch()) {
$comment = $this->getCommentFromData($data);
$this->cache($comment);
$comments[] = $comment;
@@ -537,7 +537,7 @@ class Manager implements ICommentsManager {
->andWhere($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if ($row) {
@@ -609,7 +609,7 @@ class Manager implements ICommentsManager {
$comments = [];
$result = $query->executeQuery();
while ($data = $result->fetchAssociative()) {
while ($data = $result->fetch()) {
$comment = $this->getCommentFromData($data);
$this->cache($comment);
$comments[] = $comment;
@@ -653,7 +653,7 @@ class Manager implements ICommentsManager {
$query->groupBy('object_id');
$comments = array_fill_keys($objectIds, 0);
$resultStatement = $query->executeQuery();
while ($data = $resultStatement->fetchAssociative()) {
while ($data = $resultStatement->fetch()) {
$comments[$data['object_id']] = (int)$data['num_comments'];
}
$resultStatement->closeCursor();
@@ -697,7 +697,7 @@ class Manager implements ICommentsManager {
$query->setParameter('ids', $chunk, IQueryBuilder::PARAM_STR_ARRAY);
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$unreadComments[$row['object_id']] = (int)$row['num_comments'];
}
$result->closeCursor();
@@ -743,7 +743,7 @@ class Manager implements ICommentsManager {
}
$result = $query->executeQuery();
$data = $result->fetchAssociative();
$data = $result->fetch();
$result->closeCursor();
return (int)($data['num_messages'] ?? 0);
@@ -771,7 +771,7 @@ class Manager implements ICommentsManager {
}
$result = $query->executeQuery();
$data = $result->fetchAssociative();
$data = $result->fetch();
$result->closeCursor();
return (int)($data['id'] ?? 0);
@@ -808,7 +808,7 @@ class Manager implements ICommentsManager {
->groupBy('actor_id');
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$lastComments[$row['actor_id']] = $this->timeFactory->getDateTime($row['last_comment']);
}
$result->closeCursor();
@@ -976,7 +976,7 @@ class Manager implements ICommentsManager {
->executeQuery();
$commentIds = [];
while ($data = $result->fetchAssociative()) {
while ($data = $result->fetch()) {
$commentIds[] = $data['message_id'];
}
@@ -1006,7 +1006,7 @@ class Manager implements ICommentsManager {
->executeQuery();
$commentIds = [];
while ($data = $result->fetchAssociative()) {
while ($data = $result->fetch()) {
$commentIds[] = $data['message_id'];
}
$comments = [];
@@ -1063,7 +1063,7 @@ class Manager implements ICommentsManager {
$query->setParameter('ids', $ids, IQueryBuilder::PARAM_STR_ARRAY);
$result = $query->executeQuery();
while ($data = $result->fetchAssociative()) {
while ($data = $result->fetch()) {
$comment = $this->getCommentFromData($data);
$this->cache($comment);
$comments[] = $comment;
@@ -1415,7 +1415,7 @@ class Manager implements ICommentsManager {
->setParameter('object_id', $objectId, IQueryBuilder::PARAM_STR)
->executeQuery();
$data = $resultStatement->fetchAssociative();
$data = $resultStatement->fetch();
$resultStatement->closeCursor();
if (!$data || is_null($data['marker_datetime'])) {
return null;
+4 -4
View File
@@ -102,7 +102,7 @@ class UserConfig implements IUserConfig {
}
$result = $qb->executeQuery();
$rows = $result->fetchAllAssociative();
$rows = $result->fetchAll();
$userIds = [];
foreach ($rows as $row) {
$userIds[] = $row['userid'];
@@ -375,7 +375,7 @@ class UserConfig implements IUserConfig {
// this nested function will execute current Query and store result within $values.
$executeAndStoreValue = function (IQueryBuilder $qb) use (&$values, $typedAs): IResult {
$result = $qb->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$value = $row['configvalue'];
try {
$value = $this->convertTypedValue($value, $typedAs ?? ValueType::from((int)$row['type']));
@@ -535,7 +535,7 @@ class UserConfig implements IUserConfig {
$qb->andWhere($where);
$result = $qb->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
yield $row['userid'];
}
}
@@ -1773,7 +1773,7 @@ class UserConfig implements IUserConfig {
}
$result = $qb->executeQuery();
$rows = $result->fetchAllAssociative();
$rows = $result->fetchAll();
foreach ($rows as $row) {
if (($row['lazy'] ?? ($lazy ?? 0) ? 1 : 0) === 1) {
$this->lazyCache[$userId][$row['appid']][$row['configkey']] = $row['configvalue'] ?? '';
+2 -2
View File
@@ -47,7 +47,7 @@ class Adapter {
*/
public function lockTable(string $tableName) {
$this->conn->beginTransaction();
$this->conn->executeStatement('LOCK TABLE `' . $tableName . '` IN EXCLUSIVE MODE');
$this->conn->executeUpdate('LOCK TABLE `' . $tableName . '` IN EXCLUSIVE MODE');
}
/**
@@ -99,7 +99,7 @@ class Adapter {
$query .= ' HAVING COUNT(*) = 0';
try {
return $this->conn->executeStatement($query, $inserts);
return $this->conn->executeUpdate($query, $inserts);
} catch (UniqueConstraintViolationException $e) {
// This exception indicates a concurrent insert happened between
// the insert and the sub-select in the insert, which is safe to ignore.
+2 -2
View File
@@ -15,11 +15,11 @@ class AdapterMySQL extends Adapter {
* @param string $tableName
*/
public function lockTable($tableName) {
$this->conn->executeStatement('LOCK TABLES `' . $tableName . '` WRITE');
$this->conn->executeUpdate('LOCK TABLES `' . $tableName . '` WRITE');
}
public function unlockTable() {
$this->conn->executeStatement('UNLOCK TABLES');
$this->conn->executeUpdate('UNLOCK TABLES');
}
public function fixupStatement($statement) {
+1 -1
View File
@@ -32,6 +32,6 @@ class AdapterPgSql extends Adapter {
$builder->setValue($key, $builder->createNamedParameter($value));
}
$queryString = $builder->getSQL() . ' ON CONFLICT DO NOTHING';
return $this->conn->executeStatement($queryString, $builder->getParameters(), $builder->getParameterTypes());
return $this->conn->executeUpdate($queryString, $builder->getParameters(), $builder->getParameterTypes());
}
}
+3 -3
View File
@@ -14,11 +14,11 @@ class AdapterSqlite extends Adapter {
* @param string $tableName
*/
public function lockTable($tableName) {
$this->conn->executeStatement('BEGIN EXCLUSIVE TRANSACTION');
$this->conn->executeUpdate('BEGIN EXCLUSIVE TRANSACTION');
}
public function unlockTable() {
$this->conn->executeStatement('COMMIT TRANSACTION');
$this->conn->executeUpdate('COMMIT TRANSACTION');
}
public function fixupStatement($statement) {
@@ -67,7 +67,7 @@ class AdapterSqlite extends Adapter {
$query .= ')';
try {
return $this->conn->executeStatement($query, $inserts);
return $this->conn->executeUpdate($query, $inserts);
} catch (UniqueConstraintViolationException $e) {
// if this is thrown then a concurrent insert happened between the insert and the sub-select in the insert, that should have avoided it
// it's fine to ignore this then
+16 -9
View File
@@ -65,35 +65,42 @@ class ArrayResult implements IResult {
#[Override]
public function fetchOne() {
$row = array_shift($this->rows);
return $row !== null ? current($row) : false;
$row = $this->fetch();
if ($row) {
return current($row);
}
return false;
}
#[Override]
public function fetchAssociative(): array|false {
$row = array_shift($this->rows);
return $row !== null ? $row : false;
$row = $this->fetch();
if ($row) {
return $row;
}
return false;
}
#[Override]
public function fetchNumeric(): array|false {
$row = array_shift($this->rows);
return $row !== null ? array_values($row) : false;
return $this->fetch(PDO::FETCH_NUM);
}
#[Override]
public function fetchAllNumeric(): array {
return array_map(static fn (array $row): array => array_values($row), $this->rows);
return $this->fetchAll(PDO::FETCH_NUM);
}
#[Override]
public function fetchAllAssociative(): array {
return $this->rows;
return $this->fetchAll();
}
#[Override]
public function fetchFirstColumn(): array {
return array_map(static fn (array $row): mixed => current($row), $this->rows);
return $this->fetchAll(PDO::FETCH_COLUMN);
}
#[Override]
+1 -1
View File
@@ -59,7 +59,7 @@ class ConnectionAdapter implements IDBConnection {
public function executeUpdate(string $sql, array $params = [], array $types = []): int {
try {
return $this->inner->executeStatement($sql, $params, $types);
return $this->inner->executeUpdate($sql, $params, $types);
} catch (Exception $e) {
throw DbalException::wrap($e, '', $sql);
}
+1 -1
View File
@@ -173,7 +173,7 @@ class MigrationService {
->orderBy('version');
$result = $qb->executeQuery();
$rows = $result->fetchFirstColumn();
$rows = $result->fetchAll(\PDO::FETCH_COLUMN);
$result->closeCursor();
usort($rows, $this->sortMigrations(...));
+2 -2
View File
@@ -25,7 +25,7 @@ class MySqlTools {
foreach ($variables as $var => $val) {
$result = $connection->executeQuery("SHOW VARIABLES LIKE '$var'");
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if ($row === false) {
return false;
@@ -39,7 +39,7 @@ class MySqlTools {
protected function isMariaDBWithLargePrefix(IDBConnection $connection) {
$result = $connection->executeQuery('SELECT VERSION()');
$row = strtolower($result->fetchOne());
$row = strtolower($result->fetchColumn());
$result->closeCursor();
if ($row === false) {
+3 -13
View File
@@ -42,21 +42,11 @@ class PreparedStatement implements IPreparedStatement {
}
public function fetch(int $fetchMode = PDO::FETCH_ASSOC) {
return match ($fetchMode) {
PDO::FETCH_ASSOC => $this->getResult()->fetchAssociative(),
PDO::FETCH_NUM => $this->getResult()->fetchNumeric(),
PDO::FETCH_COLUMN => $this->getResult()->fetchOne(),
default => $this->getResult()->fetch($fetchMode),
};
return $this->getResult()->fetch($fetchMode);
}
public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array {
return match ($fetchMode) {
PDO::FETCH_ASSOC => $this->getResult()->fetchAllAssociative(),
PDO::FETCH_NUM => $this->getResult()->fetchAllNumeric(),
PDO::FETCH_COLUMN => $this->getResult()->fetchFirstColumn(),
default => $this->getResult()->fetchAll($fetchMode),
};
return $this->getResult()->fetchAll($fetchMode);
}
public function fetchColumn() {
@@ -76,7 +66,7 @@ class PreparedStatement implements IPreparedStatement {
}
public function execute($params = null): IResult {
return ($this->result = new ResultAdapter($this->statement->execute($params ?? [])));
return ($this->result = new ResultAdapter($this->statement->execute($params)));
}
public function rowCount(): int {
@@ -49,7 +49,7 @@ class PartitionQuery {
$this->query->andWhere($this->query->expr()->in($this->joinToColumn, $this->query->createNamedParameter($joinFromValues, IQueryBuilder::PARAM_STR_ARRAY, ':' . uniqid())));
$s = $this->query->getSQL();
$partitionedRows = $this->query->executeQuery()->fetchAllAssociative();
$partitionedRows = $this->query->executeQuery()->fetchAll();
$columns = $this->query->getOutputColumns();
$nullResult = array_combine($columns, array_fill(0, count($columns), null));
@@ -43,36 +43,6 @@ class PartitionedResult extends ArrayResult {
return parent::fetchAll($fetchMode);
}
public function fetchAssociative(): array|false {
$this->fetchRows();
return parent::fetchAssociative();
}
public function fetchNumeric(): array|false {
$this->fetchRows();
return parent::fetchNumeric();
}
public function fetchOne(): mixed {
$this->fetchRows();
return parent::fetchOne();
}
public function fetchAllAssociative(): array {
$this->fetchRows();
return parent::fetchAllAssociative();
}
public function fetchAllNumeric(): array {
$this->fetchRows();
return parent::fetchAllNumeric();
}
public function fetchFirstColumn(): array {
$this->fetchRows();
return parent::fetchFirstColumn();
}
public function rowCount(): int {
$this->fetchRows();
return parent::rowCount();
@@ -81,7 +51,7 @@ class PartitionedResult extends ArrayResult {
private function fetchRows(): void {
if (!$this->fetched) {
$this->fetched = true;
$this->rows = $this->result->fetchAllAssociative();
$this->rows = $this->result->fetchAll();
foreach ($this->splitOfParts as $part) {
$this->rows = $part->mergeWith($this->rows);
}
@@ -90,7 +90,7 @@ class CrossShardMoveHelper {
$results = [];
foreach ($chunks as $chunk) {
$query->setParameter('keys', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
$results = array_merge($results, $query->executeQuery()->fetchAllAssociative());
$results = array_merge($results, $query->executeQuery()->fetchAll());
}
return $results;
@@ -138,7 +138,7 @@ class CrossShardMoveHelper {
$query->update($table)
->set($shardColumn, $query->createNamedParameter($targetShardKey, IQueryBuilder::PARAM_INT))
->where($query->expr()->in($primaryColumn, $query->createNamedParameter($primaryKeys, IQueryBuilder::PARAM_INT_ARRAY)));
$query->executeQuery()->fetchAllAssociative();
$query->executeQuery()->fetchAll();
}
/**
@@ -104,7 +104,7 @@ class ShardQueryRunner {
foreach ($shards as $shard) {
$shardConnection = $this->shardConnectionManager->getConnection($this->shardDefinition, $shard);
$subResult = $query->executeQuery($shardConnection);
$results = array_merge($results, $subResult->fetchAllAssociative());
$results = array_merge($results, $subResult->fetchAll());
$subResult->closeCursor();
}
} else {
@@ -118,7 +118,7 @@ class ShardQueryRunner {
foreach ($shards as $shard) {
$shardConnection = $this->shardConnectionManager->getConnection($this->shardDefinition, $shard);
$subResult = $query->executeQuery($shardConnection);
$rows = $subResult->fetchAllAssociative();
$rows = $subResult->fetchAll();
$results = array_merge($results, $rows);
$subResult->closeCursor();
+2 -2
View File
@@ -23,8 +23,8 @@ class SQLiteSessionInit implements EventSubscriber {
public function postConnect(ConnectionEventArgs $args): void {
$sensitive = $this->caseSensitiveLike ? 'true' : 'false';
$args->getConnection()->executeStatement('PRAGMA case_sensitive_like = ' . $sensitive);
$args->getConnection()->executeStatement('PRAGMA journal_mode = ' . $this->journalMode);
$args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive);
$args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode);
/** @var \Doctrine\DBAL\Driver\PDO\Connection $connection */
$connection = $args->getConnection()->getWrappedConnection();
$pdo = $connection->getWrappedConnection();
+2 -1
View File
@@ -6,6 +6,7 @@
*/
namespace OC\DirectEditing;
use Doctrine\DBAL\FetchMode;
use OCA\Encryption\Util;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\Response;
@@ -197,7 +198,7 @@ class Manager implements IManager {
$query->select('*')->from(self::TABLE_TOKENS)
->where($query->expr()->eq('token', $query->createNamedParameter($token, IQueryBuilder::PARAM_STR)));
$result = $query->executeQuery();
if ($tokenRow = $result->fetchAssociative()) {
if ($tokenRow = $result->fetch(FetchMode::ASSOCIATIVE)) {
return new Token($this, $tokenRow);
}
throw new \RuntimeException('Failed to validate the token');
+6 -6
View File
@@ -136,7 +136,7 @@ class Cache implements ICache {
$query->whereStorageId($this->getNumericStorageId());
$result = $query->executeQuery();
$data = $result->fetchAssociative();
$data = $result->fetch();
$result->closeCursor();
if ($data !== false) {
@@ -231,7 +231,7 @@ class Cache implements ICache {
$metadataQuery = $query->selectMetadata();
$result = $query->executeQuery();
$files = $result->fetchAllAssociative();
$files = $result->fetchAll();
$result->closeCursor();
return array_map(function (array $data) use ($metadataQuery): ICacheEntry {
@@ -858,7 +858,7 @@ class Cache implements ICache {
->from('filecache')
->where($query->expr()->eq('storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($path) . '/%')));
return $query->executeQuery()->fetchFirstColumn();
return $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN);
}
/**
@@ -1038,7 +1038,7 @@ class Cache implements ICache {
}
$result = $query->executeQuery();
$rows = $result->fetchAllAssociative();
$rows = $result->fetchAll();
$result->closeCursor();
if ($rows) {
@@ -1112,7 +1112,7 @@ class Cache implements ICache {
->whereStorageId($this->getNumericStorageId());
$result = $query->executeQuery();
$files = $result->fetchFirstColumn();
$files = $result->fetchAll(\PDO::FETCH_COLUMN);
$result->closeCursor();
return array_map(function ($id) {
@@ -1185,7 +1185,7 @@ class Cache implements ICache {
->where($query->expr()->eq('fileid', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if ($row) {
+10 -10
View File
@@ -49,7 +49,7 @@ class FileAccess implements IFileAccess {
$query->andWhere($query->expr()->eq('filecache.path_hash', $query->createNamedParameter(md5($path))));
$query->andWhere($query->expr()->eq('filecache.storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)));
$row = $query->executeQuery()->fetchAssociative();
$row = $query->executeQuery()->fetch();
return $row ? Cache::cacheEntryFromData($row, $this->mimeTypeLoader) : null;
}
@@ -79,7 +79,7 @@ class FileAccess implements IFileAccess {
$query = $this->getQuery()->selectFileCache();
$query->andWhere($query->expr()->in('filecache.fileid', $query->createNamedParameter($fileIds, IQueryBuilder::PARAM_INT_ARRAY)));
$rows = $query->executeQuery()->fetchAllAssociative();
$rows = $query->executeQuery()->fetchAll();
return $this->rowsToEntries($rows);
}
@@ -94,7 +94,7 @@ class FileAccess implements IFileAccess {
$query->andWhere($query->expr()->in('filecache.fileid', $query->createNamedParameter($fileIds, IQueryBuilder::PARAM_INT_ARRAY)));
$query->andWhere($query->expr()->eq('filecache.storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)));
$rows = $query->executeQuery()->fetchAllAssociative();
$rows = $query->executeQuery()->fetchAll();
return $this->rowsToEntries($rows);
}
@@ -105,7 +105,7 @@ class FileAccess implements IFileAccess {
->where($qb->expr()->eq('fileid', $qb->createNamedParameter($folderId, IQueryBuilder::PARAM_INT)));
$result = $qb->executeQuery();
/** @var array{path:string}|false $root */
$root = $result->fetchAssociative();
$root = $result->fetch();
$result->closeCursor();
if ($root === false) {
@@ -153,7 +153,7 @@ class FileAccess implements IFileAccess {
// If the filecache table is sharded we need to check with a separate query if the parent is encrypted
$rows = [];
do {
while (count($rows) < 1000 && ($row = $files->fetchAssociative())) {
while (count($rows) < 1000 && ($row = $files->fetch())) {
$rows[] = $row;
}
$parents = array_map(function ($row) {
@@ -165,7 +165,7 @@ class FileAccess implements IFileAccess {
$parentQuery->where($parentQuery->expr()->in('fileid', $parentQuery->createNamedParameter($parents, IQueryBuilder::PARAM_INT_ARRAY)));
$parentQuery->hintShardKey('storage', $storageId);
$result = $parentQuery->executeQuery();
$parentRows = $result->fetchAllAssociative();
$parentRows = $result->fetchAll();
$result->closeCursor();
$encryptedByFileId = array_column($parentRows, 'encrypted', 'fileid');
@@ -176,11 +176,11 @@ class FileAccess implements IFileAccess {
yield Cache::cacheEntryFromData($row, $this->mimeTypeLoader);
}
$rows = [];
} while ($rows[] = $files->fetchAssociative());
} while ($rows[] = $files->fetch());
} else {
while (
/** @var array */
$row = $files->fetchAssociative()
$row = $files->fetch()
) {
yield Cache::cacheEntryFromData($row, $this->mimeTypeLoader);
}
@@ -212,7 +212,7 @@ class FileAccess implements IFileAccess {
while (
/** @var array{storage_id:int, root_id:int,mount_provider_class:string} $row */
$row = $result->fetchAssociative()
$row = $result->fetch()
) {
$storageId = (int)$row['storage_id'];
$rootId = (int)$row['root_id'];
@@ -232,7 +232,7 @@ class FileAccess implements IFileAccess {
->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($rootId, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('path', $qb->createNamedParameter('files')));
/** @var array|false $root */
$root = $qb->executeQuery()->fetchAssociative();
$root = $qb->executeQuery()->fetch();
if ($root !== false) {
$overrideRoot = (int)$root['fileid'];
}
@@ -91,7 +91,7 @@ class QuerySearchHelper {
$result = $query->executeQuery();
/** @var list<array{id: int, name: string, visibility: int, editable: int, ref_file_id: int, number_files: int}> $tags */
$tags = $result->fetchAllAssociative();
$tags = $result->fetchAll();
$result->closeCursor();
return $tags;
}
@@ -172,7 +172,7 @@ class QuerySearchHelper {
$this->applySearchConstraints($query, $searchQuery, $caches, $metadataQuery);
$result = $query->executeQuery();
$files = $result->fetchAllAssociative();
$files = $result->fetchAll();
$rawEntries = array_map(function (array $data) use ($metadataQuery) {
$data['metadata'] = $metadataQuery->extractMetadata($data)->asArray();
+1 -1
View File
@@ -174,7 +174,7 @@ class Storage {
$query->select('storage_id')
->from('mounts')
->where($query->expr()->eq('mount_id', $query->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
$storageIds = $query->executeQuery()->fetchFirstColumn();
$storageIds = $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN);
$storageIds = array_unique($storageIds);
$query = $db->getQueryBuilder();
+3 -3
View File
@@ -44,7 +44,7 @@ class StorageGlobal {
->where($builder->expr()->in('id', $builder->createNamedParameter(array_values($storageIds), IQueryBuilder::PARAM_STR_ARRAY)));
$result = $query->executeQuery();
while (($row = $result->fetchAssociative()) !== false) {
while (($row = $result->fetch()) !== false) {
$normalizedRow = [
'id' => (string)$row['id'],
'numeric_id' => (int)$row['numeric_id'],
@@ -69,7 +69,7 @@ class StorageGlobal {
->where($builder->expr()->eq('id', $builder->createNamedParameter($storageId)));
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if ($row !== false) {
@@ -99,7 +99,7 @@ class StorageGlobal {
->where($builder->expr()->eq('numeric_id', $builder->createNamedParameter($numericId)));
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if ($row !== false) {
+24 -46
View File
@@ -7,10 +7,8 @@
*/
namespace OC\Files\Config;
use OC\DB\Exceptions\DbalException;
use OC\User\LazyUser;
use OCP\Cache\CappedMemoryCache;
use OCP\DB\Exception;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
@@ -167,25 +165,15 @@ class UserMountCache implements IUserMountCache {
private function addToCache(ICachedMountInfo $mount) {
if ($mount->getStorageId() !== -1) {
$qb = $this->connection->getQueryBuilder();
$qb
->insert('mounts')
->values([
'storage_id' => $qb->createNamedParameter($mount->getStorageId(), IQueryBuilder::PARAM_INT),
'root_id' => $qb->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT),
'user_id' => $qb->createNamedParameter($mount->getUser()->getUID()),
'mount_point' => $qb->createNamedParameter($mount->getMountPoint()),
'mount_point_hash' => $qb->createNamedParameter(hash('xxh128', $mount->getMountPoint())),
'mount_id' => $qb->createNamedParameter($mount->getMountId(), IQueryBuilder::PARAM_INT),
'mount_provider_class' => $qb->createNamedParameter($mount->getMountProvider()),
]);
try {
$qb->executeStatement();
} catch (Exception $e) {
if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
throw $e;
}
}
$this->connection->insertIgnoreConflict('mounts', [
'storage_id' => $mount->getStorageId(),
'root_id' => $mount->getRootId(),
'user_id' => $mount->getUser()->getUID(),
'mount_point' => $mount->getMountPoint(),
'mount_point_hash' => hash('xxh128', $mount->getMountPoint()),
'mount_id' => $mount->getMountId(),
'mount_provider_class' => $mount->getMountProvider(),
]);
} else {
// in some cases this is legitimate, like orphaned shares
$this->logger->debug('Could not get storage info for mount at ' . $mount->getMountPoint());
@@ -267,7 +255,7 @@ class UserMountCache implements IUserMountCache {
->where($builder->expr()->eq('user_id', $builder->createNamedParameter($userUID)));
$result = $query->executeQuery();
$rows = $result->fetchAllAssociative();
$rows = $result->fetchAll();
$result->closeCursor();
/** @var array<string, ICachedMountInfo> $mounts */
@@ -312,7 +300,7 @@ class UserMountCache implements IUserMountCache {
}
$result = $query->executeQuery();
$rows = $result->fetchAllAssociative();
$rows = $result->fetchAll();
$result->closeCursor();
return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows));
@@ -330,7 +318,7 @@ class UserMountCache implements IUserMountCache {
->where($builder->expr()->eq('root_id', $builder->createNamedParameter($rootFileId, IQueryBuilder::PARAM_INT)));
$result = $query->executeQuery();
$rows = $result->fetchAllAssociative();
$rows = $result->fetchAll();
$result->closeCursor();
return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows));
@@ -349,7 +337,7 @@ class UserMountCache implements IUserMountCache {
->where($builder->expr()->eq('fileid', $builder->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)));
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if (is_array($row)) {
@@ -408,7 +396,7 @@ class UserMountCache implements IUserMountCache {
$result = $query->executeQuery();
$mounts = [];
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
if ($user === null && !$this->userManager->userExists($row['user_id'])) {
continue;
}
@@ -481,7 +469,7 @@ class UserMountCache implements IUserMountCache {
$result = $query->executeQuery();
$results = [];
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$results[$row['user_id']] = $row['size'];
}
$result->closeCursor();
@@ -539,25 +527,15 @@ class UserMountCache implements IUserMountCache {
}
public function addMount(IUser $user, string $mountPoint, ICacheEntry $rootCacheEntry, string $mountProvider, ?int $mountId = null): void {
$query = $this->connection->getQueryBuilder();
$query->insert('mounts')
->values([
'storage_id' => $query->createNamedParameter($rootCacheEntry->getStorageId()),
'root_id' => $query->createNamedParameter($rootCacheEntry->getId()),
'user_id' => $query->createNamedParameter($user->getUID()),
'mount_point' => $query->createNamedParameter($mountPoint),
'mount_point_hash' => $query->createNamedParameter(hash('xxh128', $mountPoint)),
'mount_id' => $query->createNamedParameter($mountId),
'mount_provider_class' => $query->createNamedParameter($mountProvider)
]);
try {
$query->executeStatement();
} catch (DbalException $e) {
if ($e->getReason() !== DbalException::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
throw $e;
}
}
$this->connection->insertIgnoreConflict('mounts', [
'storage_id' => $rootCacheEntry->getStorageId(),
'root_id' => $rootCacheEntry->getId(),
'user_id' => $user->getUID(),
'mount_point' => $mountPoint,
'mount_point_hash' => hash('xxh128', $mountPoint),
'mount_id' => $mountId,
'mount_provider_class' => $mountProvider
]);
}
/**
+1 -1
View File
@@ -131,7 +131,7 @@ class Loader implements IMimeTypeLoader {
->from('mimetypes');
$result = $qb->executeQuery();
$results = $result->fetchAllAssociative();
$results = $result->fetchAll();
$result->closeCursor();
foreach ($results as $row) {
+32 -20
View File
@@ -96,12 +96,15 @@ class View {
}
/**
* @param ?string $path
* Returns an absolute path in Nextcloud's virtual filesystem for this view.
*
* The returned path is scoped by this view's fake root.
*
* @psalm-template S as string|null
* @psalm-param S $path
* @psalm-return (S is string ? string : null)
*/
public function getAbsolutePath($path = '/'): ?string {
public function getAbsolutePath(?string $path = '/'): ?string {
if ($path === null) {
return null;
}
@@ -185,33 +188,42 @@ class View {
}
/**
* Resolve a path to a storage and internal path
* Resolve a path to a storage and internal path.
*
* @param string $path
* @return array{?IStorage, string} an array consisting of the storage and the internal path
* Accepts both:
* - relative paths (interpreted relative to this view root), and
* - absolute paths in Nextcloud's virtual filesystem (leading '/').
*
* @param string $path Relative path, or absolute virtual filesystem path
* @return array{?IStorage, string} An array containing [storage, internalPath]
*/
public function resolvePath($path): array {
$a = $this->getAbsolutePath($path);
$p = Filesystem::normalizePath($a);
return Filesystem::resolvePath($p);
public function resolvePath(string $path): array {
$absolutePath = $this->getAbsolutePath($path);
$normalizedPath = Filesystem::normalizePath($absolutePath);
return Filesystem::resolvePath($normalizedPath);
}
/**
* Return the path to a local version of the file
* we need this because we can't know if a file is stored local or not from
* outside the filestorage and for some purposes a local file is needed
* Return the path to a local representation of a file.
*
* @param string $path
* For local storages this is usually the real on-disk path.
* For non-local storages this may be a temporary local file.
*
* @param string $path Path relative to this view, or absolute virtual filesystem path
* @return string|false Local file path, or false if unavailable
*/
public function getLocalFile($path): string|false {
$parent = substr($path, 0, strrpos($path, '/') ?: 0);
$path = $this->getAbsolutePath($path);
[$storage, $internalPath] = Filesystem::resolvePath($path);
if (Filesystem::isValidPath($parent) && $storage) {
return $storage->getLocalFile($internalPath);
} else {
public function getLocalFile(string $path): string|false {
$parentPath = dirname($path);
if (!Filesystem::isValidPath($parentPath)) {
return false;
}
[$storage, $internalPath] = $this->resolvePath($path);
if (!$storage) {
return false;
}
return $storage->getLocalFile($internalPath);
}
/**
@@ -41,7 +41,7 @@ class MetadataRequestService {
$query->select('storage')
->from('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($filesMetadata->getFileId(), IQueryBuilder::PARAM_INT)));
$storageId = (int)$query->executeQuery()->fetchOne();
$storageId = $query->executeQuery()->fetchColumn();
if ($filesMetadata instanceof FilesMetadata) {
$filesMetadata->setStorageId($storageId);
@@ -81,7 +81,7 @@ class MetadataRequestService {
$qb->select('json', 'sync_token')->from(self::TABLE_METADATA);
$qb->where($qb->expr()->eq('file_id', $qb->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)));
$result = $qb->executeQuery();
$data = $result->fetchAssociative();
$data = $result->fetch();
$result->closeCursor();
} catch (Exception $e) {
$this->logger->warning('exception while getMetadataFromDatabase()', ['exception' => $e, 'fileId' => $fileId]);
@@ -115,7 +115,7 @@ class MetadataRequestService {
$list = [];
$result = $qb->executeQuery();
while ($data = $result->fetchAssociative()) {
while ($data = $result->fetch()) {
$fileId = (int)$data['file_id'];
$metadata = new FilesMetadata($fileId);
try {
+7 -7
View File
@@ -146,7 +146,7 @@ class Database extends ABackend implements
->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid)))
->executeQuery();
$result = $cursor->fetchAssociative();
$result = $cursor->fetch();
$cursor->closeCursor();
return $result ? true : false;
@@ -221,7 +221,7 @@ class Database extends ABackend implements
->executeQuery();
$groups = [];
while ($row = $cursor->fetchAssociative()) {
while ($row = $cursor->fetch()) {
$groups[] = $row['gid'];
$this->groupCache[$row['gid']] = [
'gid' => $row['gid'],
@@ -268,7 +268,7 @@ class Database extends ABackend implements
$result = $query->executeQuery();
$groups = [];
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$this->groupCache[$row['gid']] = [
'displayname' => $row['displayname'],
'gid' => $row['gid'],
@@ -298,7 +298,7 @@ class Database extends ABackend implements
->from('groups')
->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid)))
->executeQuery();
$result = $cursor->fetchAssociative();
$result = $cursor->fetch();
$cursor->closeCursor();
if ($result !== false) {
@@ -335,7 +335,7 @@ class Database extends ABackend implements
foreach (array_chunk($notFoundGids, 1000) as $chunk) {
$qb->setParameter('ids', $chunk, IQueryBuilder::PARAM_STR_ARRAY);
$result = $qb->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$this->groupCache[(string)$row['gid']] = [
'displayname' => (string)$row['displayname'],
'gid' => (string)$row['gid'],
@@ -413,7 +413,7 @@ class Database extends ABackend implements
$users = [];
$userManager = Server::get(IUserManager::class);
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$users[$row['uid']] = new LazyUser($row['uid'], $userManager, $row['displayname'] ?? null);
}
$result->closeCursor();
@@ -544,7 +544,7 @@ class Database extends ABackend implements
->where($query->expr()->in('gid', $query->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY)));
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$details[(string)$row['gid']] = ['displayName' => (string)$row['displayname']];
$this->groupCache[(string)$row['gid']] = [
'displayname' => (string)$row['displayname'],
+3 -3
View File
@@ -63,14 +63,14 @@ class Manager extends PublicEmitter implements IGroupManager {
) {
$this->displayNameCache = new DisplayNameCache($cacheFactory, $this);
$this->listen('\OC\Group', 'postDelete', function (IGroup $group): void {
$this->listen('\OC\Group', 'preDelete', function (IGroup $group): void {
unset($this->cachedGroups[$group->getGID()]);
$this->cachedUserGroups = [];
});
$this->listen('\OC\Group', 'postAddUser', function (IGroup $group): void {
$this->listen('\OC\Group', 'preAddUser', function (IGroup $group): void {
$this->cachedUserGroups = [];
});
$this->listen('\OC\Group', 'postRemoveUser', function (IGroup $group): void {
$this->listen('\OC\Group', 'preRemoveUser', function (IGroup $group): void {
$this->cachedUserGroups = [];
});
}
+2 -2
View File
@@ -83,7 +83,7 @@ class BackgroundCleanupJob extends TimedJob {
}
$cursor = $qb->executeQuery();
while ($row = $cursor->fetchAssociative()) {
while ($row = $cursor->fetch()) {
yield (int)$row['file_id'];
}
$cursor->closeCursor();
@@ -101,7 +101,7 @@ class BackgroundCleanupJob extends TimedJob {
$qb->expr()->in('fileid', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)),
$qb->expr()->eq('storage', $qb->createNamedParameter($storage, IQueryBuilder::PARAM_INT)),
));
$found = $qb->executeQuery()->fetchFirstColumn();
$found = $qb->executeQuery()->fetchAll(\PDO::FETCH_COLUMN);
return array_diff($ids, $found);
}
}
+1 -1
View File
@@ -67,7 +67,7 @@ class PreviewService {
$found = false;
// Previews next to each others in the database are likely in the same storage, so group them
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$found = true;
if ($lastStorageId !== (int)$row['storage_id']) {
if ($lastStorageId !== -1) {
+2 -2
View File
@@ -66,7 +66,7 @@ class CleanTags implements IRepairStep {
$users = [];
$hadResults = false;
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$hadResults = true;
if (!$this->userManager->userExists($row['uid'])) {
$users[] = $row['uid'];
@@ -149,7 +149,7 @@ class CleanTags implements IRepairStep {
$result = $qb->executeQuery();
$orphanItems = [];
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$orphanItems[] = (int)$row[$deleteId];
}
+2 -2
View File
@@ -87,7 +87,7 @@ class Collation implements IRepairStep {
. " AND TABLE_NAME LIKE '*PREFIX*%'",
[$dbName]
);
$rows = $statement->fetchAllAssociative();
$rows = $statement->fetchAll();
$result = [];
foreach ($rows as $row) {
$result[$row['table']] = true;
@@ -102,7 +102,7 @@ class Collation implements IRepairStep {
. " AND TABLE_NAME LIKE '*PREFIX*%'",
[$dbName]
);
$rows = $statement->fetchAllAssociative();
$rows = $statement->fetchAll();
foreach ($rows as $row) {
$result[$row['table']] = true;
}
@@ -53,7 +53,7 @@ class OldGroupMembershipShares implements IRepairStep {
->where($query->expr()->eq('id', $deleteQuery->createParameter('share')));
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
if (!$this->isMember($row['group'], $row['user'])) {
$deletedEntries += $deleteQuery->setParameter('share', (int)$row['id'])
->executeStatement();
@@ -109,7 +109,7 @@ class MigrateOauthTables implements IRepairStep {
->from('oauth2_clients');
$result = $qbSelect->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$id = $row['id'];
$shortenedName = mb_substr($row['name'], 0, 64);
$qb->setParameter('theId', $id, IQueryBuilder::PARAM_INT);
@@ -147,7 +147,7 @@ class MigrateOauthTables implements IRepairStep {
$selectQuery = $this->db->getQueryBuilder();
$selectQuery->select('id', 'identifier')->from('oauth2_clients');
$result = $selectQuery->executeQuery();
$identifiers = $result->fetchAllAssociative();
$identifiers = $result->fetchAll();
$result->closeCursor();
// 2. Insert them into the client_identifier column.
@@ -218,7 +218,7 @@ class MigrateOauthTables implements IRepairStep {
$result = $qbSelect->executeQuery();
$now = $this->timeFactory->now()->getTimestamp();
$index = 0;
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$clientId = $row['client_id'];
$refreshToken = $row['token'];
@@ -110,7 +110,7 @@ class SaveAccountsTableData implements IRepairStep {
->where($update->expr()->eq('uid', $update->createParameter('userid')));
$updatedUsers = 0;
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
try {
$this->migrateUserInfo($update, $row);
} catch (PreConditionNotMetException|\UnexpectedValueException) {
@@ -35,7 +35,7 @@ class RemoveBrokenProperties implements IRepairStep {
$result = $qb->executeQuery();
// find broken object properties
$brokenIds = [];
while ($entry = $result->fetchAssociative()) {
while ($entry = $result->fetch()) {
if (!empty($entry['propertyvalue'])) {
$object = @unserialize(str_replace('\x00', chr(0), $entry['propertyvalue']));
if ($object === false) {
+2 -2
View File
@@ -87,7 +87,7 @@ class RemoveLinkShares implements IRepairStep {
->where($query->expr()->in('id', $query->createFunction($subQuery->getSQL())));
$result = $query->executeQuery();
$data = $result->fetchAssociative();
$data = $result->fetch();
$result->closeCursor();
return (int)$data['total'];
@@ -166,7 +166,7 @@ class RemoveLinkShares implements IRepairStep {
$output->startProgress($total);
$shareResult = $this->getShares();
while ($data = $shareResult->fetchAssociative()) {
while ($data = $shareResult->fetch()) {
$this->processShare($data);
$output->advance();
}
+1 -1
View File
@@ -49,7 +49,7 @@ class RepairDavShares implements IRepairStep {
->where($updateQuery->expr()->eq('id', $updateQuery->createParameter('shareId')));
$statement = $qb->executeQuery();
while ($share = $statement->fetchAssociative()) {
while ($share = $statement->fetch()) {
$gid = substr($share['principaluri'], strlen(self::GROUP_PRINCIPAL_PREFIX));
$decodedGid = urldecode($gid);
$encodedGid = urlencode($gid);
+1 -1
View File
@@ -72,7 +72,7 @@ class RepairInvalidShares implements IRepairStep {
while ($deletedInLastChunk === self::CHUNK_SIZE) {
$deletedInLastChunk = 0;
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$deletedInLastChunk++;
$deletedEntries += $deleteQuery->setParameter('parent', (int)$row['parent'])
->executeStatement();
@@ -43,7 +43,7 @@ class DatabaseBackend implements IBackend {
}
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
return (int)$row['attempts'];
+1 -1
View File
@@ -61,7 +61,7 @@ class CredentialsManager implements ICredentialsManager {
}
$qResult = $qb->executeQuery();
$result = $qResult->fetchAssociative();
$result = $qResult->fetch();
$qResult->closeCursor();
if (!$result) {
+3 -3
View File
@@ -65,7 +65,7 @@ class MySQL extends AbstractDatabase {
//we can't use OC_DB functions here because we need to connect as the administrative user.
$characterSet = $this->config->getValue('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8';
$query = "CREATE DATABASE IF NOT EXISTS `$name` CHARACTER SET $characterSet COLLATE {$characterSet}_bin;";
$connection->executeStatement($query);
$connection->executeUpdate($query);
} catch (\Exception $ex) {
$this->logger->error('Database creation failed.', [
'exception' => $ex,
@@ -77,7 +77,7 @@ class MySQL extends AbstractDatabase {
try {
//this query will fail if there aren't the right permissions, ignore the error
$query = "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `$name` . * TO '$user'";
$connection->executeStatement($query);
$connection->executeUpdate($query);
} catch (\Exception $ex) {
$this->logger->debug('Could not automatically grant privileges, this can be ignored if database user already had privileges.', [
'exception' => $ex,
@@ -152,7 +152,7 @@ class MySQL extends AbstractDatabase {
$result = $connection->executeQuery($query, [$adminUser]);
//current dbuser has admin rights
$data = $result->fetchAllAssociative();
$data = $result->fetchAll();
$result->closeCursor();
//new dbuser does not exist
if (count($data) === 0) {
+17 -17
View File
@@ -340,7 +340,7 @@ class DefaultShareProvider implements
->andWhere($qb->expr()->in('item_type', $qb->createNamedParameter(['file', 'folder'], IQueryBuilder::PARAM_STR_ARRAY)))
->executeQuery();
$data = $stmt->fetchAssociative();
$data = $stmt->fetch();
$stmt->closeCursor();
/*
@@ -392,7 +392,7 @@ class DefaultShareProvider implements
->orderBy('id');
$cursor = $qb->executeQuery();
while ($data = $cursor->fetchAssociative()) {
while ($data = $cursor->fetch()) {
$children[] = $this->createShare($data);
}
$cursor->closeCursor();
@@ -454,7 +454,7 @@ class DefaultShareProvider implements
->andWhere($qb->expr()->in('item_type', $qb->createNamedParameter(['file', 'folder'], IQueryBuilder::PARAM_STR_ARRAY)))
->executeQuery();
$data = $stmt->fetchAssociative();
$data = $stmt->fetch();
/*
* Check if there already is a user specific group share.
@@ -533,7 +533,7 @@ class DefaultShareProvider implements
$qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))
);
$cursor = $qb->executeQuery();
$data = $cursor->fetchAssociative();
$data = $cursor->fetch();
$cursor->closeCursor();
$originalPermission = $data['permissions'];
@@ -577,7 +577,7 @@ class DefaultShareProvider implements
->setMaxResults(1)
->executeQuery();
$data = $stmt->fetchAssociative();
$data = $stmt->fetch();
$stmt->closeCursor();
$shareAttributes = $this->formatShareAttributes(
@@ -687,7 +687,7 @@ class DefaultShareProvider implements
foreach ($chunks as $chunk) {
$qb->setParameter('chunk', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
$cursor = $qb->executeQuery();
while ($data = $cursor->fetchAssociative()) {
while ($data = $cursor->fetch()) {
$shares[$data['fileid']][] = $this->createShare($data);
}
$cursor->closeCursor();
@@ -736,7 +736,7 @@ class DefaultShareProvider implements
$cursor = $qb->executeQuery();
$shares = [];
while ($data = $cursor->fetchAssociative()) {
while ($data = $cursor->fetch()) {
$shares[] = $this->createShare($data);
}
$cursor->closeCursor();
@@ -766,7 +766,7 @@ class DefaultShareProvider implements
->andWhere($qb->expr()->in('item_type', $qb->createNamedParameter(['file', 'folder'], IQueryBuilder::PARAM_STR_ARRAY)));
$cursor = $qb->executeQuery();
$data = $cursor->fetchAssociative();
$data = $cursor->fetch();
$cursor->closeCursor();
if ($data === false) {
@@ -805,7 +805,7 @@ class DefaultShareProvider implements
->executeQuery();
$shares = [];
while ($data = $cursor->fetchAssociative()) {
while ($data = $cursor->fetch()) {
$shares[] = $this->createShare($data);
}
$cursor->closeCursor();
@@ -927,7 +927,7 @@ class DefaultShareProvider implements
$cursor = $qb->executeQuery();
while ($data = $cursor->fetchAssociative()) {
while ($data = $cursor->fetch()) {
if ($data['fileid'] && $data['path'] === null) {
$data['path'] = (string)$data['path'];
$data['name'] = (string)$data['name'];
@@ -1018,7 +1018,7 @@ class DefaultShareProvider implements
->andWhere($qb->expr()->in('s.item_type', $qb->createNamedParameter(['file', 'folder'], IQueryBuilder::PARAM_STR_ARRAY)));
$cursor = $qb->executeQuery();
while ($data = $cursor->fetchAssociative()) {
while ($data = $cursor->fetch()) {
if ($offset > 0) {
$offset--;
continue;
@@ -1061,7 +1061,7 @@ class DefaultShareProvider implements
->andWhere($qb->expr()->in('item_type', $qb->createNamedParameter(['file', 'folder'], IQueryBuilder::PARAM_STR_ARRAY)))
->executeQuery();
$data = $cursor->fetchAssociative();
$data = $cursor->fetch();
if ($data === false) {
throw new ShareNotFound();
@@ -1176,7 +1176,7 @@ class DefaultShareProvider implements
$stmt = $query->executeQuery();
while ($data = $stmt->fetchAssociative()) {
while ($data = $stmt->fetch()) {
if (array_key_exists($data['parent'], $shareMap)) {
$shareMap[$data['parent']]->setPermissions((int)$data['permissions']);
$shareMap[$data['parent']]->setStatus((int)$data['accepted']);
@@ -1272,7 +1272,7 @@ class DefaultShareProvider implements
$cursor = $qb->executeQuery();
$ids = [];
while ($row = $cursor->fetchAssociative()) {
while ($row = $cursor->fetch()) {
$ids[] = (int)$row['id'];
}
$cursor->closeCursor();
@@ -1320,7 +1320,7 @@ class DefaultShareProvider implements
$cursor = $qb->executeQuery();
$ids = [];
while ($row = $cursor->fetchAssociative()) {
while ($row = $cursor->fetch()) {
$ids[] = (int)$row['id'];
}
$cursor->closeCursor();
@@ -1423,7 +1423,7 @@ class DefaultShareProvider implements
$users = [];
$link = false;
while ($row = $cursor->fetchAssociative()) {
while ($row = $cursor->fetch()) {
$type = (int)$row['share_type'];
if ($type === IShare::TYPE_USER) {
$uid = $row['share_with'];
@@ -1726,7 +1726,7 @@ class DefaultShareProvider implements
->where($qb->expr()->in('share_type', $qb->createNamedParameter([IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK], IQueryBuilder::PARAM_INT_ARRAY)));
$cursor = $qb->executeQuery();
while ($data = $cursor->fetchAssociative()) {
while ($data = $cursor->fetch()) {
try {
$share = $this->createShare($data);
} catch (InvalidShare $e) {
+1 -1
View File
@@ -1069,7 +1069,7 @@ class Manager implements IManager {
$cursor = $qb->executeQuery();
/** @var array<string, list<array{IShare::TYPE_*, Node}>> $rawShare */
$rawShares = [];
while ($data = $cursor->fetchAssociative()) {
while ($data = $cursor->fetch()) {
if (!isset($rawShares[$data['uid_initiator']])) {
$rawShares[$data['uid_initiator']] = [];
}
+5 -5
View File
@@ -106,7 +106,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin {
->executeQuery();
$groups = [];
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$groups[] = $row['gid'];
}
$result->closeCursor();
@@ -139,7 +139,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin {
->executeQuery();
$users = [];
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$user = $this->userManager->get($row['uid']);
if (!is_null($user)) {
$users[] = $user;
@@ -162,7 +162,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin {
->executeQuery();
$subadmins = [];
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$user = $this->userManager->get($row['uid']);
$group = $this->groupManager->get($row['gid']);
if (!is_null($user) && !is_null($group)) {
@@ -195,7 +195,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin {
->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
->executeQuery();
$fetch = $result->fetchAssociative();
$fetch = $result->fetch();
$result->closeCursor();
$result = !empty($fetch) ? true : false;
@@ -226,7 +226,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin {
->setMaxResults(1)
->executeQuery();
$isSubAdmin = $result->fetchAssociative();
$isSubAdmin = $result->fetch();
$result->closeCursor();
return $isSubAdmin !== false;
+4 -4
View File
@@ -75,7 +75,7 @@ class SystemTagManager implements ISystemTagManager {
->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY);
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$tag = $this->createSystemTagFromRow($row);
if ($user && !$this->canUserSeeTag($tag, $user)) {
// if a user is given, hide invisible tags
@@ -121,7 +121,7 @@ class SystemTagManager implements ISystemTagManager {
->addOrderBy('editable', 'ASC');
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$tags[$row['id']] = $this->createSystemTagFromRow($row);
}
@@ -139,7 +139,7 @@ class SystemTagManager implements ISystemTagManager {
->setParameter('editable', $userAssignable ? 1 : 0)
->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
if (!$row) {
throw new TagNotFoundException(
@@ -452,7 +452,7 @@ class SystemTagManager implements ISystemTagManager {
->orderBy('gid');
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$groupIds[] = $row['gid'];
}
@@ -56,7 +56,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
foreach ($chunks as $chunk) {
$query->setParameter('objectids', $chunk, IQueryBuilder::PARAM_STR_ARRAY);
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$objectId = $row['objectid'];
$mapping[$objectId][] = (string)$row['systemtagid'];
}
@@ -99,7 +99,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
$objectIds = [];
$result = $query->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$objectIds[] = $row['objectid'];
}
$result->closeCursor();
@@ -123,7 +123,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
->andWhere($query->expr()->eq('objecttype', $query->createNamedParameter($objectType)))
->andWhere($query->expr()->eq('objectid', $query->createNamedParameter($objId)));
$result = $query->executeQuery();
$rows = $result->fetchAllAssociative();
$rows = $result->fetchAll();
$existingTags = [];
foreach ($rows as $row) {
$existingTags[] = $row['systemtagid'];
@@ -259,7 +259,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
->setParameter('objecttype', $objectType);
$result = $query->executeQuery();
$row = $result->fetchNumeric();
$row = $result->fetch(\PDO::FETCH_NUM);
$result->closeCursor();
if ($all) {
@@ -376,7 +376,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
$result = $query->executeQuery();
$objectTypes = [];
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$objectTypes[] = $row['objecttype'];
}
$result->closeCursor();
+2 -2
View File
@@ -79,7 +79,7 @@ class TagManager implements ITagManager, IEventListener {
->andWhere($query->expr()->eq('c.category', $query->createNamedParameter(ITags::TAG_FAVORITE)));
$result = $query->executeQuery();
$users = $result->fetchFirstColumn();
$users = $result->fetchAll(\PDO::FETCH_COLUMN);
$result->closeCursor();
return $users;
@@ -106,7 +106,7 @@ class TagManager implements ITagManager, IEventListener {
return;
}
$tagsIds = array_map(fn (array $row) => (int)$row['id'], $result->fetchAllAssociative());
$tagsIds = array_map(fn (array $row) => (int)$row['id'], $result->fetchAll());
$result->closeCursor();
if (count($tagsIds) === 0) {
+2 -2
View File
@@ -159,7 +159,7 @@ class Tags implements ITags {
$qb->setParameter('type', $this->type, IQueryBuilder::PARAM_STR);
$qb->setParameter('chunk', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
$result = $qb->executeQuery();
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$objId = (int)$row['objid'];
if (!isset($entries[$objId])) {
$entries[$objId] = [];
@@ -223,7 +223,7 @@ class Tags implements ITags {
return false;
}
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$ids[] = (int)$row['objid'];
}
$result->closeCursor();
+1 -1
View File
@@ -276,7 +276,7 @@ class TaskMapper extends QBMapper {
$qb->andWhere($qb->expr()->eq('status', $qb->createNamedParameter(\OCP\TaskProcessing\Task::STATUS_RUNNING, IQueryBuilder::PARAM_INT)));
$qb->setMaxResults(1);
$result = $qb->executeQuery();
$hasRunningTasks = $result->fetchAssociative() !== false;
$hasRunningTasks = $result->fetch() !== false;
$result->closeCursor();
return $hasRunningTasks;
}
+3 -3
View File
@@ -289,7 +289,7 @@ class Database extends ABackend implements
$result = $query->executeQuery();
$displayNames = [];
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$displayNames[(string)$row['uid']] = (string)$row['displayname'];
}
@@ -328,7 +328,7 @@ class Database extends ABackend implements
$result = $query->executeQuery();
$displayNames = [];
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$displayNames[(string)$row['uid']] = (string)$row['displayname'];
}
@@ -389,7 +389,7 @@ class Database extends ABackend implements
)
);
$result = $qb->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
$result->closeCursor();
// "uid" is primary key, so there can only be a single result
+2 -2
View File
@@ -651,7 +651,7 @@ class Manager extends PublicEmitter implements IUserManager {
$query = $queryBuilder->executeQuery();
$result = [];
while ($row = $query->fetchAssociative()) {
while ($row = $query->fetch()) {
$result[] = $row['userid'];
}
@@ -774,7 +774,7 @@ class Manager extends PublicEmitter implements IUserManager {
}
/** @var list<string> */
$list = $queryBuilder->executeQuery()->fetchFirstColumn();
$list = $queryBuilder->executeQuery()->fetchAll(\PDO::FETCH_COLUMN);
return $list;
}
+4 -4
View File
@@ -275,7 +275,7 @@ abstract class QBMapper {
protected function findOneQuery(IQueryBuilder $query): array {
$result = $query->executeQuery();
$row = $result->fetchAssociative();
$row = $result->fetch();
if ($row === false) {
$result->closeCursor();
$msg = $this->buildDebugMessage(
@@ -284,7 +284,7 @@ abstract class QBMapper {
throw new DoesNotExistException($msg);
}
$row2 = $result->fetchAssociative();
$row2 = $result->fetch();
$result->closeCursor();
if ($row2 !== false) {
$msg = $this->buildDebugMessage(
@@ -336,7 +336,7 @@ abstract class QBMapper {
$result = $query->executeQuery();
try {
$entities = [];
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
$entities[] = $this->mapRowToEntity($row);
}
return $entities;
@@ -357,7 +357,7 @@ abstract class QBMapper {
protected function yieldEntities(IQueryBuilder $query): Generator {
$result = $query->executeQuery();
try {
while ($row = $result->fetchAssociative()) {
while ($row = $result->fetch()) {
yield $this->mapRowToEntity($row);
}
} finally {

Some files were not shown because too many files have changed in this diff Show More