From 08b01502a5bddfc5a375a1e3801e6a879ae00d2a Mon Sep 17 00:00:00 2001 From: Marcos Del Sol Vives Date: Fri, 16 Feb 2024 17:10:37 +0100 Subject: [PATCH] Do not cast hard drive size to integer - fixes #1037 --- core/polyfills.php | 2 +- ext/et/main.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/polyfills.php b/core/polyfills.php index 558ad15a..e078c1e7 100644 --- a/core/polyfills.php +++ b/core/polyfills.php @@ -488,7 +488,7 @@ function parse_shorthand_int(string $limit): int /** * Turn an integer into a human readable filesize, eg 1024 -> 1KB */ -function to_shorthand_int(int $int): string +function to_shorthand_int(int|float $int): string { assert($int >= 0); diff --git a/ext/et/main.php b/ext/et/main.php index 6c19af8f..1df0e863 100644 --- a/ext/et/main.php +++ b/ext/et/main.php @@ -77,6 +77,8 @@ class ET extends Extension $ver .= "+"; } + $disk_total = false_throws(disk_total_space("./")); + $disk_free = false_throws(disk_free_space("./")); $info = [ "about" => [ 'title' => $config->get_string(SetupConfig::TITLE), @@ -103,8 +105,8 @@ class ET extends Extension ], "media" => [ "memory_limit" => to_shorthand_int($config->get_int(MediaConfig::MEM_LIMIT)), - "disk_use" => to_shorthand_int((int)disk_total_space("./") - (int)disk_free_space("./")), - "disk_total" => to_shorthand_int((int)disk_total_space("./")), + "disk_use" => to_shorthand_int($disk_total - $disk_free), + "disk_total" => to_shorthand_int($disk_total), ], "thumbnails" => [ "engine" => $config->get_string(ImageConfig::THUMB_ENGINE),