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

QueryBus returns null with FinalizeGuard plugin included #177

Closed
lezhnev74 opened this issue Dec 25, 2017 · 3 comments · Fixed by #178
Closed

QueryBus returns null with FinalizeGuard plugin included #177

lezhnev74 opened this issue Dec 25, 2017 · 3 comments · Fixed by #178

Comments

@lezhnev74
Copy link

Test to reproduce the problem:
https://github.com/lezhnev74/prooph-query-test/blob/prooph-bare/tests/QueryTest.php

Results:

  • executing query with no guards - pass
  • executing query with RouteGuard - pass
  • executing query with FinalizeGuard - fail
@lezhnev74 lezhnev74 changed the title QueryBus returns null will FinalizeGuard plugin included QueryBus returns null with FinalizeGuard plugin included Dec 25, 2017
@basz
Copy link
Member

basz commented Dec 25, 2017

promises are suppose to return something. each then() may change the passed payload.

therefore when I change the FinalizeGuard like the following, I get three green lights when running your tests.

$newPromise = $promise->then(function ($result) use ($actionEvent, $messageName) {
                        if (! $this->authorizationService->isGranted($messageName, $result)) {
                            $actionEvent->stopPropagation(true);

                            if (! $this->exposeEventMessageName) {
                                $messageName = '';
                            }

                            throw new UnauthorizedException($messageName);
                        }

                        return $result; // note this, but also the return type has changed
                    });

                    $actionEvent->setParam(QueryBus::EVENT_PARAM_PROMISE, $newPromise);

I don't understand why this would have worked so far. I'm using the same react/promise version.

@basz
Copy link
Member

basz commented Dec 25, 2017

https://blog.domenic.me/youre-missing-the-point-of-promises/

@lezhnev74
Copy link
Author

lezhnev74 commented Dec 25, 2017

I don't deal with async stuff at my work. Is it something I should make a PR for or what is the solution here?

@basz can you take a moment and analyze your code. If you will copy the same tests in your project - will they fail? If so hows your project working? :)

prolic added a commit that referenced this issue Dec 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants