Skip to content

fix(dispatcher): Move remaining simple cases in apps/ folder to IEven… - #39485

Merged
nickvergessen merged 1 commit into
masterfrom
bugfix/noid/move-remaining-easy-usages-to-IEventDispatcher
Jul 26, 2023
Merged

fix(dispatcher): Move remaining simple cases in apps/ folder to IEven…#39485
nickvergessen merged 1 commit into
masterfrom
bugfix/noid/move-remaining-easy-usages-to-IEventDispatcher

Conversation

@nickvergessen

Copy link
Copy Markdown
Member

…tDispatcher

Checklist

@nickvergessennickvergessen added 3. to review Waiting for reviews technical debt 🧱 🤔🚀 pending documentation This pull request needs an associated documentation update labels Jul 19, 2023
@nickvergessennickvergessen added this to the Nextcloud 28 milestone Jul 19, 2023
@nickvergessennickvergessen self-assigned this Jul 19, 2023
// notifications api to accept incoming user shares
$oldDispatcher->addListener('OCP\Share::postShare', function (OldGenericEvent $event) {
$dispatcher->addListener('OCP\Share::postShare', function ($event) {
if (!$event instanceof OldGenericEvent) {

Check notice

Code scanning / Psalm

RedundantConditionGivenDocblockType

OCP\EventDispatcher\Event does not contain Symfony\Component\EventDispatcher\GenericEvent
});
$oldDispatcher->addListener(IGroup::class . '::postAddUser', function (OldGenericEvent $event) {
$dispatcher->addListener(IGroup::class . '::postAddUser', function ($event) {
if (!$event instanceof OldGenericEvent) {

Check notice

Code scanning / Psalm

RedundantConditionGivenDocblockType

OCP\EventDispatcher\Event does not contain Symfony\Component\EventDispatcher\GenericEvent

$userBackendRegisteredEvent = new UserBackendRegistered($userBackend, $userPluginManager);
$legacyDispatcher->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded', $userBackendRegisteredEvent);
$dispatcher->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded', $userBackendRegisteredEvent);

Check notice

Code scanning / Psalm

DeprecatedMethod

The method OCP\EventDispatcher\IEventDispatcher::dispatch has been marked as deprecated
}

private function registerBackendDependents(IAppContainer $appContainer, EventDispatcherInterface $dispatcher) {
private function registerBackendDependents(IAppContainer $appContainer, IEventDispatcher $dispatcher) {

Check notice

Code scanning / Psalm

MissingReturnType

Method OCA\User_LDAP\AppInfo\Application::registerBackendDependents does not have a return type, expecting void
}

private function registerBackendDependents(IAppContainer $appContainer, EventDispatcherInterface $dispatcher) {
private function registerBackendDependents(IAppContainer $appContainer, IEventDispatcher $dispatcher) {

Check notice

Code scanning / Psalm

DeprecatedInterface

Interface OCP\AppFramework\IAppContainer is marked as deprecated
@nickvergessen
nickvergessenforce-pushed the bugfix/noid/move-remaining-easy-usages-to-IEventDispatcher branch from 08ce53a to f733301CompareJuly 19, 2023 20:07
…tDispatcher
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
nickvergessenforce-pushed the bugfix/noid/move-remaining-easy-usages-to-IEventDispatcher branch from f733301 to 77bc6c3CompareJuly 25, 2023 09:19
@nickvergessen
nickvergessen requested review from a team, ArtificialOwl, ChristophWurst and nfebe and removed request for a teamJuly 25, 2023 20:20
$dispatcher->addListener('OCP\Share::postShare', function ($event) {
if (!$event instanceof OldGenericEvent) {
return;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this guard needed?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

It helps to trick psalm, so it doesn't yield on $listener->shareNotification($event) Later on, which only eats GenericEvent.
But it only is an intermediate step anyway to move forward to 5.4.x of the dispatcher. When we have to update to 6.4.x at the end of the year, GenericEvent will no longer exist and we need to do more work I guess, so I took the soft/low effort approach and added this mini guard.

@susnuxsusnux left a comment

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.

🧹

@nickvergessen
nickvergessen merged commit b76b0bb into masterJul 26, 2023
@nickvergessen
nickvergessen deleted the bugfix/noid/move-remaining-easy-usages-to-IEventDispatcher branch July 26, 2023 15:29
@nickvergessennickvergessen removed the pending documentation This pull request needs an associated documentation update label Jul 28, 2023
@nickvergessen

Copy link
Copy Markdown
MemberAuthor

Docs in nextcloud/documentation#10858

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

Labels

3. to reviewWaiting for reviewstechnical debt🧱 🤔🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@nickvergessen@marcelklehr@susnux@github-advanced-security@come-nc