Skip to content

Commit

Permalink
Merge pull request PrestaShop#36875 from fox-john/fix/pdo-regression-…
Browse files Browse the repository at this point in the history
…with-php-8-1-on-ps-8-2-x

Add attr_stringify_fetches to PDO init config to avoid BC Break
  • Loading branch information
jolelievre authored Sep 13, 2024
2 parents bcb8eca + 55d95b1 commit c6cf71f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion classes/db/DbPDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
);
}
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit c6cf71f

Please sign in to comment.