Skip to content

Commit f7237a4

Browse files
Merge pull request #3571 from nextcloud/fix/noid/improve-team-folders
lighter request on circle memberships
2 parents 5405ae3 + 82f40cf commit f7237a4

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

β€Žlib/Folder/FolderManager.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,15 @@ public function getFoldersFromCircleMemberships(IUser $user, int $rootStorageId
702702
'group_folders_groups',
703703
'a',
704704
$query->expr()->eq('f.folder_id', 'a.folder_id')
705-
);
705+
)
706+
->where($query->expr()->neq('a.circle_id', $query->createNamedParameter('')));
706707

707-
$queryHelper->limitToInheritedMembers('a', 'circle_id', $federatedUser);
708+
/** @psalm-suppress RedundantCondition */
709+
if (method_exists($queryHelper, 'limitToMemberships')) {
710+
$queryHelper->limitToMemberships('a', 'circle_id', $federatedUser);
711+
} else {
712+
$queryHelper->limitToInheritedMembers('a', 'circle_id', $federatedUser);
713+
}
708714
$this->joinQueryWithFileCache($query, $rootStorageId);
709715

710716
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)