Description
Three related bugs exist in packages/block-library/src/navigation/index.php:
- block_core_navigation_get_inner_blocks_from_unstable_location() (added 6.5.0) calls block_core_navigation_parse_blocks_from_menu_items() which was deprecated in 6.3.0. This triggers a _deprecated_function() notice on every page render when the Navigation block uses the __unstableLocation attribute (classic menu location fallback) and WP_DEBUG is enabled.
- The deprecated function's docblock references a non-existent replacement: WP_Navigation_Fallback::parse_blocks_from_menu_items(). That method does not exist. The actual replacement is WP_Classic_To_Block_Menu_Converter::to_blocks().
- Missing null-coalescing fallback: Line 1088 accesses $menu_items_by_parent_id[0] directly without ?? array(). The equivalent call inside the already-deprecated block_core_navigation_get_classic_menu_fallback_blocks() (line 1726) correctly guards this access. If all menu items carry a non-zero parent ID, the 0 key is absent and PHP 8.x raises an undefined array key notice.
Step-by-step reproduction instructions
- Enable WP_DEBUG and WP_DEBUG_LOG in wp-config.php.
- Create a Navigation block that uses a classic menu via the __unstableLocation attribute (a theme location fallback menu).
- Load any front-end page that renders the Navigation block.
- Check the debug log.
Expected: No deprecation notices.
Actual: _deprecated_function notice for block_core_navigation_parse_blocks_from_menu_items fires on every request.
Screenshots, screen recording, code snippet
`// packages/block-library/src/navigation/index.php
// Line 1088 — calls deprecated function, missing ?? array() guard:
function block_core_navigation_get_inner_blocks_from_unstable_location( $attributes ) {
$menu_items = block_core_navigation_get_menu_items_at_location( $attributes['__unstableLocation'] );
if ( empty( $menu_items ) ) {
return new WP_Block_List( array(), $attributes );
}
$menu_items_by_parent_id = block_core_navigation_sort_menu_items_by_parent_id( $menu_items );
$parsed_blocks = block_core_navigation_parse_blocks_from_menu_items( $menu_items_by_parent_id[0], $menu_items_by_parent_id ); // ← deprecated call + missing ?? array()
return new WP_Block_List( $parsed_blocks, $attributes );
}
// Line 1591 — incorrect @deprecated docblock:
// @deprecated 6.3.0 Use WP_Navigation_Fallback::parse_blocks_from_menu_items() instead.
// WP_Navigation_Fallback has no such method. The actual replacement is:
// WP_Classic_To_Block_Menu_Converter::to_blocks()
// Line 1726 — correct guard used in the already-deprecated sibling function:
$inner_blocks = block_core_navigation_parse_blocks_from_menu_items(
$menu_items_by_parent_id[0] ?? array(), // ← correct pattern
$menu_items_by_parent_id
);`
Proposed fix:
function block_core_navigation_get_inner_blocks_from_unstable_location( $attributes ) { $menu_items = block_core_navigation_get_menu_items_at_location( $attributes['__unstableLocation'] ); if ( empty( $menu_items ) ) { return new WP_Block_List( array(), $attributes ); } $menu_items_by_parent_id = block_core_navigation_sort_menu_items_by_parent_id( $menu_items ); $parsed_blocks = WP_Classic_To_Block_Menu_Converter::to_blocks( $menu_items_by_parent_id[0] ?? array(), $menu_items_by_parent_id ); return new WP_Block_List( $parsed_blocks, $attributes ); }
Also correct the @deprecated docblock at line 1591:
`- * @deprecated 6.3.0 Use WP_Navigation_Fallback::parse_blocks_from_menu_items() instead.
-
- @deprecated 6.3.0 Use WP_Classic_To_Block_Menu_Converter::to_blocks() instead.`
Note: WP_Classic_To_Block_Menu_Converter::to_blocks() and ::group_by_parent_id() are currently private — they may need to be made public, or a new public static wrapper added.
Environment info
- WordPress version: N/A (bug is in Gutenberg source, confirmed in trunk)
- Gutenberg version: trunk (confirmed in packages/block-library/src/navigation/index.php)
- Affects any site using a Navigation block with the __unstableLocation attribute
- PHP 8.x required to surface the undefined array key notice (Issue 3)
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
Description
Three related bugs exist in packages/block-library/src/navigation/index.php:
Step-by-step reproduction instructions
Expected: No deprecation notices.
Actual: _deprecated_function notice for block_core_navigation_parse_blocks_from_menu_items fires on every request.
Screenshots, screen recording, code snippet
`// packages/block-library/src/navigation/index.php
// Line 1088 — calls deprecated function, missing ?? array() guard:
function block_core_navigation_get_inner_blocks_from_unstable_location( $attributes ) {
$menu_items = block_core_navigation_get_menu_items_at_location( $attributes['__unstableLocation'] );
if ( empty( $menu_items ) ) {
return new WP_Block_List( array(), $attributes );
}
$menu_items_by_parent_id = block_core_navigation_sort_menu_items_by_parent_id( $menu_items );
$parsed_blocks = block_core_navigation_parse_blocks_from_menu_items( $menu_items_by_parent_id[0], $menu_items_by_parent_id ); // ← deprecated call + missing ?? array()
return new WP_Block_List( $parsed_blocks, $attributes );
}
// Line 1591 — incorrect @deprecated docblock:
// @deprecated 6.3.0 Use WP_Navigation_Fallback::parse_blocks_from_menu_items() instead.
// WP_Navigation_Fallback has no such method. The actual replacement is:
// WP_Classic_To_Block_Menu_Converter::to_blocks()
// Line 1726 — correct guard used in the already-deprecated sibling function:
$inner_blocks = block_core_navigation_parse_blocks_from_menu_items(
$menu_items_by_parent_id[0] ?? array(), // ← correct pattern
$menu_items_by_parent_id
);`
Proposed fix:
function block_core_navigation_get_inner_blocks_from_unstable_location( $attributes ) { $menu_items = block_core_navigation_get_menu_items_at_location( $attributes['__unstableLocation'] ); if ( empty( $menu_items ) ) { return new WP_Block_List( array(), $attributes ); } $menu_items_by_parent_id = block_core_navigation_sort_menu_items_by_parent_id( $menu_items ); $parsed_blocks = WP_Classic_To_Block_Menu_Converter::to_blocks( $menu_items_by_parent_id[0] ?? array(), $menu_items_by_parent_id ); return new WP_Block_List( $parsed_blocks, $attributes ); }Also correct the @deprecated docblock at line 1591:
`- * @deprecated 6.3.0 Use WP_Navigation_Fallback::parse_blocks_from_menu_items() instead.
Note: WP_Classic_To_Block_Menu_Converter::to_blocks() and ::group_by_parent_id() are currently private — they may need to be made public, or a new public static wrapper added.
Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.