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.
Comment | File | Size | Author |
---|---|---|---|
#2 | filefield-past-revision-load-1210710.patch | 417 bytes | quicksketch |
Comments
Comment #1
lambic CreditAttribution: lambic commentedJust 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
Comment #2
quicksketchI 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.