Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291153

Remove the hardcode 0 index in theme_status_messages()

$
0
0

In this code block, theme_status_messages() hardcodes a 0 index for the $messages array when theming a single value message array:

<?php
   
if (count($messages) > 1) {
     
$output .= "<ul>\n";
      foreach (
$messages as $message) {
       
$output .= '  <li>'. $message . "</li>\n";
      }
     
$output .= "</ul>\n";
    }
    else {
     
$output .= $messages[0];
    }
?>

The problem is that if you're doing any sort of manual interaction with the messages session variable, you may end up with a single value array that does not have a 0 key. Instead of adding $messages[0] to $output, this could be changed to reset($messages) if desired. I'm sure there are other ways to deal with this, the most robust of which will not get into 7.x - provide a proper API around status messages. ^_^


Viewing all articles
Browse latest Browse all 291153

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>