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

Fix EZP-23176: Lazy sessions are not honored in 5.3 #936

Merged
merged 1 commit into from Jul 25, 2014

Conversation

lolautruche
Copy link
Contributor

https://jira.ez.no/browse/EZP-23176

Alternative of #932 and ezsystems/ezpublish-legacy#1033 by @joaoinacio .

In security mapper, user was injected in legacy even if the current user wasn't authenticated. Problem is that eZUser::setLoggedInUser() always sets a session variable, and thus starts a session.

This patch ensures user is authenticated in security context before injecting the user.

@@ -81,13 +89,26 @@ public function onKernelBuilt( PostBuildKernelEvent $event )
function () use ( $currentUser )
{
$legacyUser = eZUser::fetch( $currentUser->id );
eZUser::setCurrentlyLoggedInUser( $legacyUser, $legacyUser->attribute( 'contentobject_id' ), eZUser::NO_SESSION_REGENERATE );
// "1" stands for eZUser::NO_SESSION_REGENERATE.
// Using raw value to be keep being testable.
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't get this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically, when you want to mock static methods, you need to use class alias/overload with Mockery. Problem is that it doesn't keep class constants, so here test would crash with a fatal.

@andrerom
Copy link
Contributor

Besides the comment, and travis, +1

> https://jira.ez.no/browse/EZP-23176

Alternative of #932 and ezsystems/ezpublish-legacy#1033 by @joaoinacio .

In security mapper, user was injected in legacy even if the current user wasn't authenticated.
Problem is that `eZUser::setLoggedInUser()` always sets a session variable…

This patch ensures user is authenticated in security context before injecting the user.
Tests have been updated and improved.
@pspanja
Copy link
Contributor

pspanja commented Jul 25, 2014

+1

lolautruche added a commit that referenced this pull request Jul 25, 2014
…onymous

Fix EZP-23176: Lazy sessions are not honored in 5.3
@lolautruche lolautruche merged commit 201d396 into master Jul 25, 2014
@lolautruche lolautruche deleted the fix_EZP-23176_sessionStartedAnonymous branch July 25, 2014 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants