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

Comments

kobnim’s picture

StatusFileSize
new2.55 KB

There is a small bug in the patch above. Use this one instead.

kobnim’s picture

StatusFileSize
new3.27 KB

The 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.

arthurf’s picture

Kobnin - 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.

kobnim’s picture

Arthur,
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

kobnim’s picture

StatusFileSize
new3.73 KB
new1.49 KB

Here 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