Redirect to wrong URL when "destination" query parameter is set

Created on 20 April 2019, almost 6 years ago
Updated 12 June 2024, 7 months ago

When "?destination=..." parameter is in GET query, form submission handler redirects to destination instead of current page.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇺🇦Ukraine d.novikov

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India prashant.c Dharamshala

    "\Drupal::request()->query->remove('destination');" needs to be converted to use dependency injection, you need to inject the "request_stack" service as a dependency using

    Symfony\Component\HttpFoundation\RequestStack
    

    .

  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India sahil.goyal

    Addressing #3, as suggestive using the DI for removing the query param.

  • Getting a WSOD with the latest patch.

    Attaching the correct fix for the dev version.

  • Status changed to Needs work almost 2 years ago
  • 🇮🇳India prashant.c Dharamshala

    use statement not used to include the required classes in the patch submitted in #4

  • @prashant.c , what do u mean by use statement for the classes not included in the patch? The required service is already being injected in code written previously.

  • There is another issue in the patch submitted in 4 (and now 5 also). The url being switched to, still has the destination parameter in it. which means that when i save an entity in the switched language, it goes back to the old language.

    The right solution would be to change the destination to the language being switched, but i will leave that to the language experts . Submitting a temporary patch to remove the destination in the new url also , for now.

  • First commit to issue fork.
  • @shivam_tiwari opened merge request.
  • Status changed to Needs review almost 2 years ago
  • Hello,

    I have reviewed the patch in #8, and I noticed it removes the destination query parameter. I believe this is not the intended behavior, as the destination parameter is essential for the entity edit form and other pages. The language switcher provided by Core operates similarly. it retains the destination parameter.

    Patch #5 works well, but there is an additional concern. When the language is changed, the destination parameter retains the old language prefix. So, if a user changes the language on the entity edit form and submits it, the system will redirect to the old language based on the destination parameter. This issue also exists in the Core language switcher.

  • 🇮🇳India prashant.c Dharamshala
Production build 0.71.5 2024