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.
warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/www/html/sites/all/modules/filefield/filefield.module on line 267.
This error come when I finish setting up a cck image field with "Widget type: Image with cropping"
Earlier I faced this error on 6.x-3.0-alpha5 that came on on line 273 .. NOT with the dev version it is on line 267.
any idea?
Comment | File | Size | Author |
---|---|---|---|
#16 | filefield-widget-settings-355392-16.patch | 1.81 KB | markus_petrux |
#15 | filefield-widget-settings-355392-15.patch | 502 bytes | markus_petrux |
Comments
Comment #1
bensemmel CreditAttribution: bensemmel commentedSame error
Comment #2
CKIDOWSame thing here...
Comment #3
realityloopSame issue here
Comment #4
drewish CreditAttribution: drewish commentedplease try the -dev release and confirm that it's present there too.
Comment #5
mrfelton CreditAttribution: mrfelton commentedI get the same problem using alpha6 which was created on the same day as the latest -dev version.
Comment #6
apadernoComment #7
mariusooms CreditAttribution: mariusooms commentedSame issue...subscribe. Filefield 6.x-3.0-alpha6, haven't tried dev.
Marius
Comment #8
markus_petrux CreditAttribution: markus_petrux commentedI believe this problem is caused by imagefield_crop module.
In filefield_widget_settings() there's the following code:
And that means any module that implements a {$widget_type}_widget_settings_{$op} should return an array. However, if we look at imagefield_crop_widget.inc, there's at least one of these implementation that doesn't meet the requirement, hence it crashes in the caller. For example:
One possible solution for filefield would be to check the result of calling widget_settings function, maybe like this:
Comment #9
apadernoThe code reported in #8 is present in 6.x-3.x-dev too.
As stated in field.php, the values returned from the implementation of
hook_widget_settings()
are:It doesn't then seem a problem with a specific module.
Comment #10
markus_petrux CreditAttribution: markus_petrux commentedhmm... that field.php doesn't exist in CCK 6. Anyway, 'validate' is probably the cause of the problem here. The file imagefield_crop_widget.inc contains a widget validate handler that's empty, it returns nothing, hence it causes the reported problem on filefield.
Note that is reported to happend when setting up a "Widget type: Image with cropping", so this is an issue that can be fixed in 2 ways:
1) imagefield_crop removes the function imagefield_crop_widget_widget_validate() or makes it return array().
2) filefield code includes a defensive check in the loop running widget operation handlers so that array_merge is used only if the return value is an array.
Comment #11
apadernoThe content of field.php is also reported in the documentation for
hook_widget_settings()
.I think that is rather difficult a validation function in the FAPI style is required to return anything, in Drupal.
filefield.module should avoid to check the return value when
$op
is equal to'validate'
or, more generally, it should check the value type returned from the called function.For other informations, see CCK for Developers.
Comment #12
markus_petrux CreditAttribution: markus_petrux commentedOh, I see what you mean. Then, probably imagefield_crop_widget_widget_validate() would be compliant with CCK documents, and the correct fix would affect filefield, so it should do something like this:
...or more generally, a defensive check on the result as posted in #8:
This is part of function filefield_widget_settings() in filefield.module.
Comment #13
apadernoThe defensive check on the result is probably better for when CCK implements new operations for the
hook_widget_operations()
, and filefield.module is still not updated to handle them.I would write the code like:
The call to
isset()
before the call tois_array()
is normally used on Drupal code; it avoids the code raises an access to a undefined variable warning.Comment #14
drewish CreditAttribution: drewish commentedsomeone want to roll a patch?
Comment #15
markus_petrux CreditAttribution: markus_petrux commentedAttached patch as in #13
Comment #16
markus_petrux CreditAttribution: markus_petrux commentedRe-rolled as the same exact issue affects other pieces of code in filefield.module.
Comment #17
drewish CreditAttribution: drewish commentedlooks good, committed to HEAD.
Comment #18
bgogoi CreditAttribution: bgogoi commentedi just patched mine. no issues now. Thanks to all of you :)