From a5efd981d8609402aa3a48ac96d141b8ae36d00b Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 12 Mar 2024 18:05:38 +0100 Subject: [PATCH 1/3] =?UTF-8?q?N=C2=B07343=20Catch=20ParseError=20when=20l?= =?UTF-8?q?oading=20dict=20files=20in=20setup=20(#615)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/modelfactory.class.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/setup/modelfactory.class.inc.php b/setup/modelfactory.class.inc.php index c9d92e41c..5a0c6577b 100644 --- a/setup/modelfactory.class.inc.php +++ b/setup/modelfactory.class.inc.php @@ -932,10 +932,12 @@ class ModelFactory $this->aDictKeys[$sLanguageCode][$sCode] = $oXmlEntry; } } - } - catch (Exception $e) + } catch (Exception|Error $e) // Error can occurs on eval() calls { - throw new Exception('Failed to load dictionary file "'.$sPHPFile.'", reason: '.$e->getMessage()); + throw new DictException('Failed to load dictionary file "' . $sPHPFile . '"', [ + 'exception_class' => get_class($e), + 'exception_msg' => $e->getMessage(), + ]); } } From 763112c17944f45dd89650bb22d6f3ada18d5e5e Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 12 Mar 2024 18:08:04 +0100 Subject: [PATCH 2/3] =?UTF-8?q?N=C2=B07344=20rest.php=20core/get=20:=20add?= =?UTF-8?q?=20try/catch=20around=20query=20execution=20(#622)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Thomas Casteleyn Co-authored-by: Molkobain --- application/applicationextension.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/application/applicationextension.inc.php b/application/applicationextension.inc.php index 734554833..aeed05e8b 100644 --- a/application/applicationextension.inc.php +++ b/application/applicationextension.inc.php @@ -1709,8 +1709,16 @@ class RestUtils elseif (is_string($key)) { // OQL - $oSearch = DBObjectSearch::FromOQL($key); - } + try { + $oSearch = DBObjectSearch::FromOQL($key); + } catch (Exception $e) { + throw new CoreOqlException('Query failed to execute', [ + 'query' => $key, + 'exception_class' => get_class($e), + 'exception_message' => $e->getMessage(), + ]); + } + } else { throw new Exception("Wrong format for key"); From 986c24d777d36bc3f890bd18728dd57eccc569b2 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 12 Mar 2024 18:09:29 +0100 Subject: [PATCH 3/3] =?UTF-8?q?N=C2=B07302=20Fix=20unit=20name=20in=20\Set?= =?UTF-8?q?upUtils::HumanReadableSize=20(#626)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/setuputils.class.inc.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index e45dd62c9..cc49bcdc5 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -897,9 +897,18 @@ class SetupUtils return $f; } + /** + * @param float $fBytes size in raw bytes, for example 162594750464.0 + * @return string formatted string, for example "161.62 GB" + * + * @link https://en.wiktionary.org/wiki/byte byte and not Byte + * @link https://en.wikipedia.org/wiki/Kilobyte kB and not KB (IEC 80000-13) + * @link https://en.wiktionary.org/wiki/petabyte petabyte PB + * @link https://en.wiktionary.org/wiki/exabyte exabyte EB + */ public static function HumanReadableSize($fBytes) { - $aSizes = array('bytes', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Hb'); + $aSizes = array('bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB'); $index = 0; while (($fBytes > 1000) && ($index < count($aSizes))) {