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 EZP21591: querystring lost in redirection #527

Merged
1 commit merged into from
Oct 1, 2013

Conversation

ghost
Copy link

@ghost ghost commented Sep 25, 2013

will carry the querystring params on a redirect operation.

the QueryString is normalized by the request(), so i needed to manually add the '?' for the the fix to work. yes, looks ugly, is there a better way to do it?

@lolautruche
Copy link
Contributor

+1

@andrerom
Copy link
Contributor

+1 (but nitpick, what is "Carrier" in this context? better with just $querystring or something ?)

@ghost
Copy link
Author

ghost commented Sep 26, 2013

it's what the variable is for, it "carries" the querystring over the redirect op.
bytes are cheap, and so are keystrokes.... :)

@lolautruche
Copy link
Contributor

@Pbras I agree with @andrerom on the nitpick. This is confusing. Can you please amend your commit ?

@@ -137,6 +137,7 @@ public function onKernelRequestRedirect( GetResponseEvent $event )
{
$siteaccess = $request->attributes->get( 'siteaccess' );
$semanticPathinfo = $request->attributes->get( 'semanticPathinfo' );
$querystring = $request->getQueryString();
Copy link
Contributor

Choose a reason for hiding this comment

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

CS: $queryString in camel caps.

But better would be to just not use a temporary variable and write directly:

$semanticPathinfo . '?' . $request->getQueryString()

to keep the context closer.

Copy link
Contributor

Choose a reason for hiding this comment

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

We're forced to use a temp variable here (for keeping readability). And it makes me thing that we don't have always a query string while we enforce it below.

@patrickallaert
Copy link
Contributor

+1 but take other's remark into account.

@@ -148,7 +149,7 @@ public function onKernelRequestRedirect( GetResponseEvent $event )

$event->setResponse(
new RedirectResponse(
$semanticPathinfo,
$semanticPathinfo . '?' . $querystring,
Copy link
Contributor

Choose a reason for hiding this comment

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

What if $queryString is empty ? We'll have an orphan ?.

Better do something like this:

$queryString = $request->getQueryString();

// ...
new RedirectResponse ( $semanticPathinfo . $queryString ? "?$queryString" : '' );

@ezrobot
Copy link
Contributor

ezrobot commented Sep 27, 2013

This Pull Request does not respect our Coding Standards, please, see the report below:

FILE: ...ce/eZ/Bundle/EzPublishCoreBundle/EventListener/RequestEventListener.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
 151 | ERROR | Space found before comma in function call
--------------------------------------------------------------------------------

@ghost
Copy link
Author

ghost commented Oct 1, 2013

good to go?

@lolautruche
Copy link
Contributor

You have 3 "+1" so yes it is ok.
However, please squash your 2 commits into one (easier for backports).

@ghost ghost merged this pull request into master Oct 1, 2013
@lolautruche lolautruche deleted the fix-EZP21591-querystring-lost-in-redirection branch October 1, 2013 09:09
@lolautruche lolautruche restored the fix-EZP21591-querystring-lost-in-redirection branch October 1, 2013 10:23
@lolautruche lolautruche deleted the fix-EZP21591-querystring-lost-in-redirection branch October 1, 2013 10:28
@lolautruche
Copy link
Contributor

Manually merged in 9a70edc

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants