Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When there are multiple messages, the key is not used. But when there is only one, the expected key is 0, which is not always correct (for example #1945758: Work around theme_status_messages() limitation to display checkout form errors outside panes).
if (count($messages) > 1) {
$output .= " <ul>\n";
foreach ($messages as $message) {
$output .= ' <li>' . $message . "</li>\n";
}
$output .= " </ul>\n";
}
else {
$output .= $messages[0];
}
I'm not sure if it is a bug, or if we want to keep the core simple.
Comments
Comment #1
rszrama CreditAttribution: rszrama commentedHope you don't mind me closing this, but I'd already made this a separate issue against 7.x (as this will be deprecated in 8.x by the change to TWIG).
See: #1946240: Remove the hardcoded 0 index in theme_status_messages()
Comment #2
jcisio CreditAttribution: jcisio commentedNo problem, you created that issue 3 minutes before mine ;)