Skip to content

perf: Introduce LazyGroup#61871

Open
CarlSchwan wants to merge 2 commits into
masterfrom
carl/lazy-group
Open

perf: Introduce LazyGroup#61871
CarlSchwan wants to merge 2 commits into
masterfrom
carl/lazy-group

Conversation

@CarlSchwan

Copy link
Copy Markdown
Member

Similar to LazyUser, this allow to get a IGroup object where properties are lazyly evaluated only when needed.

This also reuse the DisplayNameCache from the IGroupManager.

  • Resolves: #

Summary

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Similar to LazyUser, this allow to get a IGroup object where properties
are lazyly evaluated only when needed.

This also reuse the DisplayNameCache from the IGroupManager.

Signed-off-by: Carl Schwan <carlschwan@kde.org>
@CarlSchwan CarlSchwan added this to the Nextcloud 35 milestone Jul 7, 2026
@CarlSchwan CarlSchwan self-assigned this Jul 7, 2026
@CarlSchwan CarlSchwan requested a review from a team as a code owner July 7, 2026 11:49
@CarlSchwan CarlSchwan requested review from Altahrim and icewind1991 and removed request for a team July 7, 2026 11:49
if ($aGroup instanceof IGroup) {
$groups[$groupId] = $aGroup;
} else {
$this->logger->debug('User "' . $uid . '" belongs to deleted group: "' . $groupId . '"', ['app' => 'core']);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure if this can actually happen as it is weird that getUserIdGroupIds would return an invalid group

Signed-off-by: Carl Schwan <carlschwan@kde.org>
@@ -0,0 +1,132 @@
<?php

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict types!

private function getGroup(): IGroup {
if ($this->group === null) {
$this->group = $this->groupManager->get($this->gid);
;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
;


#[\Override]
public function setDisplayName(string $displayName): bool {
return $this->group->setDisplayName($displayName);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return $this->group->setDisplayName($displayName);
return $this->getGroup()->setDisplayName($displayName);

Comment on lines +127 to +129
if ($this->isDeleted === null) {
$this->getGroup();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($this->isDeleted === null) {
$this->getGroup();
}

Useless I think, getGroup is called below anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants