From 1dd07a56fd41a473942c419366d975fcf5b6ff26 Mon Sep 17 00:00:00 2001 From: David Stone Date: Tue, 10 Feb 2026 17:53:47 -0700 Subject: [PATCH] Fix PHP 8.5 deprecation of PDO::sqliteCreateFunction() PHP 8.5 deprecated PDO::sqliteCreateFunction() in favor of Pdo\Sqlite::createFunction(). Use the new method on PHP 8.0+ where it is available, falling back to the old method for older versions. Co-Authored-By: Claude Opus 4.6 --- src/db.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/db.php b/src/db.php index 1935d47..e813b17 100644 --- a/src/db.php +++ b/src/db.php @@ -152,7 +152,11 @@ public function __construct($pdo) wp_die('Database is not initialized.', 'Database Error'); } foreach ($this->functions as $f => $t) { - $pdo->sqliteCreateFunction($f, [$this, $t]); + if (PHP_VERSION_ID >= 80400) { + $pdo->createFunction($f, [$this, $t]); + } else { + $pdo->sqliteCreateFunction($f, [$this, $t]); + } } } @@ -1163,7 +1167,11 @@ function __construct() $status = 0; do { try { - $this->pdo = new PDO($dsn, null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); + if (PHP_VERSION_ID >= 80400) { + $this->pdo = new \Pdo\Sqlite($dsn, null, null, [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]); + } else { + $this->pdo = new PDO($dsn, null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); + } new PDOSQLiteUDFS($this->pdo); $GLOBALS['@pdo'] = $this->pdo; } catch (PDOException $ex) {