Skip to content

Commit 8a67b57

Browse files
committed
refactor: Remove isDeleted method
Not used Signed-off-by: Carl Schwan <carlschwan@kde.org>
1 parent c7075cc commit 8a67b57

4 files changed

Lines changed: 5 additions & 53 deletions

File tree

lib/private/Group/Group.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class Group implements IGroup {
4040
/** @var User[] */
4141
private array $users = [];
4242
private bool $usersLoaded = false;
43-
private bool $isDeleted = false;
4443

4544
public function __construct(
4645
private string $gid,
@@ -337,7 +336,6 @@ public function delete(): bool {
337336
$this->emitter->emit('\OC\Group', 'postDelete', [$this]);
338337
}
339338
}
340-
$this->isDeleted = $result;
341339
return $result;
342340
}
343341

@@ -395,8 +393,4 @@ public function hideFromCollaboration(): bool {
395393
return $hide || ($backend instanceof IHideFromCollaborationBackend && $backend->hideGroup($this->gid));
396394
}, false);
397395
}
398-
399-
public function isDeleted(): bool {
400-
return $this->isDeleted;
401-
}
402396
}

lib/private/Group/LazyGroup.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -18,7 +20,6 @@
1820

1921
class LazyGroup implements IGroup {
2022
private ?IGroup $group = null;
21-
private ?bool $isDeleted = null;
2223

2324
public function __construct(
2425
private string $gid,
@@ -34,27 +35,23 @@ public function getGID(): string {
3435
private function getGroup(): IGroup {
3536
if ($this->group === null) {
3637
$this->group = $this->groupManager->get($this->gid);
37-
;
3838
}
3939
if ($this->group === null) {
40-
Server::get(LoggerInterface::class)->debug('Trying to use the deleted group: "' . $this->gid . '"', ['app' => 'core']);
41-
$this->isDeleted = true;
40+
Server::get(LoggerInterface::class)->error('Trying to use the deleted group: "' . $this->gid . '"', ['app' => 'core']);
4241
$this->group = new Group($this->gid, [], Server::get(IEventDispatcher::class), Server::get(IUserManager::class));
43-
} else {
44-
$this->isDeleted = false;
4542
}
4643
return $this->group;
4744
}
4845

4946
#[\Override]
5047
public function getDisplayName(): string {
5148
// Use display name cache from IGroupManager
52-
return $this->groupManager->getDisplayName($this->gid);
49+
return $this->groupManager->getDisplayName($this->gid) ?? $this->gid;
5350
}
5451

5552
#[\Override]
5653
public function setDisplayName(string $displayName): bool {
57-
return $this->group->setDisplayName($displayName);
54+
return $this->getGroup()->setDisplayName($displayName);
5855
}
5956

6057
#[\Override]
@@ -121,12 +118,4 @@ public function canAddUser(): bool {
121118
public function hideFromCollaboration(): bool {
122119
return $this->getGroup()->hideFromCollaboration();
123120
}
124-
125-
#[\Override]
126-
public function isDeleted(): bool {
127-
if ($this->isDeleted === null) {
128-
$this->getGroup();
129-
}
130-
return $this->isDeleted === true ? true : $this->getGroup()->isDeleted();
131-
}
132121
}

lib/public/IGroup.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,4 @@ public function canAddUser(): bool;
148148
* @since 16.0.0
149149
*/
150150
public function hideFromCollaboration(): bool;
151-
152-
/**
153-
* Return whether the group is deleted.
154-
*
155-
* @since 35.0.0
156-
*/
157-
public function isDeleted(): bool;
158151
}

tests/lib/Group/ManagerTest.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -418,30 +418,6 @@ public function testGetUserGroupIds(): void {
418418
}
419419
}
420420

421-
public function testGetUserGroupsWithDeletedGroup(): void {
422-
$backend = $this->createMock(Database::class);
423-
$backend->expects($this->once())
424-
->method('getUserGroups')
425-
->with('user1')
426-
->willReturn(['group1']);
427-
$backend->expects($this->any())
428-
->method('groupExists')
429-
->with('group1')
430-
->willReturn(false);
431-
432-
$manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache, $this->remoteIpAddress);
433-
$manager->addBackend($backend);
434-
435-
$user = $this->createMock(IUser::class);
436-
$user->expects($this->atLeastOnce())
437-
->method('getUID')
438-
->willReturn('user1');
439-
440-
$groups = $manager->getUserGroups($user);
441-
$this->assertCount(1, $groups);
442-
$this->assertTrue($groups['group1']->isDeleted());
443-
}
444-
445421
public function testInGroup(): void {
446422
$backend = $this->getTestBackend();
447423
$backend->expects($this->once())

0 commit comments

Comments
 (0)