Skip to content

refactor(GroupInterface): Cleanup the group backends - #61745

Open
CarlSchwan wants to merge 2 commits into
masterfrom
carl/groupbackend-cleanups
Open

refactor(GroupInterface): Cleanup the group backends#61745
CarlSchwan wants to merge 2 commits into
masterfrom
carl/groupbackend-cleanups

Conversation

@CarlSchwan

Copy link
Copy Markdown
Member
  • Use as much typing as possible
  • Remove unused interface in ILDAPGroupPlugin
  • Mark group backends as implementing a few more interface
  • Resolves: #

Summary

TODO

  • ...

Checklist

AI (if applicable)

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

- Use as much typing as possible
- Remove unused interface in ILDAPGroupPlugin
- Mark group backends as implementing a few more interface

Signed-off-by: Carl Schwan <carlschwan@kde.org>
@CarlSchwan
CarlSchwan requested a review from a team as a code owner July 3, 2026 09:03
@CarlSchwan
CarlSchwan requested review from Altahrim, come-nc, leftybournes and salmart-dev and removed request for a team July 3, 2026 09:03
@CarlSchwan CarlSchwan self-assigned this Jul 3, 2026
@CarlSchwan CarlSchwan added the 3. to review Waiting for reviews label Jul 3, 2026
@CarlSchwan CarlSchwan added this to the Nextcloud 35 milestone Jul 3, 2026
Signed-off-by: Carl Schwan <carlschwan@kde.org>
@susnux susnux added the ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) label Jul 3, 2026
@susnux

susnux commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Comment on lines -1324 to 1257
/**
* Gets group details
*
* @param string $gid Name of the group
* @return array|false
* @throws Exception
*/
public function getGroupDetails($gid) {
if ($this->groupPluginManager->implementsActions(GroupInterface::GROUP_DETAILS)) {
return $this->groupPluginManager->getGroupDetails($gid);
#[\Override]
public function getGroupDetails(string $gid): array {
$displayName = $this->getDisplayName($gid);
if ($displayName !== '') {
return ['displayName' => $displayName];
}
throw new Exception('Could not get group details in LDAP backend.');

return [];
}

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.

Here you remove the support for overriding getGroupDetails from a user_ldap plugin?

Comment on lines -141 to -171

/**
* get the number of all users matching the search string in a group
* @param string $gid ID of the group
* @param string $search query string
* @return int|false
* @throws \Exception
*/
public function countUsersInGroup($gid, $search = '') {
$plugin = $this->which[GroupInterface::COUNT_USERS];

if ($plugin) {
return $plugin->countUsersInGroup($gid, $search);
}
throw new \Exception('No plugin implements countUsersInGroup in this LDAP Backend.');
}

/**
* get an array with group details
* @param string $gid
* @return array|false
* @throws \Exception
*/
public function getGroupDetails($gid) {
$plugin = $this->which[GroupInterface::GROUP_DETAILS];

if ($plugin) {
return $plugin->getGroupDetails($gid);
}
throw new \Exception('No plugin implements getGroupDetails in this LDAP Backend.');
}

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.

Why do you remove support for these? Because it’s unused?


namespace OCA\User_LDAP;

use OCP\AppFramework\Attribute\Consumable;

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.

Forgot to actually add the attribute?

@@ -182,7 +163,7 @@ public function removeUser(IUser $user): void {
$this->emitter->emit('\OC\Group', 'preRemoveUser', [$this, $user]);
}
foreach ($this->backends as $backend) {
if ($backend->implementsActions(\OC\Group\Backend::REMOVE_FROM_GOUP) && $backend->inGroup($user->getUID(), $this->gid)) {
if ($backend->implementsActions(\OCP\GroupInterface::REMOVE_FROM_GOUP) && $backend->inGroup($user->getUID(), $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
if ($backend->implementsActions(\OCP\GroupInterface::REMOVE_FROM_GOUP) && $backend->inGroup($user->getUID(), $this->gid)) {
if ($backend->implementsActions(\OCP\GroupInterface::REMOVE_FROM_GROUP) && $backend->inGroup($user->getUID(), $this->gid)) {

@@ -35,7 +38,6 @@ interface GroupInterface {

/**
* @since 12.0.0
* @deprecated 29.0.0

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.

Please put that back. Or you can even remove the const I guess.

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

Labels

3. to review Waiting for reviews ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants