Skip to content

Commit 09f1639

Browse files
committed
Fix PHP 8.5 deprecation about PDO driver specific constants
1 parent 778eff2 commit 09f1639

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

program/lib/Roundcube/db/mysql.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use Pdo\Mysql;
4+
35
/*
46
+-----------------------------------------------------------------------+
57
| This file is part of the Roundcube Webmail client |
@@ -97,31 +99,31 @@ protected function dsn_options($dsn)
9799
$result = parent::dsn_options($dsn);
98100

99101
if (!empty($dsn['key'])) {
100-
$result[\PDO::MYSQL_ATTR_SSL_KEY] = $dsn['key'];
102+
$result[\PHP_VERSION_ID < 80500 ? \PDO::MYSQL_ATTR_SSL_KEY : Mysql::ATTR_SSL_KEY] = $dsn['key'];
101103
}
102104

103105
if (!empty($dsn['cipher'])) {
104-
$result[\PDO::MYSQL_ATTR_SSL_CIPHER] = $dsn['cipher'];
106+
$result[\PHP_VERSION_ID < 80500 ? \PDO::MYSQL_ATTR_SSL_CIPHER : Mysql::ATTR_SSL_CIPHER] = $dsn['cipher'];
105107
}
106108

107109
if (!empty($dsn['cert'])) {
108-
$result[\PDO::MYSQL_ATTR_SSL_CERT] = $dsn['cert'];
110+
$result[\PHP_VERSION_ID < 80500 ? \PDO::MYSQL_ATTR_SSL_CERT : Mysql::ATTR_SSL_CERT] = $dsn['cert'];
109111
}
110112

111113
if (!empty($dsn['capath'])) {
112-
$result[\PDO::MYSQL_ATTR_SSL_CAPATH] = $dsn['capath'];
114+
$result[\PHP_VERSION_ID < 80500 ? \PDO::MYSQL_ATTR_SSL_CAPATH : Mysql::ATTR_SSL_CAPATH] = $dsn['capath'];
113115
}
114116

115117
if (!empty($dsn['ca'])) {
116-
$result[\PDO::MYSQL_ATTR_SSL_CA] = $dsn['ca'];
118+
$result[\PHP_VERSION_ID < 80500 ? \PDO::MYSQL_ATTR_SSL_CA : Mysql::ATTR_SSL_CA] = $dsn['ca'];
117119
}
118120

119121
if (isset($dsn['verify_server_cert'])) {
120-
$result[\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = rcube_utils::get_boolean($dsn['verify_server_cert']);
122+
$result[\PHP_VERSION_ID < 80500 ? \PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT : Mysql::ATTR_SSL_VERIFY_SERVER_CERT] = rcube_utils::get_boolean($dsn['verify_server_cert']);
121123
}
122124

123125
// Always return matching (not affected only) rows count
124-
$result[\PDO::MYSQL_ATTR_FOUND_ROWS] = true;
126+
$result[\PHP_VERSION_ID < 80500 ? \PDO::MYSQL_ATTR_FOUND_ROWS : Mysql::ATTR_FOUND_ROWS] = true;
125127

126128
// Enable AUTOCOMMIT mode (#1488902)
127129
$result[\PDO::ATTR_AUTOCOMMIT] = true;

program/lib/Roundcube/rcube_db.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ protected function conn_create($dsn)
176176

177177
// Return numbers as strings consistently for all supported PHP versions
178178
// Since PHP 8.1 native data types are used by default
179-
if (defined('PDO::ATTR_STRINGIFY_FETCHES')) {
180-
$this->dbh->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, 1);
181-
}
179+
$this->dbh->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, 1);
182180

183181
$this->conn_configure($dsn, $this->dbh);
184182
} catch (\Exception $e) {

0 commit comments

Comments
 (0)