-
Notifications
You must be signed in to change notification settings - Fork 2
applied fixes in upstream: Fixing deprecation in PHP 8.5 #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,14 +163,23 @@ public function connect() { | |
| $config = $this->config; | ||
| $this->connected = false; | ||
|
|
||
| // PDO::MYSQL_ATTR_* constants are deprecated in PHP 8.5; Pdo\Mysql class is available since PHP 8.1 | ||
| if (class_exists('Pdo\Mysql')) { | ||
| $mysqlAttrUseBufferedQuery = Pdo\Mysql::ATTR_USE_BUFFERED_QUERY; | ||
| $mysqlAttrInitCommand = Pdo\Mysql::ATTR_INIT_COMMAND; | ||
| } else { | ||
| $mysqlAttrUseBufferedQuery = PDO::MYSQL_ATTR_USE_BUFFERED_QUERY; | ||
| $mysqlAttrInitCommand = PDO::MYSQL_ATTR_INIT_COMMAND; | ||
| } | ||
|
|
||
| $flags = $config['flags'] + array( | ||
| PDO::ATTR_PERSISTENT => $config['persistent'], | ||
| PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, | ||
| $mysqlAttrUseBufferedQuery => true, | ||
| PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION | ||
| ); | ||
|
|
||
| if (!empty($config['encoding'])) { | ||
| $flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $config['encoding']; | ||
| $flags[$mysqlAttrInitCommand] = 'SET NAMES ' . $config['encoding']; | ||
| } | ||
| if (!empty($config['ssl_key']) && !empty($config['ssl_cert'])) { | ||
| $flags[PDO::MYSQL_ATTR_SSL_KEY] = $config['ssl_key']; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (For the follow-up PR.) if (!empty($config['ssl_key']) && !empty($config['ssl_cert'])) {
$flags[$mysqlAttrSslKey] = $config['ssl_key'];
$flags[$mysqlAttrSslCert] = $config['ssl_cert'];
}
if (!empty($config['ssl_ca'])) {
$flags[$mysqlAttrSslCa] = $config['ssl_ca'];
}CakePHP 4.x/5.x switch these three as well. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(For the follow-up PR.)
Pdo\Mysqlwas added in PHP 8.4.0, not 8.1 (https://www.php.net/manual/en/class.pdo-mysql.php).PHP_VERSION_ID >= 80400would also be preferable toclass_exists('Pdo\Mysql'). On PHP < 8.4,class_exists()runs the autoloader chain on everyconnect(), and a userlandPdo\Mysqlclass would be misdetected. CakePHP 4.x/5.x use the same version check. A possible shape, which also defines the SSL variables used at L185-189: