Closed (works as designed)
Project:
Drupal core
Version:
6.6
Component:
system.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Oct 2008 at 21:09 UTC
Updated:
8 Jan 2009 at 14:51 UTC
Hi, this is already reported in others modules too #326041: Fatal error: Unsupported operand types in:, but in my case is happening in system.module. Some hosting sites, using PHP 5.2.6 (like Mosso) are rising this problem. Can't array_merge be used as default in core modules in order to avoid this?
Comments
Comment #1
sfranchi commentedThis error only happens when the array to be added is not actually an array (as when db_fetch_array() returns FALSE).
The array can be avoided by casting the element to add as an array using
but anyway, the code using this should be able to take action based on that.
Comment #2
gábor hojtsyThe modules reusing core functions should ensure that data passed in is an array, not FALSE, when the API documents to accept an array and no non-arrays. Please reopen this if you know of core places where the data type is not checked or documented in the API when expecting an array.
Comment #3
sfranchi commentedOk, but the core shouldn't check the received data? A simple call to is_array will make it bullet (and fool) proof.
Comment #4
gábor hojtsyDrupal does not usually check data type to be the one defined by the API, except when there is some security concern. Where exactly would you think we'd need this?
Comment #5
damien tournoud commentedWe don't babysit broken code. That create cruft everywhere.
In Drupal 7, now that we require PHP5, we are adding type-hinting to those types of parameters.
Comment #6
sfranchi commentedWhere ? Wherever it can cause a crash, but if you think is only responsability of the module consuming the API, is ok the way it is, there is nothing to change.
# Damein, good to hear that about Drupal 7.
Thanks,