WordPress.org

Make WordPress Core

#35928 closed defect (bug) (fixed)

Notice in `is_dynamic_sidebar()`

Reported by: dlh Owned by: SergeyBiryukov
Milestone: 4.5 Priority: normal
Severity: normal Version:
Component: Widgets Keywords: has-patch commit
Focuses: Cc:

Description

A sidebar can be registered but not yet have an index in the sidebars_widgets option.

is_dynamic_sidebar() checks count($sidebars_widgets[$index]) for each registered sidebar, potentially, but if it reaches a sidebar that doesn't have an index in the option, it generates an "undefined index" notice.

The attached patch adds an isset() check.

Attachments (1)

35928.patch (677 bytes) - added by dlh 21 months ago.

Download all attachments as: .zip

Change History (4)

@dlh
21 months ago

#1 @swissspidy
21 months ago

  • Keywords has-patch added

#2 @westonruter
21 months ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 4.5

#3 @SergeyBiryukov
21 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 36667:

Widgets: Avoid a PHP notice in is_dynamic_sidebar() is a sidebar is registered but does not yet have an index in the sidebars_widgets option.

Props dlh.
Fixes #35928.

Note: See TracTickets for help on using tickets.