Not directly an issue with this, but I guess it needs addressing and is best done here.
I'm trying to index files on a CCK node using the filefield module. The module's hook_nodeapi implementation currently looks for $node->file to get the information base on which it populates it's own table, however in the case of these nodes it's $node->field_file (or something similar).
Could be hacked to work easily enough, or made to support both. Alternatively, I thought maybe if it interrogates the file table with the node id to gather the details then that would probably be better and should be compatible with any implementation. Would have to double check the order of actions for nodeapi to make sure that the files table is populated first, but soulds good in theory.
Anyway, I'm going to tackle this in the next few days, but thought I'd raise the issue now to open it up to discussion before I get started.
Cheers,
Jon
Comments
Comment #1
jondoesdrupal commentedOK, so I've rewritten the nodeapi update portion. I'll submit it copy and paste style to save any patch confusion with my other submissions.
In addition to resolving the issue of the module barfing on anything that doesn't have the $node->files var, I think I spotted that some of the sql statements had a few bugs in them, so I'm not entirely sure that it was working as it was before.
Cheers,
Jon
Comment #2
jondoesdrupal commentedAlso noticed that it runs against update, submit and insert - the submit seems superfluous, so I imagine that can be removed.
Comment #3
jondoesdrupal commentedHave found similar issues with the _swish_do_update function which is called by cron - mal formed sql statements. Have rewritten them to fix them and give them a general tidy.
One thing I noticed though was that in cron, it looks for files with matching filepaths and nids, whereas in the nodeapi hooks, it just matches on filepath, which would potentially clear more than one node if they had the same file attached. In practice I don't think this would be a problem, as if the same file was uploaded it would be saved with a different name (file and file_2 or something like that), however for completeness here's the updated code.
Comment #4
jondoesdrupal commentedOne more time......
Comment #5
jondoesdrupal commentedOK, last time, tested this time and should all be ok
Comment #6
jondoesdrupal commentedAnd it includes an implementation to delete records on node deletion.
Comment #7
populist commentedGreat improvement to the module. Added several months ago, closing out the issue.
Comment #8
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.