Redirect module compatibility

Created on 1 February 2025, 4 days ago

Problem/Motivation

On Drupal 11, when using ui_styles alongside with redirect module. stylesheet.css enter an infinite 301 redirect.

This is due to Drupal\redirect\EventSubscriber\RouteNormalizerRequestSubscriber.

Steps to reproduce

  • Enable redirect, ui_styles, ui_patterns modules and ui_suite_bootstrap theme
  • Create a content type with layout builder override
  • Create a node and try to add accordion

Proposed resolution

As redirect is widely used, ui_styles could be compatible directly by preventing redirect to process the ui_styles.stylesheet route.
Just by adding _disable_route_normalizer: true to route defaults.

Feature request
Status

Active

Version

1.15

Component

Code

Created by

🇫🇷France mattlc

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

Merge Requests

Comments & Activities

  • Issue created by @mattlc
  • Pipeline finished with Success
    4 days ago
    Total: 307s
    #412040
  • 🇫🇷France mattlc

    To be tested

  • 🇫🇷France Grimreaper France 🇫🇷

    Hi,

    Thanks a lot for the report.

    But I can't reproduce, is it because my test environment is on D10?

    In the Redirect event subscriber what are the variables values that it triggers a redirect?

  • 🇫🇷France goz

    I confirm the issue with D11, and i'm using :
    ui_patterns : 2.0.0-rc2
    ui_styles: 8.x-1.15

    After applying patch, i can add section to my layout.

  • 🇫🇷France goz

    My bad, i reproduce in D10.4 and D10.3.

    In ui_style.routing.yml file, route is defined with .css extension

    ui_styles.stylesheet:
      path: '/ui_styles/stylesheet.css'
      defaults:
        _controller: 'Drupal\ui_styles\Controller\StylesheetController::generateStylesheet'
        _title: 'UI Styles CSS generator'
      requirements:
        _permission: 'access content'
    

    In Nginx, the following configuration add ?q= because of .css extension.

    
        location @rewrite {
            rewrite ^/(.*)$ /index.php?q=$1;
        }
    
        location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|eot|ttf|woff|woff2)$ {
            try_files $uri @rewrite;
        }
    

    So in web/modules/contrib/redirect/src/EventSubscriber/RouteNormalizerRequestSubscriber.php, at the end of onKernelRequestRedirect method, redirect_uri is

    /ui_styles/stylesheet.css?q=/ui_styles/stylesheet.css&prefix....

    so redirect module redirect to this url.

    ?q should not be there, but it's caused by nginx configuration and because it's not a real CSS file but generated on the fly by controller.

    Renaming controller path to something without .css extension solve the issue

  • 🇫🇷France Grimreaper France 🇫🇷
  • 🇫🇷France Grimreaper France 🇫🇷

    MR rebased and updated.

    @pierre, can you test with Drush webserver please?

  • 🇫🇷France Grimreaper France 🇫🇷
Production build 0.71.5 2024