WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years 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:
PR Number:

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 7 years ago.
23508.2.diff (988 bytes) - added by SergeyBiryukov 7 years ago.
23508.3.diff (1013 bytes) - added by SergeyBiryukov 7 years ago.

Download all attachments as: .zip

Change History (14)

#1 @SergeyBiryukov
7 years ago

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

#2 @SergeyBiryukov
7 years 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.

#3 @nacin
7 years 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?

#4 @SergeyBiryukov
7 years ago

  • Keywords needs-patch added

@JustinSainton
7 years ago

#5 @JustinSainton
7 years ago

Ensures that get_nav_menu_locations() always returns an array.

#6 @DrewAPicture
7 years ago

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

#7 @jkudish
7 years ago

  • Cc jkudish added

#9 @SergeyBiryukov
7 years ago

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

#10 @SergeyBiryukov
7 years 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.

#11 @DrewAPicture
7 years ago

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