Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate more apps to IEventDispatcher #39222

Merged
merged 3 commits into from
Jul 19, 2023

Conversation

nickvergessen
Copy link
Member

@nickvergessen nickvergessen commented Jul 7, 2023

One step closer for #38546

Checklist

@nickvergessen nickvergessen added bug 3. to review Waiting for reviews pending documentation This pull request needs an associated documentation update labels Jul 7, 2023
@nickvergessen nickvergessen added this to the Nextcloud 28 milestone Jul 7, 2023
@nickvergessen nickvergessen requested review from ChristophWurst, come-nc and a team July 7, 2023 09:35
@nickvergessen nickvergessen self-assigned this Jul 7, 2023
@nickvergessen nickvergessen requested review from ArtificialOwl and icewind1991 and removed request for a team July 7, 2023 09:35
/** @var IUser $user */
$user = $event->getSubject();
$dispatcher->addListener('OC\AccountManager::userUpdated', function ($event) use ($appContainer) {
if ($event instanceof GenericEvent) {

Check notice

Code scanning / Psalm

DocblockTypeContradiction Note

Cannot resolve types for $event - docblock-defined type OCP\EventDispatcher\Event does not contain Symfony\Component\EventDispatcher\GenericEvent
@nickvergessen nickvergessen removed the pending documentation This pull request needs an associated documentation update label Jul 11, 2023
@@ -694,7 +687,6 @@ public function formatOperation(array $operation): array {
*/
public function getEntitiesList(): array {
$this->dispatcher->dispatchTyped(new RegisterEntitiesEvent($this));
$this->legacyEventDispatcher->dispatch(IManager::EVENT_NAME_REG_ENTITY, new GenericEvent($this));
Copy link
Contributor

Choose a reason for hiding this comment

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

Code in applications which are registering a listener for this, will they get an error or just silently won’t be called anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

"Silently" won't be called anymore after 3+ years of deprecation. It is documented in the changelogs never the less:
https://docs.nextcloud.com/server/latest/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_28.html#removed-events

$dispatcher->addListener('OC\AccountManager::userUpdated', function (GenericEvent $event) use ($appContainer) {
/** @var IUser $user */
$user = $event->getSubject();
$dispatcher->addListener('OC\AccountManager::userUpdated', function ($event) use ($appContainer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no typed event version for this one?
This change is not really updating to the new system, it’s still using the old one, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no typed event version for this one?

No unluckily not.

This change is not really updating to the new system, it’s still using the old one, no?

For "listeners" there is no new/old system. It's the same. But yeah I'm not planing to migrate the things to typed events with the current work. I just want to free the way to be able to merge #38546 and that comes with a breaking API change, unless our wrapper is used when dispatching.
But for the ease of search and being sure, I'm move all code away from directly using the thirdparty.

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the bugfix/noid/more-event-dispatchers branch from 6371b22 to aa039c9 Compare July 19, 2023 15:37
@nickvergessen
Copy link
Member Author

Rebased after conflicts

@nickvergessen nickvergessen merged commit 2e175fb into master Jul 19, 2023
38 checks passed
@nickvergessen nickvergessen deleted the bugfix/noid/more-event-dispatchers branch July 19, 2023 18:59
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 bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants