Redirect module compatibility

Created on 1 February 2025, about 1 month 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
    about 1 month 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 🇫🇷
  • 🇫🇷France pdureau Paris

    it works with "drush rs"

    ~/Projects/Drupal/ui_patterns_2/ $ vendor/bin/drush st
    Drupal version   : 11.1.2                                                                  
    Site URI         : http://default                                                          
    DB driver        : sqlite                                                                  
    DB port          :                                                                         
    DB username      :                                                                         
    DB name          : db.sqlite                                                               
    Database         : Connected                                                               
    Drupal bootstrap : Successful                                                              
    Default theme    : ui_suite_bootstrap                                                      
    Admin theme      : claro                                                                   
    PHP binary       : /usr/bin/php                                                            
    PHP config       : /etc/php.ini                                                            
    PHP OS           : Linux                                                                   
    PHP version      : 8.3.16                                                                  
    Drush script     : /home/pierre/Projects/Drupal/ui_patterns_2/vendor/bin/drush.php         
    Drush version    : 13.3.3.0                                                                
    Drush temp       : /tmp                                                                    
    Drush configs    : /home/pierre/Projects/Drupal/ui_patterns_2/vendor/drush/drush/drush.yml 
    Install profile  : standard                                                                
    Drupal root      : /home/pierre/Projects/Drupal/ui_patterns_2/web                          
    Site path        : sites/default                                                           
    Files, Public    : sites/default/files                                                     
    Files, Temp      : /tmp   

    i have http://127.0.0.1:8888/ui_styles/stylesheet?prefix=.ck-content&srblbb without the .css extension:

    
    HTTP/1.1 200 OK
    Host: 127.0.0.1:8888
    Connection: close
    X-Powered-By: PHP/8.3.16
    Content-Type: text/css; charset=UTF-8
    Cache-Control: must-revalidate, no-cache, private
    Date: Fri, 07 Feb 2025 15:50:12 GMT
    X-Drupal-Dynamic-Cache: MISS
    Content-language: en
    X-Content-Type-Options: nosniff
    X-Frame-Options: SAMEORIGIN
    X-Drupal-Cache-Tags: http_response
    X-Drupal-Cache-Contexts: url.query_args:prefix user.permissions
    X-Drupal-Cache-Max-Age: 31536000
    Expires: Sun, 19 Nov 1978 05:00:00 GMT
    X-Generator: Drupal 11 (https://www.drupal.org)
    Content-Length: 45259
    X-Drupal-Cache: MISS
  • 🇫🇷France Grimreaper France 🇫🇷
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024