Postponed
Project:
Multifield
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
31 Jul 2013 at 01:59 UTC
Updated:
6 May 2016 at 05:51 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dave reidComment #2
dave reidTaking this one at for the next release.
Comment #3
dave reidComment #4
juampynr commentedLooks like we need to add a call to
file_usage_add($file, 'multifield', 'node', $node->nid)when a file is saved. I am debugging the module to see where is the best place to add this.Comment #5
juampynr commentedThe following patch adds file usage statistics for multifield files.
I have updated the issue metadata because this bug makes it impossible to re-save entities containing files.
Comment #6
juampynr commentedHere is an improved version of the patch thanks to feedback given by @q0rban.
Comment #7
badrange commentedI used this patch together with a patch from #2327317: Integrity constraint violation when saving multifield with a file subfield and I still get the same error. Without those patches I get a SQL error when trying to edit a page with a multifield. With the patches I can add an image and save the page with no sql errors, but not edit the page after uploading images.
File usage page shows that the files are used 0 times.
Comment #8
dave reidI want to work on this a bit more, there are some issues with the patch.
This line here assumes that this structure exists, when it in fact may not (for example, if we're adding a record, this will cause a notice since the new larger $delta does not exist on the original object).
Overall, this doesn't seem to cover the logic in hook_field_insert() and hook_field_delete() as well. I'm working on some tests around file usage in #2327317: Integrity constraint violation when saving multifield with a file subfield that can easily be extended to test support for usage tracking on the parent entity.
But I think the biggest problem is that we've seen this pop up with multiple field types. For example, with taxonomy terms: #2390233: Taxonomy terms in multifields on nodes don't update taxonomy_index table. I'm wondering if maybe there could be a more general solution that somehow takes a stub version of the parent entity, puts the subfield values onto it, and runs hook_field_insert|update|delete where needed, which should account for file usage tracking and taxonomy index tracking for the parent entity.