summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--field_file.inc2
-rw-r--r--filefield_field.inc14
2 files changed, 10 insertions, 6 deletions
diff --git a/field_file.inc b/field_file.inc
index 2f17705..267aeb9 100644
--- a/field_file.inc
+++ b/field_file.inc
@@ -202,7 +202,7 @@ function field_file_save_file($filepath, $validators = array(), $dest = FALSE) {
*/
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)) {
diff --git a/filefield_field.inc b/filefield_field.inc
index 5f7fb2b..10d9963 100644
--- a/filefield_field.inc
+++ b/filefield_field.inc
@@ -87,7 +87,7 @@ function filefield_field_load($node, $field, &$items, $teaser, $page) {
// 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']);
@@ -109,8 +109,12 @@ function filefield_field_update($node, $field, &$items, $teaser, $page) {
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
@@ -138,7 +142,7 @@ function filefield_field_delete_revision($node, $field, &$items, $teaser, $page)
// 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;
}
}
}
@@ -156,7 +160,7 @@ function filefield_field_sanitize($node, $field, &$items, $teaser, $page) {
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.