Make WordPress Core

Opened 2 years ago

Closed 23 months ago

#56142 closed defect (bug) (duplicate)

Warnings from Customizer when choosing Site icon settings link for FSE theme(s)

Reported by: bobbingwide's profile bobbingwide Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.9
Component: Customize Keywords:
Focuses: Cc:

Description

The Site Logo block contains a Site Icon settings link to the customizer. This is to allow you to define a different site icon from the site logo.
When you click on this link, for a Full Site Editing (FSE) theme, such as Twenty Twenty Two, there are a number of Warnings generated. Some of these are obvious to the end user, the others can be seen in the HTML output or the PHP Error log.

Warning: Attempt to read property "title" on null in \wp-includes\class-wp-customize-nav-menus.php on line 523
Warning: Attempt to read property "title" on null in \wp-includes\class-wp-customize-widgets.php on line 899
Warning: Attempt to read property "title" on null in \wp-includes\class-wp-customize-nav-menus.php on line 1152

These messages are issued from code which is attempting to set a title for the panel.
eg.
`
customizingMenus' => sprintf( ( 'Customizing ▸ %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) ),
`

Since FSE themes do not call register_nav_menus() or register_sidebar() no calls to add_theme_support( 'menus' ) or add_theme_support( 'widgets' ) have been made.

The result of the $this->manager->get_panel() call(s) is null, leading to the Warning messages when attempting to access the title property.

The solution is to check the result before attempting to obtain the property. eg
`
$panel = $this->manager->get_panel( 'menus' );
$section_title = ( null !== $panel ) ? $panel->title : ( 'Menus');
/* translators: ▸ is the unicode right-pointing triangle. %s: Section title in the Customizer. */
printf(
( 'Customizing ▸ %s' ), esc_html( $section_title ) );
`

Similar code needed for the other two message.

I originally reported this issue at https://github.com/bobbingwide/bobbingwide/issues/47
It's received a number of comments from other people experiencing the problem.

The workaround to call add_theme_support() is unsatisfactory, hence this error report.

Attachments (1)

issue-56142.diff (2.9 KB) - added by bobbingwide 23 months ago.
Avoid Warnings when get_panel() returns null

Download all attachments as: .zip

Change History (2)

@bobbingwide
23 months ago

Avoid Warnings when get_panel() returns null

#1 @dlh
23 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Thanks for the report, @bobbingwide! We're tracking this issue in #54905.

Note: See TracTickets for help on using tickets.