Saving menu causes incorrect redirect when Drupal is installed into a subdirectory

Created on 2 November 2021, over 3 years ago

Problem/Motivation

When saving a menu, the user will by default be redirected to the menu top level at admin/structure/menu/manage/. This would happen even when saving a "child menu" menu at admin/structure/menu/manage/?menu_link=menu_link_content.

This module alters the redirect destination so that the user would stay in the child menu instead of being redirected to the top level. This is very convenient.

However, if Drupal is installed in a subdirectory or behind a reverse proxy, in an address like example.com/drupal/, then this custom redirect does not work as intended, but instead redirects the user to /drupal/drupal/admin/structure/menu/manage/?menu_link=menu_link_content (note the double folder name at the beginning).

Steps to reproduce

  1. Install Drupal in a subdirectory, eg example.com/drupal/
  2. Go to admin/structure/menu/manage/main, add links in multiple levels
  3. Click "Edit child items" to edit a child menu
  4. Save the child menu
  5. You should now see the Drupal 404 page, and the URL should start with /drupal/drupal/...

Proposed resolution

  • Option A: Remove the call to $form_state->setRedirectUrl(), and disable the redirect completely using $form_state->disableRedirect()
  • Option B: Remove the call to $form_state->setRedirectUrl(), and add ?destination parameters to the "Edit child items" links
๐Ÿ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

๐Ÿ‡ซ๐Ÿ‡ฎFinland rade

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024