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

Update priority of FosUser\EventListener #1065

Merged
merged 3 commits into from
Apr 21, 2017
Merged

Update priority of FosUser\EventListener #1065

merged 3 commits into from
Apr 21, 2017

Conversation

pierredup
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #1064
License MIT
Doc PR N/A

Since #597, the ApiPlatform\Core\EventListener\SerializerListener (formerly SerializerViewListener) class changed priorty from 10 to 16.
The ApiPlatform\Core\Bridge\FosUser\EventListener class has a priority of 11, which means it now runs after the SerializerListener. This causes the controller result to be already serialized, which fails the checks in the FOSUser listener.

This PR updates the priority of ApiPlatform\Core\Bridge\FosUser\EventListener to 24, so that it can run before the SerializerListener class.

@dunglas
Copy link
Member

dunglas commented Apr 17, 2017

Great! Thank you very much for finding and fixing the problem.
Can you just add a regression est to prevent future similar problems?

@soyuka
Copy link
Member

soyuka commented Apr 19, 2017

Can you rebase on 2.0 also? Thanks!

@pierredup
Copy link
Contributor Author

I added a unit test, but it feels a bit ugly (especially the path mapping to load the configs), let me know if there is a better way.
I'll do the rebase shortly

@dunglas
Copy link
Member

dunglas commented Apr 20, 2017

IMO a Behat (integration) test will be easier to do and more useful.

@soyuka
Copy link
Member

soyuka commented Apr 20, 2017

Isn't this enough to test the priority? IMO, the less behat tests we have the better.

@dunglas
Copy link
Member

dunglas commented Apr 20, 2017

But we need to be sure that this feature actually works :) Testing the priority is not enough (proof: this PR)

@pierredup
Copy link
Contributor Author

The integration is already tested separately, so IMO the priority is the only thing that still needs to be tested because that is what is broken. So I have kept the unit test to ensure the priority is set correctly, and added another step to the integration test to ensure the password hashing works when creating users

@pierredup pierredup changed the base branch from master to 2.0 April 21, 2017 07:35
@pierredup
Copy link
Contributor Author

Rebase done

$this->assertGreaterThan(
$viewListener->getTag('kernel.event_listener')[0]['priority'],
$fosListener->getTag('kernel.event_listener')[0]['priority'],
"api_platform.fos_user.event_listener priority needs to be greater than that of api_platform.listener.view.serialize"
Copy link
Member

Choose a reason for hiding this comment

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

Needs simple quotes, lint failed :)

@dunglas dunglas merged commit 077f390 into api-platform:2.0 Apr 21, 2017
@dunglas
Copy link
Member

dunglas commented Apr 21, 2017

Thanks @pierredup!

@pierredup pierredup deleted the patch-1 branch April 21, 2017 15:34
@teohhanhui teohhanhui added the bug label May 3, 2017
hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
Update priority of FosUser\EventListener
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants