mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-07 07:34:10 +00:00
fix(config): resolve the mysql SSL CA attribute per PHP version (#701)
PHP 8.5 deprecated PDO::MYSQL_ATTR_SSL_CA in favour of Pdo\Mysql::ATTR_SSL_CA, so on 8.5 every test in the suite was reported as deprecated rather than passed — noise that would hide a real one. Pdo\Mysql does not exist before 8.5 and this package supports ^8.4, so the constant is resolved at runtime; the untaken ternary branch is never looked up, which keeps 8.4 working. The lookup stays behind the extension_loaded() check because neither name is defined when pdo_mysql is missing. Verified against both runtimes: with MYSQL_ATTR_SSL_CA set, 8.4 resolves to attribute 1009 and 8.5 to 1008 — each version's own value, matching what the previous code produced there. Same change as InvoiceShelf/InvoiceShelf#696 on 3.x.
This commit is contained in:
+14
-4
@@ -1,6 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Pdo\Mysql;
|
||||
|
||||
// PHP 8.5 deprecated PDO::MYSQL_ATTR_SSL_CA in favour of Pdo\Mysql::ATTR_SSL_CA,
|
||||
// which does not exist before 8.5. This package supports ^8.4, so resolve
|
||||
// whichever name the running version provides — both refer to the same
|
||||
// attribute. Kept behind the extension check because neither constant is
|
||||
// defined at all when pdo_mysql is missing.
|
||||
$mysqlSslCaAttribute = extension_loaded('pdo_mysql')
|
||||
? (PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA)
|
||||
: null;
|
||||
|
||||
return [
|
||||
|
||||
@@ -58,8 +68,8 @@ return [
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
'options' => $mysqlSslCaAttribute !== null ? array_filter([
|
||||
$mysqlSslCaAttribute => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
@@ -78,8 +88,8 @@ return [
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
'options' => $mysqlSslCaAttribute !== null ? array_filter([
|
||||
$mysqlSslCaAttribute => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
|
||||
Reference in New Issue
Block a user