Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions apps/files_sharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

namespace OCA\Files_Sharing\AppInfo;

use OC\Group\DisplayNameCache as GroupDisplayNameCache;
use OC\User\DisplayNameCache;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar;
use OCA\Files_Sharing\Capabilities;
Expand Down Expand Up @@ -50,7 +48,6 @@
use OCP\Files\Events\Node\BeforeNodeReadEvent;
use OCP\Files\Events\UserHomeSetupEvent;
use OCP\Group\Events\BeforeGroupDeletedEvent;
use OCP\Group\Events\GroupChangedEvent;
use OCP\Group\Events\GroupDeletedEvent;
use OCP\Group\Events\UserAddedEvent;
use OCP\Group\Events\UserRemovedEvent;
Expand All @@ -62,8 +59,6 @@
use OCP\Share\Events\ShareCreatedEvent;
use OCP\Share\Events\ShareMovedEvent;
use OCP\Share\Events\ShareTransferredEvent;
use OCP\User\Events\UserChangedEvent;
use OCP\User\Events\UserDeletedEvent;
use OCP\Util;
use Psr\Container\ContainerInterface;
use Symfony\Component\EventDispatcher\GenericEvent as OldGenericEvent;
Expand Down Expand Up @@ -98,10 +93,6 @@ function () use ($c) {
$context->registerCapability(Capabilities::class);

$context->registerNotifierService(Notifier::class);
$context->registerEventListener(UserChangedEvent::class, DisplayNameCache::class);
$context->registerEventListener(UserDeletedEvent::class, DisplayNameCache::class);
$context->registerEventListener(GroupChangedEvent::class, GroupDisplayNameCache::class);
$context->registerEventListener(GroupDeletedEvent::class, GroupDisplayNameCache::class);

// Sidebar and files scripts
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class);
Expand Down
2 changes: 1 addition & 1 deletion apps/settings/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function usersList(INavigationManager $navigationManager, ISubAdmin $subA
} else {
if ($this->appManager->isEnabledForUser('user_ldap')) {
$isLDAPUsed
= $this->groupManager->isBackendUsed('\OCA\User_LDAP\Group_Proxy');
= $this->groupManager->isBackendUsed(\OCA\User_LDAP\Group_Proxy::class);
if ($isLDAPUsed) {
// LDAP user count can be slow, so we sort by group name here
$sortGroupsBy = MetaData::SORT_GROUPNAME;
Expand Down
5 changes: 5 additions & 0 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,11 @@
<code><![CDATA[getSubject]]></code>
</DeprecatedMethod>
</file>
<file src="core/AppInfo/Application.php">
<DeprecatedClass>
<code><![CDATA[BeforeUserRemovedEvent::class]]></code>
</DeprecatedClass>
</file>
<file src="core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php">
<DeprecatedClass>
<code><![CDATA[Files::rmdirr($dir)]]></code>
Expand Down
21 changes: 21 additions & 0 deletions core/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@
use OC\Core\Sharing\Recipient\TeamShareRecipientType;
use OC\Core\Sharing\Recipient\TokenShareRecipientType;
use OC\Core\Sharing\Recipient\UserShareRecipientType;
use OC\Group\DisplayNameCache as GroupDisplayNameCache;
use OC\Group\Manager as GroupManager;
use OC\OCM\OCMDiscoveryHandler;
use OC\OCM\OCMJwksHandler;
use OC\SubAdmin;
use OC\TagManager;
use OC\User\DisplayNameCache;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
Expand All @@ -48,13 +52,19 @@
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\DB\Events\AddMissingIndicesEvent;
use OCP\DB\Events\AddMissingPrimaryKeyEvent;
use OCP\Group\Events\BeforeGroupDeletedEvent;
use OCP\Group\Events\BeforeUserAddedEvent;
use OCP\Group\Events\BeforeUserRemovedEvent;
use OCP\Group\Events\GroupChangedEvent;
use OCP\Group\Events\GroupDeletedEvent;
use OCP\IAppConfig;
use OCP\Interaction\RestrictInteractionEvent;
use OCP\Navigation\Events\LoadAdditionalEntriesEvent;
use OCP\Server;
use OCP\Sharing\ISharingRegistry;
use OCP\User\Events\BeforeUserDeletedEvent;
use OCP\User\Events\PasswordUpdatedEvent;
use OCP\User\Events\UserChangedEvent;
use OCP\User\Events\UserDeletedEvent;
use OCP\Util;

Expand Down Expand Up @@ -103,6 +113,17 @@
$context->registerEventListener(UserDeletedEvent::class, UserDeletedWebAuthnCleanupListener::class);
$context->registerEventListener(PasswordUpdatedEvent::class, PasswordUpdatedListener::class);

$context->registerEventListener(UserChangedEvent::class, DisplayNameCache::class);
$context->registerEventListener(UserDeletedEvent::class, DisplayNameCache::class);
$context->registerEventListener(GroupChangedEvent::class, GroupDisplayNameCache::class);
$context->registerEventListener(GroupDeletedEvent::class, GroupDisplayNameCache::class);
$context->registerEventListener(BeforeGroupDeletedEvent::class, GroupManager::class);
$context->registerEventListener(BeforeUserAddedEvent::class, GroupManager::class);
$context->registerEventListener(BeforeUserRemovedEvent::class, GroupManager::class);
$context->registerEventListener(GroupDeletedEvent::class, GroupManager::class);

Check failure on line 123 in core/AppInfo/Application.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidArgument

core/AppInfo/Application.php:123:13: InvalidArgument: Incompatible types found for T (OCP\Group\Events\BeforeGroupCreatedEvent|OCP\Group\Events\BeforeGroupDeletedEvent|OCP\Group\Events\BeforeUserAddedEvent|OCP\Group\Events\BeforeUserRemovedEvent|OCP\Group\Events\GroupDeletedEvent is not in OCP\Group\Events\BeforeGroupCreatedEvent|OCP\Group\Events\BeforeGroupDeletedEvent|OCP\Group\Events\BeforeUserAddedEvent|OCP\Group\Events\BeforeUserRemovedEvent) (see https://psalm.dev/004)
$context->registerEventListener(GroupDeletedEvent::class, SubAdmin::class);
$context->registerEventListener(UserDeletedEvent::class, SubAdmin::class);

// Tags
$context->registerEventListener(UserDeletedEvent::class, TagManager::class);

Expand Down
24 changes: 0 additions & 24 deletions lib/OC.php
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,6 @@ public static function init(): void {
self::registerResourceCollectionHooks();
self::registerFileReferenceEventListener();
self::registerRenderReferenceEventListener();
self::registerAppRestrictionsHooks();

// Make sure that the application class is not loaded before the database is setup
if ($systemConfig->getValue('installed', false)) {
Expand Down Expand Up @@ -1061,29 +1060,6 @@ private static function registerAccountHooks(): void {
$dispatcher->addServiceListener(UserChangedEvent::class, \OC\Accounts\Hooks::class);
}

private static function registerAppRestrictionsHooks(): void {
/** @var \OC\Group\Manager $groupManager */
$groupManager = Server::get(\OCP\IGroupManager::class);
$groupManager->listen('\OC\Group', 'postDelete', function (\OCP\IGroup $group) {
$appManager = Server::get(\OCP\App\IAppManager::class);
$apps = $appManager->getEnabledAppsForGroup($group);
foreach ($apps as $appId) {
$restrictions = $appManager->getAppRestriction($appId);
if (empty($restrictions)) {
continue;
}
$key = array_search($group->getGID(), $restrictions, true);
unset($restrictions[$key]);
$restrictions = array_values($restrictions);
if (empty($restrictions)) {
$appManager->disableApp($appId);
} else {
$appManager->enableAppForGroups($appId, $restrictions);
}
}
});
}

private static function registerResourceCollectionHooks(): void {
\OC\Collaboration\Resources\Listener::register(Server::get(IEventDispatcher::class));
}
Expand Down
21 changes: 0 additions & 21 deletions lib/private/Group/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace OC\Group;

use OC\Hooks\PublicEmitter;
use OC\User\LazyUser;
use OC\User\User;
use OCP\EventDispatcher\IEventDispatcher;
Expand Down Expand Up @@ -48,7 +47,6 @@ public function __construct(
private array $backends,
private IEventDispatcher $dispatcher,
private IUserManager $userManager,
private ?PublicEmitter $emitter = null,
/** @var ?non-empty-string $displayName */
protected ?string $displayName = null,
) {
Expand Down Expand Up @@ -154,20 +152,13 @@ public function addUser(IUser $user): void {

$this->dispatcher->dispatchTyped(new BeforeUserAddedEvent($this, $user));

if ($this->emitter) {
$this->emitter->emit('\OC\Group', 'preAddUser', [$this, $user]);
}
foreach ($this->backends as $backend) {
if ($backend->implementsActions(\OC\Group\Backend::ADD_TO_GROUP)) {
/** @var IAddToGroupBackend $backend */
$backend->addToGroup($user->getUID(), $this->gid);
$this->users[$user->getUID()] = $user;

$this->dispatcher->dispatchTyped(new UserAddedEvent($this, $user));

if ($this->emitter) {
$this->emitter->emit('\OC\Group', 'postAddUser', [$this, $user]);
}
return;
}
}
Expand All @@ -180,9 +171,6 @@ public function addUser(IUser $user): void {
public function removeUser(IUser $user): void {
$result = false;
$this->dispatcher->dispatchTyped(new BeforeUserRemovedEvent($this, $user));
if ($this->emitter) {
$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)) {
/** @var IRemoveFromGroupBackend $backend */
Expand All @@ -192,9 +180,6 @@ public function removeUser(IUser $user): void {
}
if ($result) {
$this->dispatcher->dispatchTyped(new UserRemovedEvent($this, $user));
if ($this->emitter) {
$this->emitter->emit('\OC\Group', 'postRemoveUser', [$this, $user]);
}
if ($this->users) {
foreach ($this->users as $index => $groupUser) {
if ($groupUser->getUID() === $user->getUID()) {
Expand Down Expand Up @@ -323,9 +308,6 @@ public function delete(): bool {

$result = false;
$this->dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($this));
if ($this->emitter) {
$this->emitter->emit('\OC\Group', 'preDelete', [$this]);
}
foreach ($this->backends as $backend) {
if ($backend->implementsActions(\OC\Group\Backend::DELETE_GROUP)) {
/** @var IDeleteGroupBackend $backend */
Expand All @@ -334,9 +316,6 @@ public function delete(): bool {
}
if ($result) {
$this->dispatcher->dispatchTyped(new GroupDeletedEvent($this));
if ($this->emitter) {
$this->emitter->emit('\OC\Group', 'postDelete', [$this]);
}
}
return $result;
}
Expand Down
Loading
Loading