Event "Controller found to handle request" when redirecting, does not show notification message

Created on 22 May 2023, over 1 year ago
Updated 4 August 2023, over 1 year ago

Updated:
2 problems that maybe need to fix:
1. Does not work for annonymous user
2. When disabling module bigpipe, the notification does not promp

Problem/Motivation

I am trying to redirect specific page if condition is meet. The redirecting is okay, but the message does not display. If remove the redirect action, the notification will display as intended. This problem is when using the event "Controller found to handle request".

I have tried to put the message action before the redirect, still did not display.

I have attach basic example for it. Not sure if this is a bug.

Steps to reproduce

1. create a node with alias url "/test".
2. export the ECA in attachment.
3. view the node /test and you will be redirected to front page "/".
4. you will see that the error message notification does not display.
5. if remove the redirect action in the ECA model, and re-view the page again, the message will display as intended.

💬 Support request
Status

Fixed

Version

2.0

Component

Code

Created by

🇲🇾Malaysia muaz91 MY

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

Comments & Activities

  • Issue created by @muaz91
  • 🇲🇾Malaysia muaz91 MY

    I've also tried another kernal event "Start dispatching request" with the same conditions and actions, the url redirect is working, but the notification still does not shown

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Is that for authenticated users the same as for anonymous users?

  • 🇲🇾Malaysia muaz91 MY

    @jurgenhaas, I think both. I've test for anonymous still not have the notification message

  • 🇩🇪Germany jurgenhaas Gottmadingen

    That's what I expected. Messages from Drupal get stored in the session to be displayed across page requests. Since anonymous users don't have a session, Drupal can't keep messages for them to be displayed on the next page request. Without a redirect, there is only 1 page request, and that's why it works there.

    To validate that assumption, you may want to test this with authenticated users, there it should work.

  • 🇲🇾Malaysia muaz91 MY

    I am sorry for not clarifying enough for my comment. I have tested out on both logged in and out, and both does not show any notification when redirecting to another page.

    For my use case is actually for authenticated users, and as stated, the redirecting is okay, but the message does not shown as expected. I've attach screenshot for the ECA model setup below

  • 🇲🇾Malaysia muaz91 MY
  • 🇩🇪Germany jurgenhaas Gottmadingen

    I can't reproduce this problem for authenticated users. I've loaded the model you've uploaded above, and it works just fine for authenticated users, but not for anonymous users.

    This is somehow strange, as I have added a couple of more messages to the model like this:

    For authenticated users, all 4 messages get displayed.

    For anonymous users, the bottom 2 (those without condition) get displayed, the top 2 don't. This must be something that Drupal core must be doing in \Drupal\Core\Action\Plugin\Action\GotoAction::execute where it flushes the messages for anonymous users that got collected up to that point, but not any others.

    To find out in details, I guess this requires an intensive debugging session. @muaz91 any chance you could go through that with xdebug?

  • 🇲🇾Malaysia muaz91 MY

    Hi,

    It seems that the problem is occured when disabling the module bigpipe. I'm not sure why I've disabled it before. When enable the notification is shown as normal.

  • Status changed to Fixed over 1 year ago
  • 🇲🇾Malaysia muaz91 MY

    set this to fixed. thanks @jurgenhaas

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Good finding. Shouldn't we try and make it work in all cases?

  • 🇲🇾Malaysia muaz91 MY

    Good finding. Shouldn't we try and make it work in all cases?

    It would be great! I can help test @jurgenhaas

  • Status changed to Active over 1 year ago
  • 🇲🇾Malaysia muaz91 MY
  • 🇲🇾Malaysia muaz91 MY
  • Assigned to jurgenhaas
  • 🇩🇪Germany jurgenhaas Gottmadingen
  • 🇩🇪Germany jurgenhaas Gottmadingen

    This is most likely related to 💬 Redirects and Drupal cache Fixed

  • 🇩🇪Germany jurgenhaas Gottmadingen
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    @muaz91 seems like we can get this to work without even providing new ECA functionality. Please have a look at this comment and let us know if that works for you too. The important difference is that the event Controller found, which is used in your model, isn't the right one. We need to switch that to Response created, then it works just nicely.

  • 🇩🇪Germany jurgenhaas Gottmadingen
  • 🇲🇾Malaysia muaz91 MY

    It works! I've tested out with annonymous, and also with disabling bigpipe. both works.

    Thank you @jurgenhaas

  • Status changed to Fixed over 1 year ago
  • 🇲🇾Malaysia muaz91 MY
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Thanks for your feedback, glad we've sorted this out. Will add something about this to the ECA Guide.

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

Production build 0.71.5 2024