-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Description
Fixes compatibility issue with PHP 8.4 where PDO driver-specific subclasses are returned instead of the base PDO class.
Problem
In PHP 8.4, the PDO extension now returns driver-specific subclasses (e.g., Pdo\Pgsql, Pdo\Mysql) instead of instances of the base PDO class. This breaks the current check on line 135 in koolreport\datasources\PdoDataSource class:
// line 135, koolreport\datasources\PdoDataSource
if (is_object($connection) && get_class($connection) === \PDO::class) {
$this->connection = $connection;
} else if (isset(PdoDataSource::$connections[$key])) {Solution
Replace strict get_class() comparison with instanceof operator to support PHP 8.4's new PDO driver-specific subclasses (Pdo\Pgsql, Pdo\Mysql, etc.).
The previous check get_class($connection) === \PDO::class fails in PHP 8.4 because connections now return driver-specific subclass names instead of the base PDO class name.
Using instanceof maintains backward compatibility with older PHP versions while properly handling the new subclass inheritance in PHP 8.4+.
Also removes redundant is_object() check since instanceof already handles non-object values correctly.
// line 135, koolreport\datasources\PdoDataSource
if ($connection instanceof \PDO) {
$this->connection = $connection;
} else if (isset(PdoDataSource::$connections[$key])) {Ref: https://www.php.net/releases/8.4/en.php#pdo_driver_specific_subclasses