Destination query parameter should not have precedence over path in redirect

Created on 12 April 2023, over 1 year ago
Updated 18 April 2023, over 1 year ago

Problem/Motivation

When destination query parameter is present redirects point to that page instead of the path:

<page_url>/ce-api/node/add/foo?destination=bar should generate a frontend direct to /node/add/foo?destination=bar not /bar.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇸🇮Slovenia useernamee Ljubljana

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

Comments & Activities

  • Issue created by @useernamee
  • 🇸🇮Slovenia useernamee Ljubljana

    It looks like this is not realy a lupus_ce_renderer but a designed behavior in \Drupal\Core\EventSubscriber\RedirectResponseSubscriber::checkRedirectUrl the destination parameter has precedence and is set as targetUrl on RedirectResponse.

  • 🇦🇹Austria fago Vienna

    This is a Drupal feature - In general it makes sense, but not when we are doing admin fallback redirects (See https://www.drupal.org/project/lupus_ce_renderer/issues/3272161 Implement admin fallback redirect Fixed )

    Could we undo/prevent this Drupal logic somehow - only for Drupal admin fallback redirects, but keep the original path as is, with destination parameter?

  • @useernamee opened merge request.
  • Status changed to Needs review over 1 year ago
  • 🇸🇮Slovenia useernamee Ljubljana

    I've simply removed destination query parameter from request. I think this won't have any undesirable consequences (in cases where destination query parameter is actually desired). If later will be the case we can make it a bit more complicated and just add a lupus_ce_renderer_redirect attribute to request and then write a service decorator for RedirectResponseSubscriber that has another condition before applying the destination query parameter override.

    For now this solution works:

    <base-url>/ce-api/node/add/article?destination=bar => "<base-url>/node/add/article?destination=bar"

  • 🇸🇮Slovenia useernamee Ljubljana
  • 🇦🇹Austria fago Vienna

    Yep, agreed. Patch looks good. Let's get it tested!

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    9 pass
    • useernamee committed f0f5fa2a on 2.x
      Issue #3353656 by useernamee, fago: Destination query parameter should...
  • Status changed to Fixed over 1 year ago
  • 🇸🇮Slovenia useernamee Ljubljana

    Works on our ci environments and no regressions were recorded, Thus merging.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024