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.
This code appears to act differently in PHP 5.2 and 5.3:
// Get error id
$error_id = @array_search($error_message, $_SESSION['messages']['error']);
if ($error_id !== FALSE) {
From https://bugs.php.net/bug.php?id=49657, "array_search returns false in 5.2.x, null in 5.3.0, when $haystack is not an array" - which is presumably why @ is used in front of the function call.
In PHP 5.2 this means that the last inline form error on a page is sometimes lost, I will hopefully post a patch when I figure out something that works on both 5.2 and 5.3!
Comment | File | Size | Author |
---|---|---|---|
#7 | ife-radios-1800974-7.patch | 626 bytes | paulvandenburg |
Comments
Comment #1
longwaveThis bug is only triggered under very specific circumstances: in my case I have a 'radios' element as the last form element, and when using "Remove all messages", an error on this element is not displayed at all on PHP 5.2 (but works as expected on PHP 5.3).
The actual cause is the difference in return value from array_search() - FALSE instead of NULL - but I think the correct fix is to not recurse into child elements if they are one of the excluded types. The attached patch works for me, as in on PHP 5.2, inline form errors show correctly if a radio button set is the last element with errors on a form.
Comment #2
jamsilver CreditAttribution: jamsilver commentedAs pointed out by pontus_nilsson over in #1826242: Notice: Undefined index: #type in ife_element_errors_set() (line 269 of .../ife.module), the above patch introduces a PHP Notice for certain elements which legitimately do not have a '#type' property. I have attached pontus_nilsson's patch here which fixes the problem.
Comment #3
mibfire CreditAttribution: mibfire commentedshould be
Comment #4
MrHaroldA CreditAttribution: MrHaroldA commentedSetting it back as per mibfire's comment ...
Comment #5
stijndm CreditAttribution: stijndm commentedThis might be fixed in the latest dev version. The code has been overhauled. Can you please try out the latest dev?
Comment #6
kenorb CreditAttribution: kenorb commentedComment #7
paulvandenburg CreditAttribution: paulvandenburg at iO commentedRerolled patch and added mentioned change in #3, but cleaned up the if logic.
The changes in dev seem unrelated to this code so I don't think this issue is fixed already.