Missing status-message theme suggestions

Created on 30 December 2024, 28 days ago

Problem/Motivation

Upgraded to 10.3 and status-message.html.twig is missing as a theme suggestion.
https://www.drupal.org/project/drupal/issues/3456176 🐛 10.3 upgrade now missing status-message theme sugestions Active

Steps to reproduce

Upgrade to 10.3

Proposed resolution

Use a workaround until the bug is fixed:

/**
 * Implements hook_preprocess_block_HOOK() for HTML document templates.
 */
function italiagov_preprocess_block__system_messages_block(&$variables) {
  $variables['content'] = StatusMessages::renderMessages();
}
🐛 Bug report
Status

Active

Version

2.12

Component

Code

Created by

🇮🇹Italy arturopanetta Grotteria (RC)

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

Merge Requests

Comments & Activities

  • Issue created by @arturopanetta
  • Merge request !1updated mr → (Open) created by Unnamed author
  • Pipeline finished with Success
    28 days ago
    Total: 160s
    #381845
  • 🇮🇹Italy marcob77

    renderMessages is a method of class \Drupal\Core\Render\Element\StatusMessages

  • 🇮🇹Italy arturopanetta Grotteria (RC)

    @deepali-sardana thanks for your help, I checked the code and there are some things wrong.

    The first thing wrong is the name of the suggestions, the name of the suggestions is wrong. In the file you modified it should be `bootstrap_italia_preprocess_block__system_messages_block`; maybe my example above misled you, sorry. In the jargon of this project `italiagov` means `your_sub_theme`, the change must be applied in the subtheme that each user creates. I correct the example above to be more specific.

    The second thing I didn't understand is why you use: `BubbleableMetadata::renderMessages();` instead of `StatusMessages::renderMessages()`.

    @marcob77 yes sure, you have to import StatusMessage, I correct the suggestion above, a complete example here https://github.com/ouitoulia/skenografia/blob/2.x/includes/workaround.inc

  • 🇮🇹Italy marcob77

    why fix it in subtheme and not in the main theme? Just to wait drupal fix problem?

  • 🇮🇹Italy arturopanetta Grotteria (RC)

    Since I used the workaround as a temporary patch most of the time, it provided me with short-lived solutions. I would like to avoid releasing continuous patches for this issue and wait for a stable fix from Drupal core, also I thought I would use this issue to communicate updates on new workarounds and/or discuss better solutions.

    So far I have not identified any benefits of putting the workaround in the main theme, if you have identified any maybe we can discuss it here and see if it is possible to do so. Please note that: 1) until February 2025 you also need to patch/keep 2.8.x up to date; 2) not all installations are on Drupal 10.3, for older versions you should not use the workaround.

Production build 0.71.5 2024