Skip to content

Commit 87935d3

Browse files
committed
Fix: Address WordPress PHPUnit regressions in RAND() casting and FOR UPDATE literal evaluations
1 parent 26eb6c8 commit 87935d3

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

integrations/plugin-compatibility/boot.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ function wp_sqlite_integration_plugin_compat( $query ) {
3030

3131
// 2. Global fallback for FOR UPDATE / SKIP LOCKED.
3232
// This ensures the legacy driver natively ignores these locking constraints where SQLite faults.
33+
// We use a strict end-of-query match to avoid destroying strings inside WHERE clauses.
3334
if ( stripos( $query, 'FOR UPDATE' ) !== false ) {
34-
$query = preg_replace( '/FOR\s+UPDATE.*/i', '', $query );
35+
$query = preg_replace( '/\s+FOR\s+UPDATE(?:\s+(?:SKIP\s+LOCKED|NOWAIT))?\s*(?:;+)?\s*$/i', '', $query );
3536
}
3637

3738
// 3. Action Scheduler specific compatibility fixes.

wp-includes/sqlite-ast/class-wp-pdo-mysql-on-sqlite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4371,7 +4371,7 @@ private function translate_function_call( WP_Parser_Node $node ): string {
43714371

43724372
switch ( $name ) {
43734373
case 'RAND':
4374-
return 'RANDOM()';
4374+
return '(ABS(RANDOM()) / 9223372036854775808.0)';
43754375
case 'DATE_FORMAT':
43764376
list ( $date, $mysql_format ) = $args;
43774377

0 commit comments

Comments
 (0)