WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#26287 closed defect (bug) (fixed)

Bug when removing a location when still attached to a menu

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

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 6 years ago.
Screenshot of dropdown
26287.diff (1.4 KB) - added by nofearinc 6 years ago.
verify for existing menu location

Download all attachments as: .zip

Change History (7)

#1 in reply to: ↑ description @nielsvanrenselaar
6 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
6 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
6 years ago

verify for existing menu location

#3 @nofearinc
6 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
6 years ago

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

Introduced in [23441].

#5 @SergeyBiryukov
6 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.