From 9729ff9418f52699ff9a2be0b8bedc058f35edef Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 17 Dec 2023 14:18:55 +0100 Subject: [PATCH] Fix warning on parse_bytes(null) call --- program/lib/Roundcube/bootstrap.php | 2 +- tests/Framework/Bootstrap.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php index 6d3f6eae86c..162fa8f4cbb 100644 --- a/program/lib/Roundcube/bootstrap.php +++ b/program/lib/Roundcube/bootstrap.php @@ -158,7 +158,7 @@ function parse_bytes($str) $bytes = 0; - if (preg_match('/([0-9\.]+)\s*([a-z]*)/i', $str, $regs)) { + if (preg_match('/([0-9\.]+)\s*([a-z]*)/i', (string) $str, $regs)) { $bytes = floatval($regs[1]); switch (strtolower($regs[2])) { case 'g': diff --git a/tests/Framework/Bootstrap.php b/tests/Framework/Bootstrap.php index b4e17e4664b..56cd4ba5289 100644 --- a/tests/Framework/Bootstrap.php +++ b/tests/Framework/Bootstrap.php @@ -56,6 +56,8 @@ function test_parse_bytes() $result = parse_bytes($value); $this->assertEquals($expected, $result, "Invalid parse_bytes() result for $value"); } + + $this->assertSame(0.0, parse_bytes(null)); } /**