WordPress.org

Make WordPress Core

Opened 17 months ago

Closed 17 months ago

Last modified 16 months ago

#23508 closed defect (bug) (fixed)

Nav Menu Saving: get_nav_menu_locations() can return false, code expects array

Reported by: Viper007Bond Owned by: SergeyBiryukov
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.6
Component: Menus Keywords: has-patch 3.6-menus needs-codex
Focuses: Cc:

Description

get_nav_menu_locations() can return false (it is right now with Twenty Thirteen) but /wp-admin/nav-menu.php tries to always treat it as an array:

https://core.trac.wordpress.org/browser/trunk/wp-admin/nav-menus.php?rev=23441#L277

This throws a warning and breaks stuff.

Attachments (3)

23508.diff (447 bytes) - added by JustinSainton 17 months ago.
23508.2.diff (988 bytes) - added by SergeyBiryukov 17 months ago.
23508.3.diff (1013 bytes) - added by SergeyBiryukov 17 months ago.

Download all attachments as: .zip

Change History (14)

comment:1 SergeyBiryukov17 months ago

  • Keywords needs-patch removed
  • Milestone changed from Awaiting Review to 3.6

comment:2 SergeyBiryukov17 months ago

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

In 23453:

Fix a warning on Menus screen if $menu_locations is false.
Fix menu selection after creating a first menu on new install.

props jkudish.
fixes #23508. see #23119.

comment:3 nacin17 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I think get_nav_menu_locations() should always return an array, as the docs say. Let's try to also fix that?

comment:4 SergeyBiryukov17 months ago

  • Keywords needs-patch added

JustinSainton17 months ago

comment:5 JustinSainton17 months ago

Ensures that get_nav_menu_locations() always returns an array.

SergeyBiryukov17 months ago

comment:6 DrewAPicture17 months ago

  • Keywords has-patch 3.6-menus added; needs-patch removed
  • Version set to trunk

SergeyBiryukov17 months ago

comment:7 jkudish17 months ago

  • Cc jkudish added

comment:9 SergeyBiryukov17 months ago

Not sure if we need the ! empty() check, is_array() seems enough (23508.2.diff).

comment:10 SergeyBiryukov17 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 23550:

Ensure that get_nav_menu_locations() always returns an array. props JustinSainton for initial patch. fixes #23508.

comment:11 DrewAPicture16 months ago

  • Keywords needs-codex added
Note: See TracTickets for help on using tickets.