It is possible to have a one-to-many relationship between files and nodes (one file being attached to many nodes). This is especially true if using filefield sources or extracting from body text #937702: Check the body field for hyperlinks to files. Currently the module thows database errors if a file is attached to more then one node.
This patch changes the relationship of files to nodes. The update6002 function assumes that patch #936466: Body field can be NULL on initial insert has already been committed.
WIth search results, there will be multiple search results for the file, one for each node the file is attached to.
Comment | File | Size | Author |
---|---|---|---|
#1 | multifile.patch | 8.29 KB | aaron1234nz |
multifile.patch | 8.29 KB | aaron1234nz |
Comments
Comment #1
aaron1234nz CreditAttribution: aaron1234nz commentedI found a bug. Here is a better version
Comment #2
pwolanin CreditAttribution: pwolanin commentedQuick read through the patch, looks like a reasonable start. However, I'm suspecting that the same file will now appear in the search results multiple times?
Comment #3
aaron1234nz CreditAttribution: aaron1234nz commentedYes you are right in that the same file will appear multiple times in the search result. I'm not sure if this is desired behaviour or not? When I was writing the patch I could not decide if one result should come back, referencing all the nodes it was attached to or one result per node.
If only one result comes back, then filtering (via facets) on author (and possibly node properties?) would become very difficult. Coding this options would also require quite a bit of thought.
The other option was easier to implement. My thinking was also that each node has its own context (written about a specific topic), so one result per node per file attachment might not be a bad idea.
Comment #4
pwolanin CreditAttribution: pwolanin commentedGiven that this is a relatively rare use case in the Drupal world in D6, maybe we can live with the multiple results.
Comment #5
pwolanin CreditAttribution: pwolanin commentedIt would seem easier to make a composite primary key?