Skip to content

Commit 5f1e6bd

Browse files
committed
lighter request on circle memberships
1 parent 3b251ea commit 5f1e6bd

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

β€Žlib/Folder/FolderManager.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,14 @@ public function getFoldersFromCircleMemberships(IUser $user, int $rootStorageId
634634
'group_folders_groups',
635635
'a',
636636
$query->expr()->eq('f.folder_id', 'a.folder_id')
637-
);
637+
)
638+
->where($query->expr()->neq('a.circle_id', $query->createNamedParameter('')));
638639

639-
$queryHelper->limitToInheritedMembers('a', 'circle_id', $federatedUser);
640+
if (method_exists($queryHelper, 'limitToMemberships')) {
641+
$queryHelper->limitToMemberships('a', 'circle_id', $federatedUser);
642+
} else {
643+
$queryHelper->limitToInheritedMembers('a', 'circle_id', $federatedUser);
644+
}
640645
$this->joinQueryWithFileCache($query, $rootStorageId);
641646

642647
return array_map(fn (array $folder): array => [
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+
}

β€Žtests/stubs/oca_circles_circlesqueryhelper.php

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public function limitToInheritedMembers(string $alias, string $field, IFederated
7474
{
7575
}
7676

77+
public function limitToMemberships(string $alias, string $field, IFederatedUser $federatedUser): void
78+
{
79+
}
80+
7781

7882
/**
7983
* @param string $field

0 commit comments

Comments
Β (0)