Bug tracker

This ticket has been moved to our new tracker. Open Ticket PHPBB3-8470 now.

False conversion from MiB to MiB (fix completed in vcs)

If I enter x>=1024 MiB at fields "Total attachment quota", "Maximum file size" or "Maximum file size messaging" then after i press Submit the value will be divided by 1024. So if i enter 2048 MiB and press Submit after reload the field will mistakenly show 2 MiB.

If the value I insert is less or equal than 1023 MiB then it will not be divided with 1024 and will show as is.

This started after i updated from 3.0.4 to 3.0.5.

Comments / History

Assigned ticket to user "bantu"

Action performed by bantu (3.0 Release Manager) on Jul 4th 2009, 15:31

Changed ticket status from "New" to "Reviewed"

Action performed by bantu (3.0 Release Manager) on Jul 4th 2009, 22:37

Posted by Eelke (QA Team) on Jul 5th 2009, 12:17

Does the actual quotum also end up being divided by 1024? (I'm sure it would when pressing save again with the new value filled in, it would be interesting to know what it is right after saving the large value).

Posted by TomK000 on Jul 5th 2009, 13:32

Hhmmm strange things happened at my tests. Let's start...

Total Attachment quota:
At start I entered 3.072.000 MiB so after submit the field said 3000 MiB. Of course i was able to upload a file 3.5MB.
I deleted this file, i pressed once again submit, without changing anything, so because the field had 3000 after submit this value was 3000/1024= 2.93 MiB. Again i was able to upload the same file (3.5MB).
I deleted it once again, again pressed submit so the value remained 2.93 MiB (because the original value was less than 1024) and now i wasn't able to upload it because i had reached the board quota.

So it seems that the actual quotum doesn't end up divided but only the reading on the field.

Totally different things happened with "Maximum file size" which seems not to be working at all. Even if I entered 1024 MiB (so after submit it would say 1 MiB), or directly 1 MiB, or even 1024 KiB (so after submit it would say again 1 MiB) I was still able to upload the same file of 3.5 MB. Maybe this is happening becuase I am the founder of the board so i can bypass this limit but I am not sure about that.

If you have more questions please let me know.

Posted by bantu (3.0 Release Manager) on Jul 5th 2009, 21:13

This is a regression bug to introducing GiB into get_formatted_filesize() :-(

Posted by cYbercOsmOnauT on Jul 8th 2009, 12:34

A customer of mine who uploads very huge attachments pointed me at this bug. He uploaded a 1.6GiB file but in the posting it says 1.6 MiB. Here is my "Quick&dirty" solution. A dev has to make it nicer for the real code. ;)

In functions_content.php search for
Code: Select all
      $filesize = $attachment['filesize'];
      $size_lang = ($filesize >= 1048576) ? $user->lang['MIB'] : (($filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']);
      $filesize = get_formatted_filesize($filesize, false);

      $comment = bbcode_nl2br(censor_text($attachment['attach_comment']));

      $block_array += array(
         'UPLOAD_ICON'      => $upload_icon,
         'FILESIZE'         => $filesize,
         'SIZE_LANG'         => $size_lang,
         'DOWNLOAD_NAME'      => basename($attachment['real_filename']),
         'COMMENT'         => $comment,
      );

and replace it with
Code: Select all
      $filesize = get_formatted_filesize($attachment['filesize']);

      $comment = bbcode_nl2br(censor_text($attachment['attach_comment']));

      $block_array += array(
         'UPLOAD_ICON'      => $upload_icon,
         'FILESIZE'         => $filesize,
         'SIZE_LANG'         => '',
         'DOWNLOAD_NAME'      => basename($attachment['real_filename']),
         'COMMENT'         => $comment,
      );

The $size_lang is not needed because the function get_formatted_filesize puts the right suffix if you don't send false as second argument. Also the template variable SIZE_LANG is not necessary.

Regards,
Tekin

Edited post #168695

Action performed by bantu (3.0 Release Manager) on Jul 10th 2009, 14:40

Changed ticket status from "Reviewed" to "Fix in progress"

Action performed by bantu (3.0 Release Manager) on Jul 10th 2009, 15:16

Linked ticket with changeset: r9748

Action performed by bantu (3.0 Release Manager) on Jul 11th 2009, 10:05

Changed ticket status from "Fix in progress" to "Fix completed in SVN"

Action performed by bantu (3.0 Release Manager) on Jul 11th 2009, 10:05

Marked ticket #50905 as duplicate of this ticket

Action performed by nickvergessen (Development Team Member) on Sep 7th 2009, 17:56

Ticket details

Duplicates of this ticket

Related SVN changesets