From d8fa7d84cc23e5e15d80bdb15e00655e542853e8 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Tue, 26 Jul 2022 14:40:17 +0200 Subject: [PATCH] Allow "smallint" values to store 0 in MySQL db without conversion to NULL It was an issue with ConferenceOrBoothAttendee instances --- htdocs/core/class/commonobject.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9cfe5b47de5..13e7cb333b8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8675,7 +8675,7 @@ abstract class CommonObject public function isInt($info) { if (is_array($info)) { - if (isset($info['type']) && ($info['type'] == 'int' || preg_match('/^integer/i', $info['type']))) { + if (isset($info['type']) && (preg_match('/(^int|int$)/i', $info['type']))) { return true; } else { return false; @@ -8934,6 +8934,8 @@ abstract class CommonObject return 'NULL'; } elseif (preg_match('/^(int|double|real|price)/i', $fieldsentry['type'])) { return price2num("$value"); + } else if (preg_match('/int$/i', $fieldsentry['type'])) { + return (int)$value; } elseif ($fieldsentry['type'] == 'boolean') { if ($value) { return 'true';