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.

Ref #1939082: Convert theme_status_messages() to Twig.

Comments

rszrama’s picture

Category: bug » task
Status: Active » Closed (duplicate)

Hope 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()

jcisio’s picture

No problem, you created that issue 3 minutes before mine ;)