Skip to content

Commit b95341e

Browse files
committed
Fix grammar compression regression causing array index gaps
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.
1 parent 078e2ce commit b95341e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

grammar-tools/convert-grammar.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,17 @@ function expand( $value ) {
165165
$last = $value[ strlen( $value ) - 1 ];
166166
$name = substr( $value, 0, -1 );
167167
if ( '?' === $last ) {
168-
$expanded[] = array(
168+
$expanded[ $value ] = array(
169169
'name' => $value,
170170
'value' => array( array( $name ), array( 'ε' ) ),
171171
);
172172
} elseif ( '*' === $last ) {
173-
$expanded[] = array(
173+
$expanded[ $value ] = array(
174174
'name' => $value,
175175
'value' => array( array( $name, $value ), array( $name ), array( 'ε' ) ),
176176
);
177177
} elseif ( '+' === $last ) {
178-
$expanded[] = array(
178+
$expanded[ $value ] = array(
179179
'name' => $value,
180180
'value' => array( array( $name, $value ), array( $name ) ),
181181
);

wp-includes/mysql/mysql-grammar.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)