I've been getting the following errors when deleting files and invoking hook_file_delete:

warning: Invalid argument supplied for foreach() in /srv/wpslabs/drupal/sites/testbed0.ccs.mcgill.ca/modules/contrib/cck/content.module on line 1244.
warning: Invalid argument supplied for foreach() in /srv/wpslabs/drupal/sites/testbed0.ccs.mcgill.ca/modules/contrib/cck/content.module on line 1284.
warning: Invalid argument supplied for foreach() in /srv/wpslabs/drupal/sites/testbed0.ccs.mcgill.ca/modules/contrib/cck/content.module on line 1284.
warning: Invalid argument supplied for foreach() in /srv/wpslabs/drupal/sites/testbed0.ccs.mcgill.ca/modules/contrib/cck/includes/content.token.inc on line 42.

I tracked the errors down to the fact that this line in filefield_delete_file_references():

$node = node_load(array('vid' => $vid));

fails to load a node. I believe this is because the line should be:

$node = node_load($nid, $vid);

This loads that revision of that node, whereas the current code tries to load a node with the current revision set to $vid.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lambic’s picture

Just to expand on this a little, the node_load does actually work for the current revision of the node, but fails on all past revisions of the node because node_load is querying the node table, not the node_revisions table

quicksketch’s picture

Title: File deletion not handling revisions correctly. » File deletion not handling deletion of previous revisions correctly
Status: Active » Fixed
FileSize
417 bytes

I think you're right. What we're doing only works for the current revision and not for past revisions. I've committed this change which makes the switch you recommend.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.