Skip to content

Commit

Permalink
Fix grammar compression regression causing array index gaps
Browse files Browse the repository at this point in the history
The grammar expansion code caused duplicit entries for expanded rules
that are used in multiple different entries. When creating an index of the
grammar rules, this caused array index gaps, converting a list array to an
associative array with indexes included in the compressed grammar.
  • Loading branch information
JanJakes committed Feb 10, 2025
1 parent 078e2ce commit 12a1b00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions grammar-tools/convert-grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,17 @@ function expand( $value ) {
$last = $value[ strlen( $value ) - 1 ];
$name = substr( $value, 0, -1 );
if ( '?' === $last ) {
$expanded[] = array(
$expanded[ $value ] = array(
'name' => $value,
'value' => array( array( $name ), array( 'ε' ) ),
);
} elseif ( '*' === $last ) {
$expanded[] = array(
$expanded[ $value ] = array(

Check failure on line 173 in grammar-tools/convert-grammar.php

View workflow job for this annotation

GitHub Actions / Check code style

There should be exactly 1 space after the array key. Found: 2 spaces
'name' => $value,
'value' => array( array( $name, $value ), array( $name ), array( 'ε' ) ),
);
} elseif ( '+' === $last ) {
$expanded[] = array(
$expanded[ $value ] = array(
'name' => $value,
'value' => array( array( $name, $value ), array( $name ) ),
);
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/mysql/mysql-grammar.php

Large diffs are not rendered by default.

0 comments on commit 12a1b00

Please sign in to comment.