The function media_mover_api_node_update($node) is supposed to delete any media-mover files that the user has marked for deletion, and also delete entries for these files in the media_mover_files table. But it is not working. There are two problems. First, the function assumes that information about the media-mover files is stored in $node->media_mover. But $node->media_mover is generally not set. Second, the function assumes that $node->files stores information about whether a file has been marked for removal. But $node->files is generally not set if the files are stored in a filefield, as opposed to being attached to the node itself.
I believe the attached patch fixes these problems. It also fixes the problem described here, that when a media-mover file gets deleted, its listing in the 'files' table is not deleted: http://drupal.org/node/1477820
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | media_mover_api.bug3_.diff | 1.49 KB | kobnim |
| #5 | mm_node.bug3_.diff | 3.73 KB | kobnim |
| #2 | media_mover_api.diff | 3.27 KB | kobnim |
| #1 | media_mover_api.diff | 2.55 KB | kobnim |
| media_mover_api.diff | 2.71 KB | kobnim |
Comments
Comment #1
kobnim commentedThere is a small bug in the patch above. Use this one instead.
Comment #2
kobnim commentedThe previous patch does not properly handle child-configs, because this is not defined in a child-config:
$config->harvest->configuration[mm_config_harvest_field]I am attaching an updated patch that properly handles child-configs.
Comment #3
arthurf commentedKobnin - I'm willing to take your patch here but would you mind cleaning up the tabs? The Drupal community has a rather strict sense about it. Also I tend to put } else { on separate lines for readability. It's certainly not necessary but the rest of the module is coded that way.
A few notes:
* it might be good to have media_mover_api_node_files_fetch() set $data = array(); and then you can test if ($node->media_mover)
* you might want to look at mm_node_node_presave() in the 6.x-2x branch. I refactored a tonne of stuff there which might be worth considering.
Comment #4
kobnim commentedArthur,
Just to make sure I understand what you are suggesting ...
Are you suggesting that in media_mover_api_node_files_fetch(), I replace:
return $data->data;with:
return $data->data ? $data->data : array();Thanks,
Mindy
Comment #5
kobnim commentedHere is a revised version of the patch. I moved hook_node_update into mm_node.
In addition to fixing the issue reported above, the patch also fixes this issue:
http://drupal.org/node/1477820: deleted file is still listed in 'files' database table