Skip to content

Commit a2a8b9e

Browse files
committed
Extract the MySQL-on-SQLite driver to a package
1 parent 1e24d87 commit a2a8b9e

48 files changed

Lines changed: 88 additions & 120 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/phpunit-tests-run.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,22 @@ jobs:
7272
exit 1
7373
fi
7474
75-
- name: Install Composer dependencies
75+
- name: Install Composer dependencies (root)
7676
uses: ramsey/composer-install@v3
7777
with:
7878
ignore-cache: "yes"
7979
composer-options: "--optimize-autoloader"
8080

81+
- name: Install Composer dependencies (wp-mysql-on-sqlite)
82+
uses: ramsey/composer-install@v3
83+
with:
84+
working-directory: packages/wp-mysql-on-sqlite
85+
ignore-cache: "yes"
86+
composer-options: "--optimize-autoloader"
87+
8188
- name: Run PHPUnit tests
82-
run: php ./vendor/bin/phpunit -c ./phpunit.xml.dist
89+
run: php ./vendor/bin/phpunit -c ./phpunit.xml.dist
90+
working-directory: packages/wp-mysql-on-sqlite
91+
92+
- name: Run PHPUnit tests for the legacy driver
93+
run: php ./vendor/bin/phpunit -c ./phpunit.xml.dist

grammar-tools/convert-grammar.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
* @TODO Migrate the current regex-based solution to a proper grammar parser.
1111
*/
1212

13-
require_once __DIR__ . '/../wp-includes/parser/class-wp-parser-grammar.php';
14-
require_once __DIR__ . '/../wp-includes/mysql/class-wp-mysql-lexer.php';
13+
require_once __DIR__ . '/../packages/wp-mysql-on-sqlite/src/parser/class-wp-parser-grammar.php';
14+
require_once __DIR__ . '/../packages/wp-mysql-on-sqlite/src/mysql/class-wp-mysql-lexer.php';
1515

16-
const GRAMMAR_FILE = __DIR__ . '/../wp-includes/mysql/mysql-grammar.php';
16+
const GRAMMAR_FILE = __DIR__ . '/../packages/wp-mysql-on-sqlite/src/mysql/mysql-grammar.php';
1717

1818
// Convert the original MySQLParser.g4 grammar to a JSON format.
1919
// The grammar is also flattened and expanded to an ebnf-to-json-like format.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "wordpress/wp-mysql-on-sqlite",
3+
"type": "library",
4+
"scripts": {
5+
"test": "phpunit"
6+
},
7+
"require-dev": {
8+
"phpunit/phpunit": "^8.5"
9+
}
10+
}

phpunit.xml.dist renamed to packages/wp-mysql-on-sqlite/phpunit.xml.dist

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
<testsuites>
1515
<!-- Default test suite to run all tests. -->
1616
<testsuite name="default">
17-
<directory suffix=".php">tests/</directory>
18-
<!-- Exclude test tools. -->
17+
<directory suffix="_Tests.php">tests/</directory>
1918
<exclude>tests/tools</exclude>
2019
</testsuite>
2120
</testsuites>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
define( 'WP_MYSQL_ON_SQLITE_LOADER_PATH', __FILE__ );
4+
5+
/**
6+
* Load the PDO MySQL-on-SQLite driver and its dependencies.
7+
*/
8+
require_once __DIR__ . '/php-polyfills.php';
9+
require_once __DIR__ . '/../../../version.php';
10+
require_once __DIR__ . '/parser/class-wp-parser-grammar.php';
11+
require_once __DIR__ . '/parser/class-wp-parser.php';
12+
require_once __DIR__ . '/parser/class-wp-parser-node.php';
13+
require_once __DIR__ . '/parser/class-wp-parser-token.php';
14+
require_once __DIR__ . '/mysql/class-wp-mysql-token.php';
15+
require_once __DIR__ . '/mysql/class-wp-mysql-lexer.php';
16+
require_once __DIR__ . '/mysql/class-wp-mysql-parser.php';
17+
require_once __DIR__ . '/sqlite/class-wp-sqlite-connection.php';
18+
require_once __DIR__ . '/sqlite/class-wp-sqlite-configurator.php';
19+
require_once __DIR__ . '/sqlite/class-wp-sqlite-driver.php';
20+
require_once __DIR__ . '/sqlite/class-wp-sqlite-driver-exception.php';
21+
require_once __DIR__ . '/sqlite/class-wp-sqlite-information-schema-builder.php';
22+
require_once __DIR__ . '/sqlite/class-wp-sqlite-information-schema-exception.php';
23+
require_once __DIR__ . '/sqlite/class-wp-sqlite-information-schema-reconstructor.php';
24+
require_once __DIR__ . '/sqlite/class-wp-sqlite-pdo-user-defined-functions.php';
25+
require_once __DIR__ . '/sqlite/class-wp-pdo-mysql-on-sqlite.php';
26+
require_once __DIR__ . '/sqlite/class-wp-pdo-proxy-statement.php';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

wp-includes/parser/class-wp-parser-grammar.php renamed to packages/wp-mysql-on-sqlite/src/parser/class-wp-parser-grammar.php

File renamed without changes.

0 commit comments

Comments
 (0)