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.

CommentFileSizeAuthor
#1 multifile.patch8.29 KBaaron1234nz
multifile.patch8.29 KBaaron1234nz
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aaron1234nz’s picture

FileSize
8.29 KB

I found a bug. Here is a better version

pwolanin’s picture

Quick 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?

aaron1234nz’s picture

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

pwolanin’s picture

Given that this is a relatively rare use case in the Drupal world in D6, maybe we can live with the multiple results.

pwolanin’s picture

Issue summary: View changes
Status: Needs review » Needs work

It would seem easier to make a composite primary key?