From 7690099adeed1717d31ecc7f3ab6d36175b9a711 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Tue, 10 Sep 2024 09:59:36 +0200 Subject: [PATCH 1/2] fix: add attr_stringify_fetches to PDO init config --- classes/db/DbPDO.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/db/DbPDO.php b/classes/db/DbPDO.php index 96eef1137272c..cae034d49e8c7 100644 --- a/classes/db/DbPDO.php +++ b/classes/db/DbPDO.php @@ -72,6 +72,8 @@ protected static function getPDO($host, $user, $password, $dbname, $timeout = 5) PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', PDO::MYSQL_ATTR_MULTI_STATEMENTS => _PS_ALLOW_MULTI_STATEMENTS_QUERIES_, + // FIX This option keeps all data as strings and stops automatic casting to integers, floats and other types + PDO::ATTR_STRINGIFY_FETCHES => true ] ); } @@ -147,7 +149,7 @@ protected function _query($sql) { try { return $this->link->query($sql); - } catch (\PDOException $exception) { + } catch (PDOException $exception) { throw new PrestaShopException($exception->getMessage(), (int) $exception->getCode(), $exception); } } From 55d95b1a72a4e5e2cd2e54c69dcaa895d2b46325 Mon Sep 17 00:00:00 2001 From: Jonathan Renard <1273438+fox-john@users.noreply.github.com> Date: Tue, 10 Sep 2024 11:02:14 +0200 Subject: [PATCH 2/2] Update classes/db/DbPDO.php Co-authored-by: Jonathan Lelievre --- classes/db/DbPDO.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/db/DbPDO.php b/classes/db/DbPDO.php index cae034d49e8c7..d51e770a491a8 100644 --- a/classes/db/DbPDO.php +++ b/classes/db/DbPDO.php @@ -73,7 +73,7 @@ protected static function getPDO($host, $user, $password, $dbname, $timeout = 5) PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', PDO::MYSQL_ATTR_MULTI_STATEMENTS => _PS_ALLOW_MULTI_STATEMENTS_QUERIES_, // FIX This option keeps all data as strings and stops automatic casting to integers, floats and other types - PDO::ATTR_STRINGIFY_FETCHES => true + PDO::ATTR_STRINGIFY_FETCHES => true, ] ); }