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

Autogenerated Emitter is not persisted #1422

Closed
ls-sean-fraser opened this issue Jul 5, 2024 · 0 comments · Fixed by #1428
Closed

Autogenerated Emitter is not persisted #1422

ls-sean-fraser opened this issue Jul 5, 2024 · 0 comments · Fixed by #1428

Comments

@ls-sean-fraser
Copy link
Contributor

ls-sean-fraser commented Jul 5, 2024

I believe I have found another bug in the library (running the latest version). The getEmitter() method does not persist the autogenerated object. As a result, every call to that method returns a separate emitter instance, meaning that events emitted from one instance will never reach the listeners which are registered to a different instance

https://github.com/thephpleague/oauth2-server/blob/master/src/EventEmitting/EmitterAwarePolyfill.php#L16

public function getEmitter(): EventEmitter
    {
        return $this->emitter ?? new EventEmitter();
    }

Was that intended to be a ??= operator?

Workaround: explicitly call $server->setEmitter(new EventEmitter()) BEFORE assigning any grants to the server. This kind of defeats the purpose of the autogeneration.

Question: Should $server->setEmitter() automatically cascade the reassignment to any registered grant types?

ls-sean-fraser added a commit to ls-sean-fraser/oauth2-server that referenced this issue Jul 22, 2024
addresses thephpleague#1418

Also fixed event emitter trait not storing automatically created instance (addresses thephpleague#1422)
ls-sean-fraser added a commit to ls-sean-fraser/oauth2-server that referenced this issue Jul 22, 2024
addresses thephpleague#1418

Also fixed event emitter trait not storing automatically created instance (addresses thephpleague#1422)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant