Browse Source
Fix computerFileSize when called with a string without unit
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/36120/head
Côme Chilliet
4 years ago
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
2 changed files with
4 additions and
3 deletions
-
core/Command/Log/File.php
-
lib/private/legacy/OC_Helper.php
|
|
|
@ -115,14 +115,12 @@ class File extends Command implements Completion\CompletionAwareInterface { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param mixed $rotateSize |
|
|
|
* @throws \InvalidArgumentException |
|
|
|
*/ |
|
|
|
protected function validateRotateSize(&$rotateSize) { |
|
|
|
protected function validateRotateSize(false|int|float $rotateSize): void { |
|
|
|
if ($rotateSize === false) { |
|
|
|
throw new \InvalidArgumentException('Error parsing log rotation file size'); |
|
|
|
} |
|
|
|
$rotateSize = (int) $rotateSize; |
|
|
|
if ($rotateSize < 0) { |
|
|
|
throw new \InvalidArgumentException('Log rotation file size must be non-negative'); |
|
|
|
} |
|
|
|
|
|
|
|
@ -104,6 +104,9 @@ class OC_Helper { |
|
|
|
*/ |
|
|
|
public static function computerFileSize(string $str): false|int|float { |
|
|
|
$str = strtolower($str); |
|
|
|
if (is_numeric($str)) { |
|
|
|
return Util::numericToNumber($str); |
|
|
|
} |
|
|
|
|
|
|
|
$bytes_array = [ |
|
|
|
'b' => 1, |
|
|
|
|