Smf2.1: ManageAttachments query oddity

Created on 27 Sep 2020  路  3Comments  路  Source: SimpleMachines/SMF2.1

https://github.com/SimpleMachines/SMF2.1/blob/545d0930516dd83211ecda7a9ade9fb3011793cd/Sources/ManageAttachments.php#L693

If you look between the list_getFiles and list_getNumFiles we are doing 2 different filters for the WHERE

In list_getNumFiles we do:

            WHERE a.attachment_type = {int:attachment_type}
                AND a.id_member = {int:guest_id_member}',

And in list_getFiles we do:

            WHERE a.attachment_type = {int:attachment_type}

I'm not sure why. It doesn't seem to be causing any issues far as I can tell. I wanted to hear feedback before suggesting we fix it though.

Minor Bug

All 3 comments

Looking at the attachment tables for one of my forums, it appears that id_member is only stored for avatars and not for regular attachments (or attachment thumbnails for that matter). I guess that's because every attachment is associated with a post and we can get the id_member from there instead.

Correct. Attachments are message-specific. Avatars are user-specific.

Which explains why it hasn't caused a bug. So this is a minor code cleanup. Nothing critical, but could be sent up in another PR to standardized the queries.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sesquipedalian picture Sesquipedalian  路  6Comments

KarelWintersky picture KarelWintersky  路  5Comments

NegativeIQ picture NegativeIQ  路  11Comments

albertlast picture albertlast  路  12Comments

Dzonny picture Dzonny  路  9Comments