filefield_field_load unserializes incorrectly. It should be:
if (isset($item['data']) && !empty($item['data'])) {
$item['data'] = unserialize($item['data']);
}
Since the current version doesn't check if the string is empty, unserialize may return a spurious FALSE into item['data'] because unserialize returns FALSE on error. This may eventually lead to a corrupt serialized column in the database, like 'b:0;', which causes problems later in the array_merge at line 306:
// Load the complete file if a filepath is not available.
if (!empty($item['fid']) && empty($item['filepath'])) {
$file = (array) field_file_load($item['fid']);
if (isset($file['data'])) {
$file['data'] = array_merge($file['data'], $items[$delta]['data']);
}
$items[$delta] = array_merge($file, $items[$delta]);
}
The attached patch fixes this for me.
(I noticed this problem while using DraggableViews on a view with a filefield. When a new node is created that would display in the view, the view needs to load the node, change the cck order field, and reload the node (I think). Somewhere along the line, it serializes the FALSE and disrupts the later array_merge, which expects an array instead of a boolean.)
| Comment | File | Size | Author |
|---|---|---|---|
| filefield_field_load.patch | 646 bytes | nonzero |
Comments
Comment #1
quicksketchLet's merge with the existing issue #791118: warning: array_merge(): Argument #2 is not an array.