Download & Extend

File usage is increased incorrectly when saving new revision

Project:File (Field) Paths
Version:7.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hi,

I've found out that file usage is increased incorrectly when saving new revision of the node. It happens because of call field_attach_update and passing node with revision flag equal to 1.

The fix is easy but i wasn't able to do it for the latest dev version, it seems not working, because of incorrect condition in the select query from the filefield_paths table.
When field settings are saved, only content type name is saved in the "type" column.
But when module tries to process it later it looks for key "$type::$bundle". Because of that files are not processed.

Please review the patch and consider updating module if the code is relevant.

Thanks,
Dmitry

AttachmentSize
unnecessary-revision-for-fields-removed.patch682 bytes

Comments

#1

Status:active» reviewed & tested by the community

Hi Dmitry,

Your patch looks good and I do remember confirming and fixing this issue in D6 so this fix (or similar) will be in the next Dev release.

Cheers,
Deciphered.

#2

Status:reviewed & tested by the community» postponed (maintainer needs more info)

Strike that last status, I wasn't able to reproduce this issue and therefore I don't want to commit anything unnecessarily.

Can you please provide more information (using the latest dev) on how to reproduce this issue? The patch you provided was clearly quite old as it was referring to $node, where the latest dev should have no reference to $node, only references to $entity.

Cheers,
Deciphered.

#3

Title:Revisions handling» File usage is increased incorrectly when saving new revision
Status:postponed (maintainer needs more info)» needs review

Reproduce like this:

  1. Install clean Drupal 7.10
  2. Install modules Token and FileField Paths (latest dev)
  3. Create content type and add existing field "Image: field_image (Image)"
  4. Edit the field's settings - under IMAGE PATH SETTINGS - in the field "File path" write "images" or whatever
  5. Save content type and add content of the newly created type: Upload an image in the image field and select to save new revision

When content is saved, look in the database table file_usage and you should find that the file you uploaded has count = 2. This should really be 1. This makes files uploaded this way impossible to delete from within Drupal (e.g. IMCE) because even if you delete all revisions that uses the file, the count in file_usage will still be at least 1 and Drupal thinks that something is using the file.

I made a patch based on Dmitry's, but against the latest dev. This patch works for me.

(This is the first patch I posted to drupal.org, yay!)

AttachmentSize
revisions-handling-1334448-0.patch 710 bytes

#4

Status:needs review» fixed

Issue confirmed, patch is (mostly) good and committed to 7.x-1.x.

Cheers,
Deciphered.

#5

Status:fixed» closed (fixed)

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

nobody click here