Skip to content

Commit f96946a

Browse files
committed
Fix REPLACE() string function being misidentified as write query
Use negative lookahead REPLACE(?!\s*\() instead of bare REPLACE to distinguish the MySQL REPLACE() string function from the REPLACE INTO (or bare REPLACE) DML write statement. This avoids a false positive where SELECT queries containing REPLACE() are routed through the write-query code path, causing their results to be silently swallowed. Fixes #313
1 parent a959fd3 commit f96946a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/DB_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ public function query( $args, $assoc_args ) {
538538
$assoc_args['execute'] = $this->get_sql_mode_query( $assoc_args ) . $assoc_args['execute'];
539539
}
540540

541-
$is_row_modifying_query = isset( $assoc_args['execute'] ) && preg_match( '/\b(UPDATE|DELETE|INSERT|REPLACE|LOAD DATA)\b/i', $assoc_args['execute'] );
541+
$is_row_modifying_query = isset( $assoc_args['execute'] ) && preg_match( '/\b(UPDATE|DELETE|INSERT|REPLACE(?!\s*\()|LOAD DATA)\b/i', $assoc_args['execute'] );
542542

543543
if ( $is_row_modifying_query ) {
544544
$assoc_args['execute'] .= '; SELECT ROW_COUNT();';

0 commit comments

Comments
 (0)