Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#26287 closed defect (bug) (fixed)

Bug when removing a location when still attached to a menu

Reported by: nielsvanrenselaar's profile nielsvanrenselaar Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 3.8 Priority: normal
Severity: minor Version: 3.6
Component: Menus Keywords: has-patch needs-testing
Focuses: Cc:

Description

When creating a menu and adding it to a location trough the checkboxes it raises an error when this menu get's removed but still is connected to the location:

Notice: Trying to get property of non-object in wp-includes/nav-menu.php on line 597 Notice: Trying to get property of non-object in wp-includes/nav-menu.php on line 597

In the menu dropdown there is also "empty" slots with comma's, see it's still somewhere in the database.

Attachments (2)

Schermafbeelding 2013-11-27 om 14.16.53.png (13.7 KB) - added by nielsvanrenselaar 11 years ago.
Screenshot of dropdown
26287.diff (1.4 KB) - added by nofearinc 11 years ago.
verify for existing menu location

Download all attachments as: .zip

Change History (7)

#1 in reply to: ↑ description @nielsvanrenselaar
11 years ago

Replying to nielsvanrenselaar:

When creating a menu and adding it to a location trough the checkboxes it raises an error when this menu get's removed but still is connected to the location:

Notice: Trying to get property of non-object in wp-includes/nav-menu.php on line 597 Notice: Trying to get property of non-object in wp-includes/nav-menu.php on line 597

In the menu dropdown there is also "empty" slots with comma's, see it's still somewhere in the database.

Sorry, I mean it occurs when you remove the location from i.e. your functions.php. Not when you remove the menu but when the menu is still connected to that location!

#2 @nielsvanrenselaar
11 years ago

  • Summary changed from Bug when removing a menu when still attached to a location to Bug when removing a location when still attached to a menu

@nofearinc
11 years ago

verify for existing menu location

#3 @nofearinc
11 years ago

  • Keywords has-patch needs-testing added

IMO this is not likely to happen way too often, but it's still possible (for example, menus being updated after a theme update). Since the menu locations are fetched as get_theme_mod( 'nav_menu_locations' ) the simple checks in the patch should not cause significant performance drawbacks.

#4 @SergeyBiryukov
11 years ago

  • Milestone changed from Awaiting Review to 3.8
  • Version changed from 3.7.1 to 3.6

Introduced in [23441].

#5 @SergeyBiryukov
11 years ago

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

In 26634:

Avoid a PHP notice on Edit Menus screen when a menu is attached to a non-existing location.

props nofearinc.
fixes #26287.

Note: See TracTickets for help on using tickets.