Skip to content

Commit 53db1aa

Browse files
ArtificialOwlicewind1991
authored andcommitted
lighter request on circle memberships
Signed-off-by: Maxence Lange <[email protected]>
1 parent 60ef403 commit 53db1aa

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

β€Žlib/Folder/FolderManager.phpβ€Ž

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,14 @@ public function getFoldersFromCircleMemberships(IUser $user, int $rootStorageId
684684
'group_folders_groups',
685685
'a',
686686
$query->expr()->eq('f.folder_id', 'a.folder_id')
687-
);
687+
)
688+
->where($query->expr()->neq('a.circle_id', $query->createNamedParameter('')));
688689

689-
$queryHelper->limitToInheritedMembers('a', 'circle_id', $federatedUser);
690+
if (method_exists($queryHelper, 'limitToMemberships')) {
691+
$queryHelper->limitToMemberships('a', 'circle_id', $federatedUser);
692+
} else {
693+
$queryHelper->limitToInheritedMembers('a', 'circle_id', $federatedUser);
694+
}
690695
$this->joinQueryWithFileCache($query, $rootStorageId);
691696

692697
return array_map(function (array $folder): array {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
6+
* SPDX-License-Identifier: AGPL-3.0-or-later
7+
*/
8+
namespace OCA\GroupFolders\Migration;
9+
10+
use Closure;
11+
use OCP\DB\ISchemaWrapper;
12+
use OCP\Migration\Attributes\AddIndex;
13+
use OCP\Migration\Attributes\IndexType;
14+
use OCP\Migration\IOutput;
15+
use OCP\Migration\SimpleMigrationStep;
16+
17+
#[AddIndex('group_folders_groups', IndexType::INDEX, 'adding index on single circle id for better select')]
18+
class Version2000000Date20250128110101 extends SimpleMigrationStep {
19+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
20+
/** @var ISchemaWrapper $schema */
21+
$schema = $schemaClosure();
22+
23+
// we recreate the unique key, including circle_id
24+
$table = $schema->getTable('group_folders_groups');
25+
if (!$table->hasIndex('groups_folder_circle')) {
26+
$table->addIndex(['circle_id'], 'groups_folder_circle');
27+
}
28+
29+
return $schema;
30+
}
31+
}

0 commit comments

Comments
Β (0)