8000 Problem passing query parameters to redirected Url · Issue #26256 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Problem passing query parameters to redirected Url #26256

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

Closed
cooldude77 opened this issue Feb 21, 2018 · 5 comments
Closed

Problem passing query parameters to redirected Url #26256

cooldude77 opened this issue Feb 21, 2018 · 5 comments

Comments

@cooldude77
Copy link
cooldude77 commented Feb 21, 2018
Q A
Bug report? yes
Feature request? no
BC Break report? not sure
RFC? not sure
Symfony version 2.8.+

Here is one of my route

v2_rest_connections_status_with_self_connected_all_paged:
    pattern:  api/v2/connections/self/with/users/status/connectedSince/pages/{page}
    defaults:
        _controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
        route: rest_connections_status_with_self_connected_all_paged
        permanent: false

And this redirects to

rest_connections_status_with_self_connected_since:
    pattern:  api/v1/connections/self/with/users/status/connectedSince
    defaults: { _controller: MyCardRestBundle:Connection:getAllUsersConnectedWithSelf}
    methods: [GET]

So a sample URI for testing would be

'api/v2/connections/self/with/users/status/connectedSince/pages/1'

But there could be more get params supplied by client, which may not form part of url in routing( look at the params after ? mark)

'api/v2/connections/self/with/users/status/connectedSince/pages/1?device=android&density=XXHDPI&xy=blah',

Since the routes have same number of parameter {page} gets passed correctly but the device and density are not passed to the 'routed to' controller.

The problem could be that RedirectController does not look for the request parameter at line 65.

return new RedirectResponse($this->container->get('router')->generate($route, $attributes, UrlGeneratorInterface::ABSOLUTE_URL), $code);

Adding to route params also does not help as density value for example is not copied

And since target controller does not receive right request, it does not get the params leading to

Either device or density information is missing (404 Not Found)

@Tobion Tobion added the Feature label Feb 21, 2018
@Tobion
Copy link
Contributor
Tobion commented Feb 21, 2018

The RedirectController::redirectAction does not forward query params but only routing placeholders. This would be a new feature. For the time beeing, you can simply do the redirect in your own controller code.

@cooldude77
Copy link
Author

@Tobion Yes, that's what I guessed too.

@Simperfit
Copy link
Contributor

@cooldude77 do you want to provide a PR for this feature ?

@cooldude77
Copy link
Author

@Simperfit I am yet to understand the PR process completely ( because I recently found one more feature which was added and it was the first time I did something like this). So it would be great if anyone else ( or yourself ) can pick it up. Best regards

@Simperfit
Copy link
Contributor 8000

I'm going to do it ;).

@fabpot fabpot closed this as completed Mar 27, 2018
fabpot added a commit that referenced this issue Mar 27, 2018
This PR was merged into the 4.1-dev branch.

Discussion
----------

[FrameworkBundle] keep query in redirect

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #26256   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | #9314

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

Commits
-------

406bfc9 [FrameworkBundle] keep query params in redirection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0