- Issue created by @somebodysysop
- 🇺🇸United States somebodysysop
Never mind. I located the issue, which was an internal one. hook_preprocess never actually stopped working. False alarm.
- 🇺🇸United States somebodysysop
Updated Issue Description
Title: hook_preprocess_status_messages() Not Invoked for Authenticated Users with Big Pipe in Drupal 10.4.3
Problem/Motivation
After upgrading from Drupal 10.1.6 to 10.4.3, hook_preprocess_status_messages() no longer fires consistently as it did pre-upgrade. Initially, I assumed it stopped working entirely, but further investigation revealed a split behavior:
Anonymous Users: The hook fires as expected, filtering messages (e.g., removing (info) messages) from the status_messages render element, and no such messages appear in the UI.
Authenticated Users: The hook does not fire, and (info) messages appear in the UI via Big Pipe AJAX commands (e.g., {"command":"message","message":"(info) Form id: user_login_form"}), bypassing the status_messages preprocess pipeline.
This change disrupts custom message filtering that worked seamlessly in 10.1.6 across all users.
Steps to Reproduce
Install Drupal 10.4.3 with Big Pipe enabled (default for authenticated users).
Implement a basic preprocess hook in a custom module (e.g., sbn.module):
phpfunction sbn_preprocess_status_messages(&$variables) { \Drupal::logger('sbn')->notice('Hook sbn_preprocess_status_messages invoked.'); }
Add test messages:
bashdrush php-eval '\Drupal::messenger()->addStatus("(info) test message");' drush php-eval '\Drupal::messenger()->addStatus("Normal message");'
Test as an anonymous user:
). Expected Behavior In Drupal 10.1.6, hook_preprocess_status_messages() fired for all users, filtering messages consistently from the status_messages render element. Actual Behavior In Drupal 10.4.3: Anonymous: Hook fires, filters messages from status_messages. Authenticated: Hook doesn’t fire for messages delivered via Big Pipe AJAX, appearing in UI unfiltered. Proposed Resolution Investigate if Big Pipe’s AJAX message delivery (command: message) in 10.4.3 intentionally bypasses hook_preprocess_status_messages() for authenticated users, or if this is a regression. Possible fix: Ensure preprocess hooks apply to both static and AJAX-rendered messages, or document this change and recommend hook_messenger_alter() or hook_ajax_render_alter() for AJAX cases. Workaround Implemented: Using hook_messenger_alter() to filter messages at the Messenger service level before queuing, avoiding Big Pipe’s bypass: php
Visit a page (e.g., /node/1).
Check logs (drush watchdog:show)—hook logs appear, messages are processed.
Test as an authenticated user (admin or non-admin):
Log in, repeat the message addition, and visit a page or trigger a Big Pipe action (e.g., form submission).
Check logs—no hook invocation logs; (info) messages appear in UI via AJAX (
Environment Drupal 10.4.3 Big Pipe enabled (default) Custom module adding (info) messages via \Drupal::messenger()->addStatus() Summary After upgrading to Drupal 10.4.3, I found that hook_preprocess_status_messages() stopped working for authenticated users. Initially, I thought it was a total failure, but it turns out it still works for anonymous users via static status_messages rendering. For authenticated users, Big Pipe AJAX delivers messages (e.g., (info) Form id: user_login_form) directly as {"command":"message"} directives, bypassing the preprocess hook. This seems tied to 10.4.x’s enhanced Big Pipe usage for authenticated sessions, which wasn’t as prevalent in 10.1.6. I’ve worked around it by using hook_messenger_alter() to filter messages earlier, but it’s unclear if this is a bug or intended behavior needing documentation. New Question: “How can I ensure consistent message filtering across static and AJAX (Big Pipe) rendering in Drupal 10.4.3 without relying solely on hook_messenger_alter(), or is this the recommended approach going forward?”function sbn_messenger_alter(array &$messages, $type) { // Filtering logic here }
- 🇺🇸United States nicxvan
Not 100%sure but i think this is a duplicate of this: https://www.drupal.org/project/drupal/issues/3456176 🐛 10.3 upgrade now missing status-message theme sugestions Active