Extending Attachment model with extra JOIN clause in add-on


XenForo developer
Staff member
It depends what method you're trying to extend. If there isn't a "hook" point of sorts, you'd be replacing the method in question with custom code. In a method like getAttachments(), you'd extend prepareAttachmentFetchOptions and either adjust the calling code to have your join or "piggyback" so that your data is fetched when you need it.
There's no hook, no (that's what I proposed in my other thread, but it seems like a no-go).

For the alternative method, you're suggesting copying some of the code from XF's Attachment model into my subclass and then modifying it there, right? Not ideal, but better than hacking core XF files I suppose.
See the other thread I linked-- I'm trying to update the [bd] Attachment Store addon so it doesn't have to store its backend config options in every row of xf_attachment_data, and can instead store them in a separate table (but without generating additional queries).

So the queries in getAttachmentsByContentIds, getAttachmentById, etc. would need to be modified with an extra JOIN clause.