Skip to content

Commit 46b50a6

Browse files
committed
Bug-fix.
Changelog excerpt: - The formatFilesize method wasn't accounting for negative numbers; Fixed.
1 parent 0d6b8b5 commit 46b50a6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,8 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
196196

197197
### v3.6.3
198198

199+
#### Bugs fixed.
200+
- [2025.07.07]: The formatFilesize method wasn't accounting for negative numbers; Fixed.
201+
202+
#### Other changes.
199203
- [2025.07.05]: Aesthetic patch.

src/FrontEnd.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Front-end handler (last modified: 2025.05.08).
11+
* This file: Front-end handler (last modified: 2025.07.07).
1212
*/
1313

1414
namespace phpMussel\FrontEnd;
@@ -838,10 +838,18 @@ public function logsRecursiveList(): array
838838
* Format filesize information.
839839
*
840840
* @param int $Filesize
841+
* @param int $Markers Whether to include positive/negative markers.
842+
* 1 = Negative only. 2 = Positive only. 3 = Both.
841843
* @return void
842844
*/
843-
private function formatFilesize(int &$Filesize): void
845+
private function formatFilesize(int &$Filesize, int $Markers = 0): void
844846
{
847+
if ($Filesize < 0) {
848+
$Filesize *= -1;
849+
$Marker = $Markers === 1 || $Markers === 3 ? '-' : '';
850+
} else {
851+
$Marker = $Markers === 2 || $Markers === 3 ? '+' : '';
852+
}
845853
$Scale = ['field.size.bytes', 'field.size.KB', 'field.size.MB', 'field.size.GB', 'field.size.TB', 'field.size.PB'];
846854
$Iterate = 0;
847855
while ($Filesize > 1024) {
@@ -851,7 +859,7 @@ private function formatFilesize(int &$Filesize): void
851859
break;
852860
}
853861
}
854-
$Filesize = $this->NumberFormatter->format($Filesize, ($Iterate === 0) ? 0 : 2) . ' ' . $this->Loader->L10N->getPlural($Filesize, $Scale[$Iterate]);
862+
$Filesize = $Marker . $this->NumberFormatter->format($Filesize, ($Iterate === 0) ? 0 : 2) . ' ' . $this->Loader->L10N->getPlural($Filesize, $Scale[$Iterate]);
855863
}
856864

857865
/**

0 commit comments

Comments
 (0)