Skip to content

Remove legacy SQLite driver#358

Open
JanJakes wants to merge 6 commits intotrunkfrom
remove-legacy-driver
Open

Remove legacy SQLite driver#358
JanJakes wants to merge 6 commits intotrunkfrom
remove-legacy-driver

Conversation

@JanJakes
Copy link
Copy Markdown
Member

@JanJakes JanJakes commented Apr 8, 2026

Summary

Remove the legacy, token-based MySQL-to-SQLite translator and the `WP_SQLITE_AST_DRIVER` feature flag. The AST-based driver is now the only driver.

Changes

  • Delete 6 legacy driver files (~8,700 lines) and 7 legacy test files (~5,000 lines), along with the root `phpunit.xml.dist` and `composer.json` test command.
  • Remove `WP_SQLITE_AST_DRIVER` conditionals and `WP_SQLite_Translator` branches from `class-wp-sqlite-db.php`, `admin-page.php`, `constants.php`, `wp-mysql-proxy.php`, and `phpcs.xml.dist`.
  • Remove legacy driver CI test step and unused `phpunit-config` workflow parameter.
  • Remove DB_NAME fallback in `db.php` that was kept for legacy driver compatibility.
  • Fix dead `get_error_message()` call in `install-functions.php` left over from the legacy driver API.
  • Update docs to reflect the removal (`AGENTS.md`, `README.md`, `readme.txt`).

Test plan

  • New driver tests pass (635 tests)
  • PHPCS clean
  • CI passes

@joaopedrofrech
Copy link
Copy Markdown

This is amazing! are we finally moving to the new driver as default?

@chubes4
Copy link
Copy Markdown

chubes4 commented Apr 10, 2026

+1 to this! Would solve a problem for me when using https://github.com/Automattic/studio for local dev

Thanks for your efforts!

@JanJakes JanJakes force-pushed the remove-legacy-driver branch from aff0359 to 283fb3d Compare April 10, 2026 10:26
@JanJakes JanJakes changed the base branch from trunk to query-monitor-4-support April 10, 2026 10:26
@JanJakes JanJakes force-pushed the remove-legacy-driver branch from 283fb3d to eaecbf3 Compare April 10, 2026 10:35
Base automatically changed from query-monitor-4-support to trunk April 10, 2026 12:25
@JanJakes JanJakes force-pushed the remove-legacy-driver branch from eaecbf3 to 68d63c3 Compare April 10, 2026 12:29
Remove the legacy, token-based MySQL-to-SQLite translator and its
supporting files. The new AST-based driver fully replaces it.

Removed files:
- class-wp-sqlite-translator.php
- class-wp-sqlite-lexer.php
- class-wp-sqlite-query-rewriter.php
- class-wp-sqlite-token.php
- class-wp-sqlite-pdo-user-defined-functions.php
- php-polyfills.php
Remove test files that tested the legacy translator, along with
the test bootstrap, schema helper, and root phpunit.xml.dist.
The new driver tests live in packages/mysql-on-sqlite/.

Removed files:
- tests/WP_SQLite_Translator_Tests.php
- tests/WP_SQLite_Query_Tests.php
- tests/WP_SQLite_Metadata_Tests.php
- tests/WP_SQLite_Query_RewriterTests.php
- tests/WP_SQLite_PDO_User_Defined_Functions_Tests.php
- tests/bootstrap.php
- tests/wp-sqlite-schema.php
- phpunit.xml.dist
@JanJakes JanJakes force-pushed the remove-legacy-driver branch from 39c1e6a to 2e30d92 Compare April 13, 2026 11:03
The AST-based driver is now the only driver. Remove all conditional
logic that branched between the new and legacy driver:

- db.php: Always load the new driver.
- class-wp-sqlite-db.php: Remove WP_SQLite_Translator instanceof
  checks, simplify all methods to use WP_SQLite_Driver directly.
- install-functions.php: Always use WP_SQLite_Driver.
- admin-page.php: Remove "(AST)" suffix from admin bar.
- constants.php: Remove WP_SQLITE_AST_DRIVER env var handling.
- wp-setup.sh: Remove WP_SQLITE_AST_DRIVER env vars from Docker.
- wp-mysql-proxy.php: Remove WP_SQLITE_AST_DRIVER define.
- phpcs.xml.dist: Remove legacy translator exclusion.
- Remove the "New and old driver" section from AGENTS.md
- Remove stale plugin test commands from README.md (the root-level
  "composer run test" was removed along with the legacy driver)
- Remove PHPMyAdmin attribution from readme.txt (the PHPMyAdmin/sql-parser
  code was only used by the deleted legacy lexer)
Remove the "Run PHPUnit tests for the legacy driver" step that
ran root-level phpunit.xml.dist (now deleted). Also remove the
unused phpunit-config input parameter and PHPUNIT_CONFIG env var
that were only needed to switch between driver configs.
The filter-based fallback to 'database_name_here' was added to ease early
adoption of the new AST-based driver in projects that didn't define DB_NAME.
With the legacy driver removed, simplify to a plain ternary — matching how
WPDB itself handles the constant.
@JanJakes JanJakes force-pushed the remove-legacy-driver branch from 2e30d92 to 1437789 Compare April 13, 2026 12:23
@JanJakes JanJakes marked this pull request as ready for review April 13, 2026 12:56
@JanJakes JanJakes requested a review from Copilot April 13, 2026 13:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the legacy token-based MySQL→SQLite translator (and its tests/tooling) and eliminates the WP_SQLITE_AST_DRIVER feature flag so the AST-based driver becomes the only supported implementation across the repo.

Changes:

  • Deletes legacy driver implementation + legacy PHPUnit test suite/configuration.
  • Removes WP_SQLITE_AST_DRIVER conditionals across the WordPress plugin and MySQL proxy tooling, defaulting to the AST driver.
  • Simplifies CI/workflow inputs and updates docs/setup scripts to match the single-driver world.

Reviewed changes

Copilot reviewed 25 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
wp-setup.sh Removes WP_SQLITE_AST_DRIVER env injection from local wp-env overrides.
tests/wp-sqlite-schema.php Removes legacy test schema file.
tests/WP_SQLite_Query_Tests.php Removes legacy query tests targeting the translator.
tests/WP_SQLite_Query_RewriterTests.php Removes legacy query rewriter unit tests.
tests/WP_SQLite_PDO_User_Defined_Functions_Tests.php Removes legacy UDF unit tests.
tests/WP_SQLite_Metadata_Tests.php Removes legacy information_schema/metadata tests targeting translator behavior.
tests/bootstrap.php Removes legacy PHPUnit bootstrap and polyfills used by deleted tests.
README.md Updates docs to remove legacy plugin PHPUnit test commands; keeps E2E guidance.
phpunit.xml.dist Removes root PHPUnit config (legacy suite).
phpcs.xml.dist Drops PHPCS exclude for the deleted legacy translator file.
packages/plugin-sqlite-database-integration/wp-includes/sqlite/php-polyfills.php Removes legacy PHP 8.0 polyfills (no longer needed by deleted code).
packages/plugin-sqlite-database-integration/wp-includes/sqlite/install-functions.php Uses WP_SQLite_Driver unconditionally during schema creation.
packages/plugin-sqlite-database-integration/wp-includes/sqlite/db.php Always loads the new driver loader; removes feature-flag logic and DB_NAME fallback behavior.
packages/plugin-sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-token.php Deletes legacy lexer token model.
packages/plugin-sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-query-rewriter.php Deletes legacy query rewriter.
packages/plugin-sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-pdo-user-defined-functions.php Deletes legacy UDF implementation used by the translator.
packages/plugin-sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-lexer.php Deletes legacy lexer implementation.
packages/plugin-sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-db.php Removes translator branches; assumes WP_SQLite_Driver everywhere.
packages/plugin-sqlite-database-integration/readme.txt Removes outdated licensing note for PHPMyAdmin/sql-parser code that’s no longer shipped.
packages/plugin-sqlite-database-integration/constants.php Removes env-var-based enabling of WP_SQLITE_AST_DRIVER.
packages/plugin-sqlite-database-integration/admin-page.php Removes “(AST)” suffix since AST is now the only driver.
packages/mysql-proxy/bin/wp-mysql-proxy.php Removes hard-coded WP_SQLITE_AST_DRIVER define.
composer.json Removes root test script (no root PHPUnit suite anymore).
AGENTS.md Updates contributor docs to remove legacy driver references and plugin PHPUnit test commands.
.github/workflows/phpunit-tests.yml Removes unused workflow parameter wiring for phpunit config.
.github/workflows/phpunit-tests-run.yml Removes unused phpunit-config input/env and legacy-driver CI step.
Comments suppressed due to low confidence (1)

packages/plugin-sqlite-database-integration/wp-includes/sqlite/install-functions.php:58

  • This catch block indexes into $err->errorInfo, but WP_SQLite_Driver_Exception (thrown by the new driver) extends PDOException without necessarily setting errorInfo. On such failures (e.g. parse errors), this can trigger warnings and lose the real error context. Consider falling back to $err->getMessage() (and/or $err->getCode()) when errorInfo is missing, and only indexing errorInfo when it’s an array with expected offsets.
	} catch ( PDOException $err ) {
		$err_data = $err->errorInfo; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
		$err_code = $err_data[1];
		$translator->rollback();
		$message  = sprintf(

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JanJakes
Copy link
Copy Markdown
Member Author

This is amazing! are we finally moving to the new driver as default?

@joaopedrofrech Yes, coming soon 🙂

@JanJakes JanJakes changed the title Remove legacy SQLite driver and WP_SQLITE_AST_DRIVER feature flag Remove legacy SQLite driver Apr 13, 2026
@JanJakes JanJakes requested review from ashfame April 13, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants