Skip to content

Commit 5f364e2

Browse files
committed
Fix recursive index propagation in process_blocks_data_recursive to correctly track block instance order across inner blocks
1 parent c70a7e9 commit 5f364e2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

includes/classes/RegisteredDataHandler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function search_replace_block_inner_content( $block, $replacement_strings
6565
* @param array $extra_data Array of extra data provided by source for the registered data.
6666
* @param array $post_data Array of post data.
6767
* @param int $index Index of the extra data.
68-
* @return array Array with 'blocks' (processed blocks) and 'modified' (bool).
68+
* @return array Array with 'blocks' (processed blocks), 'modified' (bool), and 'index' (int).
6969
*/
7070
public function process_blocks_data_recursive( $blocks, $registered_data, $extra_data, $post_data, $index = 0 ) {
7171
$callback_fn = $registered_data['post_distribute_cb'] ?? null;
@@ -79,6 +79,7 @@ public function process_blocks_data_recursive( $blocks, $registered_data, $extra
7979
return array(
8080
'blocks' => $blocks,
8181
'modified' => $modified,
82+
'index' => $index,
8283
);
8384
}
8485

@@ -155,12 +156,14 @@ public function process_blocks_data_recursive( $blocks, $registered_data, $extra
155156
$block['innerBlocks'] = $inner_result['blocks'];
156157
$modified = true;
157158
}
159+
$index = $inner_result['index'];
158160
}
159161
}
160162

161163
return array(
162164
'blocks' => $blocks,
163165
'modified' => $modified,
166+
'index' => $index,
164167
);
165168
}
166169

0 commit comments

Comments
 (0)