You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cba475a
Browse filesBrowse the repository at this point in the historyBrowse files
## What it does
Cleans up the native parser follow-up from #381 so the merged code reads
as permanent code, not review scaffolding.
It replaces duplicated inline verifier logic with one
`tests/tools/verify-native-parser-extension.php` entry point for
`mysql-on-sqlite`. The parser-extension workflow and PHPUnit bootstrap
both call the same verifier:
```bash
php -d extension=../php-ext-wp-mysql-parser/target/debug/libwp_mysql_parser.so \
tests/tools/verify-native-parser-extension.php
```
It also collapses `WP_PDO_MySQL_On_SQLite::create_parser()` to one token
selection and one parser reset/create return, and rewrites native parser
test comments to describe behavior instead of PR review history.
## Rationale
#381 landed functional native parser support, but a few follow-up
surfaces still carried review-era wording and copied verifier blocks.
That makes future changes harder to read and easier to drift: native
parser routing, Rust AST handle storage, wrapper identity, and
materialized child behavior were being checked in multiple places.
The verifier now pins that runtime contract from one script: extension
loaded, `WP_MySQL_Lexer` resolves native, `WP_MySQL_Parser` delegates to
`WP_MySQL_Native_Parser`, the SQLite driver returns a native-backed AST,
native wrapper handle properties are absent, child identity is stable,
and materialized child mutations survive.
## Implementation
Added `wp_sqlite_verify_native_parser_extension()` with a shared
delegate check:
```php
function wp_sqlite_assert_native_parser_delegate( WP_MySQL_Parser $parser, string $context ): void {
$reflection = new ReflectionObject( $parser );
if ( ! $reflection->hasProperty( 'native' ) ) {
wp_sqlite_native_parser_verification_fail( $context );
}
$native_property = $reflection->getProperty( 'native' );
$native_property->setAccessible( true );
if ( ! ( $native_property->getValue( $parser ) instanceof WP_MySQL_Native_Parser ) ) {
wp_sqlite_native_parser_verification_fail( $context );
}
}
```
`WP_SQLITE_REQUIRE_NATIVE_PARSER_EXTENSION=1` in the PHPUnit bootstrap
now loads that verifier instead of inlining the same checks.
`create_parser()` now selects tokens once:
```php
$tokens = $lexer instanceof WP_MySQL_Native_Lexer
? $lexer->native_token_stream()
: $lexer->remaining_tokens();
return $this->reset_or_create_parser( $tokens );
```
The WordPress PHPUnit extension setup keeps its container-specific
verifier, but factors the repeated reflection checks into the same small
helper shape.
## Testing instructions
```bash
cargo fmt --check
bash -n .github/workflows/wp-tests-phpunit-native-extension-setup.sh
node --check .github/workflows/wp-tests-phpunit-run.js
php -l packages/mysql-on-sqlite/tests/tools/verify-native-parser-extension.php
php -l packages/mysql-on-sqlite/tests/bootstrap.php
php ./vendor/bin/phpcs .github/workflows/wp-tests-phpunit-native-extension-setup.sh packages/mysql-on-sqlite/tests/bootstrap.php packages/mysql-on-sqlite/tests/tools/verify-native-parser-extension.php packages/mysql-on-sqlite/src/sqlite/class-wp-pdo-mysql-on-sqlite.php packages/mysql-on-sqlite/tests/mysql/native/WP_MySQL_Native_Parser_Node_Identity_Tests.php packages/mysql-on-sqlite/tests/mysql/native/WP_MySQL_Parser_Instanceof_Tests.php
cd packages/mysql-on-sqlite
php -d extension=../php-ext-wp-mysql-parser/target/debug/libwp_mysql_parser.so tests/tools/verify-native-parser-extension.php
php ./vendor/bin/phpunit -c ./phpunit.xml.dist tests/mysql/native/WP_MySQL_Parser_Instanceof_Tests.php tests/mysql/native/WP_MySQL_Native_Parser_Node_Identity_Tests.php tests/mysql/native/WP_MySQL_Native_Parser_Node_Cycle_Tests.php
WP_SQLITE_REQUIRE_NATIVE_PARSER_EXTENSION=1 php -d extension=../php-ext-wp-mysql-parser/target/debug/libwp_mysql_parser.so ./vendor/bin/phpunit -c ./phpunit.xml.dist --filter 'WP_MySQL_(Native_Parser_Node_(Identity|Cycle)|Parser_Instanceof)_Tests'
php ./vendor/bin/phpunit -c ./phpunit.xml.dist tests/WP_SQLite_Driver_Query_Tests.php
WP_SQLITE_REQUIRE_NATIVE_PARSER_EXTENSION=1 php -d extension=../php-ext-wp-mysql-parser/target/debug/libwp_mysql_parser.so ./vendor/bin/phpunit -c ./phpunit.xml.dist tests/WP_SQLite_Driver_Query_Tests.php
```
CI is passing on `3f4153f`, including the PHP 8.0-8.5 Rust-extension
matrix and `WordPress PHPUnit Tests / Rust extension`.
0 commit comments