From 2ccd5c1158c477ea3fcc65710b698e2a6ea2d958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jake=C5=A1?= Date: Tue, 11 Aug 2026 16:31:12 +0200 Subject: [PATCH] Restore legacy database version support WordPress 5.0 through 5.4 reads server information directly through the MySQL extension. Keep the drop-in override so these releases work with the emulated server. --- .../tests/fixtures/class-wpdb-stub.php | 4 ---- .../wp-includes/sqlite/class-wp-sqlite-db.php | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/mysql-on-sqlite/tests/fixtures/class-wpdb-stub.php b/packages/mysql-on-sqlite/tests/fixtures/class-wpdb-stub.php index a030c8544..8b2b8f44e 100644 --- a/packages/mysql-on-sqlite/tests/fixtures/class-wpdb-stub.php +++ b/packages/mysql-on-sqlite/tests/fixtures/class-wpdb-stub.php @@ -4,10 +4,6 @@ class WPDB_Stub { public function add_placeholder_escape( $query ) { return $query; } - - public function db_version() { - return preg_replace( '/[^0-9.].*/', '', $this->db_server_info() ); - } } class_alias( WPDB_Stub::class, 'wpdb' ); diff --git a/packages/plugin-sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-db.php b/packages/plugin-sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-db.php index 79a2c4f2f..a50fbc77b 100644 --- a/packages/plugin-sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-db.php +++ b/packages/plugin-sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-db.php @@ -745,6 +745,21 @@ public function has_cap( $db_cap ) { return parent::has_cap( $db_cap ); } + /** + * Retrieves the emulated database server version number. + * + * This mirrors wpdb::db_version(), but must also be defined here because + * WordPress 5.4 and older fetch server information directly from the MySQL + * extension instead of delegating to wpdb::db_server_info(). + * + * @see wpdb::db_version() + * + * @return string Version number on success, or an empty string while disconnected. + */ + public function db_version() { + return preg_replace( '/[^0-9.].*/', '', $this->db_server_info() ); + } + /** * Returns the raw version string of the emulated MySQL server. *