Skip to content

Commit ec70aa9

Browse files
Copilotswissspidy
andauthored
Improve split_sql_statements: rename $peek, clarify version-digit loop comments
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent b6489cb commit ec70aa9

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎src/DB_Command.php‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,19 +2674,21 @@ private function split_sql_statements( $sql ) {
26742674
}
26752675

26762676
if ( '/' === $char && '*' === $next && ! $in_single_quote && ! $in_double_quote ) {
2677-
$peek = ( $i + 2 < $length ) ? $sql[ $i + 2 ] : '';
2678-
if ( '!' === $peek ) {
2677+
$char_after_asterisk = ( $i + 2 < $length ) ? $sql[ $i + 2 ] : '';
2678+
if ( '!' === $char_after_asterisk ) {
26792679
// MySQL conditional comment (/*!...*/): execute its SQL content.
26802680
$in_conditional_comment = true;
2681-
$i += 2; // skip /*!
2682-
// Skip optional version digits (e.g. 40101 in /*!40101 SET ... */).
2681+
$i += 2; // skip past /*!; $i now points at !
2682+
// Advance past optional version digits (e.g. "40101" in /*!40101 SET ... */).
2683+
// Loop checks the NEXT character so $i ends at the last digit.
26832684
while ( $i + 1 < $length && ctype_digit( $sql[ $i + 1 ] ) ) {
26842685
++$i;
26852686
}
2686-
// Skip one space following version digits, if present.
2687+
// Skip one space following the version digits, if present.
26872688
if ( $i + 1 < $length && ' ' === $sql[ $i + 1 ] ) {
26882689
++$i;
26892690
}
2691+
// The for-loop's own ++$i then lands on the first SQL char.
26902692
} else {
26912693
$in_comment = true;
26922694
++$i;

0 commit comments

Comments
 (0)