From ca4f9a39cee17da91494c6c92b8bc2b9faffc2a1 Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Mon, 1 Dec 2025 14:20:10 +0100 Subject: [PATCH] Use `PDO` MySQL driver-specific constants Replace deprecated `PDO::MYSQL_*` constant usage with the driver-specific `Pdo\Mysql::ATTR_*` constants introduced in PHP 8.4. This prepares the code for PHP 8.5, where accessing MySQL driver constants through the generic `PDO` class is deprecated. This change requires a compatibility shim on older PHP versions to provide `Pdo\Mysql` for runtimes that do not expose the driver-specific class yet. The shim is provided in `ipl-sql`. --- library/Icingadb/Common/Backend.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Icingadb/Common/Backend.php b/library/Icingadb/Common/Backend.php index 15cb93cc..26d52f0c 100644 --- a/library/Icingadb/Common/Backend.php +++ b/library/Icingadb/Common/Backend.php @@ -15,6 +15,7 @@ use ipl\Sql\Expression; use ipl\Sql\QueryBuilder; use ipl\Sql\Select; use PDO; +use Pdo\Mysql; /** * Singleton providing access to the Icinga DB and Redis @@ -61,7 +62,8 @@ final class Backend $config->options = [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ]; if ($config->db === 'mysql') { - $config->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET SESSION SQL_MODE='STRICT_TRANS_TABLES" + $config->options[Mysql::ATTR_INIT_COMMAND] + = "SET SESSION SQL_MODE='STRICT_TRANS_TABLES" . ",NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'"; }