-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
perf: Introduce LazyGroup #61871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
perf: Introduce LazyGroup #61871
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2016 ownCloud, Inc. | ||
| * SPDX-License-Identifier: AGPL-3.0-only | ||
| */ | ||
|
|
||
| namespace OC\Group; | ||
|
|
||
| use OCP\EventDispatcher\IEventDispatcher; | ||
| use OCP\IGroup; | ||
| use OCP\IGroupManager; | ||
| use OCP\IUser; | ||
| use OCP\IUserManager; | ||
| use OCP\Server; | ||
| use Psr\Log\LoggerInterface; | ||
|
|
||
| class LazyGroup implements IGroup { | ||
| private ?IGroup $group = null; | ||
| private ?bool $isDeleted = null; | ||
|
|
||
| public function __construct( | ||
| private string $gid, | ||
| private IGroupManager $groupManager, | ||
| ) { | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getGID(): string { | ||
| return $this->gid; | ||
| } | ||
|
|
||
| private function getGroup(): IGroup { | ||
| if ($this->group === null) { | ||
| $this->group = $this->groupManager->get($this->gid); | ||
| ; | ||
|
CarlSchwan marked this conversation as resolved.
Outdated
|
||
| } | ||
| if ($this->group === null) { | ||
| Server::get(LoggerInterface::class)->debug('Trying to use the deleted group: "' . $this->gid . '"', ['app' => 'core']); | ||
| $this->isDeleted = true; | ||
| $this->group = new Group($this->gid, [], Server::get(IEventDispatcher::class), Server::get(IUserManager::class)); | ||
| } else { | ||
| $this->isDeleted = false; | ||
| } | ||
| return $this->group; | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getDisplayName(): string { | ||
|
Check failure on line 50 in lib/private/Group/LazyGroup.php
|
||
| // Use display name cache from IGroupManager | ||
| return $this->groupManager->getDisplayName($this->gid); | ||
|
Check failure on line 52 in lib/private/Group/LazyGroup.php
|
||
| } | ||
|
|
||
| #[\Override] | ||
| public function setDisplayName(string $displayName): bool { | ||
| return $this->group->setDisplayName($displayName); | ||
|
CarlSchwan marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| #[\Override] | ||
| public function getUsers(): array { | ||
| return $this->getGroup()->getUsers(); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function inGroup(IUser $user): bool { | ||
| return $this->getGroup()->inGroup($user); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function addUser(IUser $user): void { | ||
| $this->getGroup()->addUser($user); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function removeUser(IUser $user): void { | ||
| $this->getGroup()->removeUser($user); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function searchUsers(string $search, ?int $limit = null, ?int $offset = null): array { | ||
| return $this->getGroup()->searchUsers($search, $limit, $offset); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function count($search = ''): int|bool { | ||
| return $this->getGroup()->count($search); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function countDisabled(): int|bool { | ||
| return $this->getGroup()->countDisabled(); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function searchDisplayName(string $search, ?int $limit = null, ?int $offset = null): array { | ||
| return $this->getGroup()->searchDisplayName($search, $limit, $offset); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function getBackendNames(): array { | ||
| return $this->getGroup()->getBackendNames(); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function delete(): bool { | ||
| return $this->getGroup()->delete(); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function canRemoveUser(): bool { | ||
| return $this->getGroup()->canRemoveUser(); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function canAddUser(): bool { | ||
| return $this->getGroup()->canAddUser(); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function hideFromCollaboration(): bool { | ||
| return $this->getGroup()->hideFromCollaboration(); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function isDeleted(): bool { | ||
| if ($this->isDeleted === null) { | ||
| $this->getGroup(); | ||
| } | ||
|
CarlSchwan marked this conversation as resolved.
Outdated
|
||
| return $this->isDeleted === true ? true : $this->getGroup()->isDeleted(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.