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.
Problem/Motivation
If there are two messages (and only two) and the first one is unsetted (with disable_messages module, or by custom code, it's indifferent) the following code will be executed,
$output .= filter_xss_admin($messages[0]);
resuting in an "undefined index" error, because there's no item with key 0
Proposed resolution
I propose to substitute $messages[0] with reset($messages) to have the first value regardless of the key
Comment | File | Size | Author |
---|---|---|---|
#2 | bootstrap_undefined-index-0-when-unsetting-first-of-two-messages-2912796-2.patch | 482 bytes | FrancescoQ |
Comments
Comment #2
FrancescoQ CreditAttribution: FrancescoQ commentedHere's the patch
Comment #3
goron CreditAttribution: goron commented+1 to this issue and patch.
This can also happen during a multipage webform, where submits of pages after the first page can result in a single message with an index higher than 0. This causes the same error reported above, for the same reason, and is fixed by this patch.
Comment #5
markhalliwell