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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

FrancescoQ created an issue. See original summary.

FrancescoQ’s picture

goron’s picture

+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.

  • markcarver committed c16b6fb on 7.x-3.x authored by FrancescoQ
    Issue #2912796 by FrancescoQ: Undefined index 0 when unsetting the first...
markhalliwell’s picture

Assigned: FrancescoQ » Unassigned
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.