*/
function field_file_save($node, &$file) {
// If this item is marked for deletion.
- if (!empty($file['delete'])) {
+ if (!empty($file['delete']) || !empty($file['_remove'])) {
// If we're creating a new revision, return an empty array so CCK will
// remove the item.
if (!empty($node->old_vid)) {
// Despite hook_content_is_empty(), CCK still doesn't filter out
// empty items from $op = 'load', so we need to do that ourselves.
if (empty($item['fid']) || !($file = field_file_load($item['fid']))) {
- unset($items[$delta]);
+ $items[$delta] = NULL;
}
else {
$item['data'] = unserialize($item['data']);
foreach ($items as $delta => $item) {
$items[$delta] = field_file_save($node, $item);
// Remove items from the array if they have been deleted.
- if (empty($items[$delta])) unset($items[$delta]);
- $curfids[] = $item['fid'];
+ if (empty($items[$delta]) || empty($items[$delta]['fid'])) {
+ $items[$delta] = NULL;
+ }
+ else {
+ $curfids[] = $items[$delta]['fid'];
+ }
}
// if this is a new node... there are no
// For hook_file_references, remember that this is being deleted.
$item['field_name'] = $field['field_name'];
if (field_file_delete($item)) {
- unset($items[$delta]);
+ $items[$delta] = NULL;
}
}
}
foreach ($items as $delta => $item) {
// Cleanup $items during node preview.
if (empty($item['fid']) || !empty($item['delete'])) {
- unset($items[$delta]);
+ $items[$delta] = NULL;
continue;
}
// Load the complete file if a filepath is not available.