Skip to content

Commit ca56f6c

Browse files
authored
Fix phpMyAdmin and Adminer crash on PHP 8.5 (#3444)
## Summary - phpMyAdmin and Adminer crashed on PHP 8.5 because they created a plain `PDO` instance and passed it to `WP_SQLite_Connection`. The SQLite plugin calls `PDO::sqliteCreateFunction()`, which is deprecated in PHP 8.5. - The plugin already checks for `PDO\SQLite` to use the new API, but the check failed because a plain `PDO` was passed. - Fixed by passing the database path to `WP_SQLite_Connection` instead of a pre-built `PDO` object. Its constructor already selects the correct `PDO` class. ## Test plan - [x] Run `npm nx dev playground-website` and open http://127.0.0.1:5400/website-server/ - [x] Change PHP to 8.5 - [x] Open phpMyAdmin — verify it loads without errors - [x] Open Adminer — verify it loads without errors Fixes #3443
1 parent e0c93a6 commit ca56f6c

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

packages/playground/personal-wp/src/components/site-manager/site-database-panel/adminer-extensions/adminer-mysql-on-sqlite-driver.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
use Throwable;
2525
use WP_SQLite_Driver;
2626
use WP_SQLite_Connection;
27-
use PDO;
28-
2927
SqlDriver::$drivers = array("server" => "MySQL / MariaDB") + SqlDriver::$drivers;
3028

3129
if (!defined('Adminer\DRIVER')) {
@@ -103,10 +101,8 @@ class Db extends SqlDb {
103101

104102
function attach($server, $username, $password) {
105103
global $wp_env;
106-
$pdo = new PDO('sqlite:' . $wp_env['db']['path']);
107-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
108104
$this->driver = new WP_SQLite_Driver(
109-
new WP_SQLite_Connection(array('pdo' => $pdo)),
105+
new WP_SQLite_Connection(array('path' => $wp_env['db']['path'])),
110106
'wordpress'
111107
);
112108
return $this;

packages/playground/tools/src/phpmyadmin/DbiMysqli.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Closure;
1616
use Exception;
1717
use Generator;
18-
use PDO;
1918
use PhpMyAdmin\FieldMetadata;
2019
use PhpMyAdmin\Query\Utilities;
2120
use Throwable;
@@ -260,10 +259,8 @@ class DbiMysqli implements DbiExtension {
260259

261260
public function connect($user, $password, array $server) {
262261
global $wp_env;
263-
$pdo = new PDO('sqlite:' . $wp_env['db']['path']);
264-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
265262
$this->driver = new WP_SQLite_Driver(
266-
new WP_SQLite_Connection(array('pdo' => $pdo)),
263+
new WP_SQLite_Connection(array('path' => $wp_env['db']['path'])),
267264
'wordpress'
268265
);
269266
return $this->driver;

packages/playground/website/src/components/site-manager/site-database-panel/adminer-extensions/adminer-mysql-on-sqlite-driver.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
use Throwable;
2525
use WP_SQLite_Driver;
2626
use WP_SQLite_Connection;
27-
use PDO;
28-
2927
SqlDriver::$drivers = array("server" => "MySQL / MariaDB") + SqlDriver::$drivers;
3028

3129
if (!defined('Adminer\DRIVER')) {
@@ -103,10 +101,8 @@ class Db extends SqlDb {
103101

104102
function attach($server, $username, $password) {
105103
global $wp_env;
106-
$pdo = new PDO('sqlite:' . $wp_env['db']['path']);
107-
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
108104
$this->driver = new WP_SQLite_Driver(
109-
new WP_SQLite_Connection(array('pdo' => $pdo)),
105+
new WP_SQLite_Connection(array('path' => $wp_env['db']['path'])),
110106
'wordpress'
111107
);
112108
return $this;

0 commit comments

Comments
 (0)