Make WordPress Core

Opened 5 weeks ago

Closed 5 weeks ago

#64062 closed defect (bug) (reported-upstream)

Warning in render_block_core_navigation_submenu

Reported by: stephanr's profile StephanR Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Editor Keywords:
Focuses: Cc:

Description

Hello,

There is a small “warning” bug in the “render_block_core_navigation_submenu” function.
If a user does not enter a URL in a navigation link (which unfortunately happens)
A “warning” is detected if the page is a post-type archive : the url attribute does not exist.

<?php
wp-includes/blocks/navigation-submenu.php :

        if ( is_post_type_archive() ) {
                $queried_archive_link = get_post_type_archive_link( get_queried_object()->name ); 
                
                if ( $attributes['url'] === $queried_archive_link ) {
                        $is_active = true;
                }
        }

Could you please add an isset?

Best regards,

Stephan Renault

Change History (3)

#1 @westonruter
5 weeks ago

  • Component changed from Menus to Editor

I supposed it is an "undefined index" bug. Is that right?

Aside: since this is for a block, we'll need to make the fix in Gutenberg and it'll get synced to core.

#2 @StephanR
5 weeks ago

Absolutely it is an undefined index bug and it is indeed the Gutenberg navigation block

#3 @sabernhardt
5 weeks ago

  • Milestone Awaiting Review deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed

GB69951 added ! empty( $attributes['url'] ) to resolve undefined key warnings in both Navigation Link and Navigation Submenu blocks. That change should be included in WordPress 6.9.

Note: See TracTickets for help on using tickets.