Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit 9b21ab3

Browse files
committed
Fix parser API, explicitly disable multi-queries in WP_SQLite_Driver::query()
1 parent c745a66 commit 9b21ab3

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

tests/WP_SQLite_Driver_Tests.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4463,4 +4463,10 @@ public function testSessionSqlModes(): void {
44634463
$result = $this->assertQuery( 'SELECT @@session.SQL_mode' );
44644464
$this->assertSame( 'ONLY_FULL_GROUP_BY', $result[0]->{'@@session.SQL_mode'} );
44654465
}
4466+
4467+
public function testMultiQueryNotSupported(): void {
4468+
$this->expectException( WP_SQLite_Driver_Exception::class );
4469+
$this->expectExceptionMessage( 'Multi-query is not supported.' );
4470+
$this->assertQuery( 'SELECT 1; SELECT 2' );
4471+
}
44664472
}

wp-includes/mysql/class-wp-mysql-parser.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ public function next_query(): bool {
3333
return false;
3434
}
3535
$this->current_ast = $this->parse();
36-
if ( ! $this->current_ast ) {
37-
return false;
38-
}
3936
return true;
4037
}
4138

wp-includes/sqlite-ast/class-wp-sqlite-driver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,14 +599,17 @@ public function query( string $query, $fetch_mode = PDO::FETCH_OBJ, ...$fetch_mo
599599

600600
try {
601601
// Parse the MySQL query.
602-
// TODO: Translate and execute all queries in the SQL input string.
603602
$parser = $this->create_parser( $query );
604603
$parser->next_query();
605604
$ast = $parser->get_query_ast();
606605
if ( null === $ast ) {
607606
throw $this->new_driver_exception( 'Failed to parse the MySQL query.' );
608607
}
609608

609+
if ( $parser->next_query() ) {
610+
throw $this->new_driver_exception( 'Multi-query is not supported.' );
611+
}
612+
610613
// Handle transaction commands.
611614

612615
/*

0 commit comments

Comments
 (0)