StackMiddleware service causing edit form render issues

Created on 4 September 2024, 2 months ago
Updated 5 September 2024, 2 months ago

Hey there, just wanted to report a null value issue my site is having with the http_middleware.alert_message service.

I'm not exactly clear on the cause of the issue as it depends on interactions with the core content_moderation and contrib scheduled_publish modules. The end result is a null value for moderation state on edit forms, however this only occurs while http_middleware.alert_message is injected into the render pipeline. I'm not sure if anyone will have any success reproducing or if the problem is unique to my site.

To resolve this issue for my purpose I've simply removed the service, and the alerts still appear to be functioning fine. I was wondering if you could comment on why the service might be needed for cache invalidation, considering that the alerts will be invalidated on save.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @Timmy_Cos
  • 🇭🇷Croatia Aporie

    Hello,

    Can you share more details on your issue, maybe screenshots?

    The middleware is needed because you need to invalidate the alert block cache for each logged-in user and eventually each anonymous users (so on each request).

    So basically this block can't be cached.

  • Thanks aporie,

    Ahh yup that makes sense. Luckily in my case I don't need the alerts to vary by user so I think what I've got will work. Unfortunately I can't provide much more info, I can't figure out why the middleware causes problems for my site and haven't had time to try reproduce on a clean install.

    I mostly just wanted to record the issue in case others have the same problem. If so it could possibly be resolved by setting a user context on the block, e.g. as in https://drupal.stackexchange.com/questions/288881/problem-setting-user-s....

  • 🇭🇷Croatia Aporie

    Yeah ... A user context will only cover logged-in users, unfortunately.

    That's why we need this stack middleware, to cover anonymous users.

    I'm keeping this ticket open for reference.

Production build 0.71.5 2024