Current time: 03-20-2010, 04:37 PM Hello There, Guest! (LoginRegister)


 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[F] Attachments: bug returned
08-23-2008, 11:23 PM (This post was last modified: 08-23-2008 11:24 PM by destroyer.)
Post: #1
[F] Attachments: bug returned
See attachment.

Last user, who has been deleted before is a top 5 username there. But nothing's shown there.


Attached File(s)
.bmp  sdf.bmp (Size: 341.24 KB / Downloads: 99)

[Image: destroyerjf8.jpg]

Give us your feedback about MyBB in this thread and become listed on the MyBB website.
Visit this user's website Find all posts by this user
08-24-2008, 11:52 PM
Post: #2
RE: Attachments: bug returned
Easy fix:
in admin/modules/forum/attachments.php find:
PHP Code:
    $query $db->query("
        SELECT a.*, u.uid, u.username, SUM(a.filesize) as totalsize
        FROM "
.TABLE_PREFIX."attachments a  
        LEFT JOIN "
.TABLE_PREFIX."users u ON (u.uid=a.uid)
        GROUP BY a.uid
        ORDER BY totalsize DESC
        LIMIT 5
    "
); 
replace with
PHP Code:
    $query $db->query("
        SELECT a.*, u.uid, u.username, SUM(a.filesize) as totalsize
        FROM "
.TABLE_PREFIX."attachments a  
        LEFT JOIN "
.TABLE_PREFIX."users u ON (u.uid=a.uid)
        WHERE u.uid != 0
        GROUP BY a.uid
        ORDER BY totalsize DESC
        LIMIT 5
    "
); 
Visit this user's website Find all posts by this user
08-25-2008, 12:03 AM
Post: #3
[F] Attachments: bug returned
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

[Image: ryangordon.png]
My Blog - My Mods
Visit this user's website Find all posts by this user
08-25-2008, 12:43 AM
Post: #4
RE: [F] Attachments: bug returned
Actually, wait, I might have made a mistake, does that actually work with MySQL? u.uid is probably actually NULL, but I think MySQL treats it as 0, but that's just a guess...
(I can't test things here at Uni)
Visit this user's website Find all posts by this user
08-25-2008, 04:57 AM
Post: #5
RE: [F] Attachments: bug returned
Yes, I believe MySQL will treat it as a null if the column row doesn't exist when left joining. a u.uid > 0 is probably better since that would include null's too (null can't be more then 0)

[Image: ryangordon.png]
My Blog - My Mods
Visit this user's website Find all posts by this user
08-25-2008, 11:30 AM
Post: #6
RE: [F] Attachments: bug returned
So what's the fix now then?

[Image: destroyerjf8.jpg]

Give us your feedback about MyBB in this thread and become listed on the MyBB website.
Visit this user's website Find all posts by this user
08-25-2008, 03:07 PM
Post: #7
RE: [F] Attachments: bug returned
Try This:


Attached File(s)
.php  attachments.php (Size: 32.11 KB / Downloads: 86)

[Image: ryangordon.png]
My Blog - My Mods
Visit this user's website Find all posts by this user
08-25-2008, 04:40 PM
Post: #8
RE: [F] Attachments: bug returned
Still the same as before...

[Image: destroyerjf8.jpg]

Give us your feedback about MyBB in this thread and become listed on the MyBB website.
Visit this user's website Find all posts by this user
08-25-2008, 11:16 PM (This post was last modified: 08-25-2008 11:17 PM by Yumi.)
Post: #9
RE: [F] Attachments: bug returned
I think there's a bit of an issue with using this:
PHP Code:
        if(!$user['uid'])
        {
            
$user['username'] = $lang->na;
        } 
Since "a.*" will pull in a uid with a number. Try changing something like this
Code:
SELECT a.*, u.uid, u.username, SUM(a.filesize) as totalsize
to
Code:
SELECT a.*, u.uid AS useruid, u.username, SUM(a.filesize) as totalsize
and make the other appropriate change.

(or, if you wanted to, you could check for the username)
Visit this user's website Find all posts by this user
08-25-2008, 11:48 PM
Post: #10
RE: [F] Attachments: bug returned
How will it put in a uid with a number higher then 0 if it doesn't even exist? Either way my "if statement" should catch all cases - It's not a strict comparison.

[Image: ryangordon.png]
My Blog - My Mods
Visit this user's website Find all posts by this user


Forum Jump: