When I delete revisions in Workbench moderation old files are left on the server and also the database table file_usage is not updated.

Comments

Wolfgang Reszel’s picture

I've some more informations. When saving a revision the count field in the file_usage table is increased by 2 but when deleting it's decreased by 1.

agentrickard’s picture

Project: Workbench » Workbench Moderation

Moving to the proper queue.

sachand’s picture

i am facing same problem , it does not allow me to delete files that are no more used ( revisions using these files are deleted) . If anyone found resolution /workaround on this please share.

jwilson3’s picture

I wonder how this could be even an issue for the workbench_moderation module, as it only piggybacks on the existing node/%node/revisions/%/delete menu item and the accompanying node_revision_delete_confirm_submit() function both provided by the core node module.

Can someone confirm that this issue *only* happens when workbench_moderation is enabled, and that with Workbench_Moderation disabled, Drupal core does properly cascade file deletions when you delete a revision?

agentrickard’s picture

Status: Active » Postponed (maintainer needs more info)
Wolfgang Reszel’s picture

If I remember right I found out that Workbench Moderation is causing this issue by deactivating it. Then deleting nodes worked as expected. Well, it's long ago, so I can remember wrong. The project doesn't depend on Workbench Moderation anymore.

hypertext200’s picture

Status: Postponed (maintainer needs more info) » Needs work

I can confirm that, I used file module to attach nodes in to the Article content type and those files never deleted whenever revisions are deleted.

overtune’s picture

The problem doesn't only occur when deleteing revisions.
If you do like this:
1. Create a new node and add a file.
2. Create new draft and delete the file, then publish this draft.
3. Delete the node.

Now the file is still on the server, and in the database.

hass’s picture

This means we also need an upgrade hook to run with this bugfix and delete stale files without references. I hope this is possible.

jwilson3’s picture

I'm confused by comment #7, @heshan.lk. It sounds like you're confirming that this is in fact a Drupal core issue (with just files module and revisions enabled). No? If so, then the next step is to open a core issue, and mark this as postponed again.

hass’s picture

phillamb168’s picture

As an FYI, there appears to be a fix for this in the 3.x branch which can also be applied to 1.x. Briefly, while there is indeed a problem in core for file management with revisions (which can be fixed by the following patch: https://www.drupal.org/files/node_system-delete_node_revision_hook-12395...), there is also an issue with how Workbench Moderation deals with field_attach_update() and file_field_update(). More information is available in the linked issue.