Make WordPress Core

Opened 9 years ago

Last modified 6 years ago

#37026 new defect (bug)

PHP Notice: Trying to get property of non-object in wp-admin\nav-menus.php on line 836

Reported by: skylarkcob's profile skylarkcob Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.5.2
Component: Menus Keywords: has-patch
Focuses: Cc:

Description

I'm using WordPress 4.5.2 and get this PHP Notice:

PHP Notice:  Trying to get property of non-object in wp-admin\nav-menus.php on line 836

When I export and import database for using on localhost (one database content for two sites), two sites using different theme and have different menu location.

My first site has menu location Mobile, when I use this database on new site with Twenty Sixteen theme, it doesn't have this location, so the notice message appeared.

The menu location on Menu Settings section looks like this:

Mobile (Currently set to: )

Plese add a conditional function to check if is a nav menu object before get its name.

wp_get_nav_menu_object( $menu_locations[ $location ] )->name

It's not an error, but I don't want to see this notice message when coding theme. Thank you.

Attachments (1)

37026.patch (1.5 KB) - added by Frozzare 9 years ago.

Download all attachments as: .zip

Change History (2)

@Frozzare
9 years ago

#1 @Frozzare
9 years ago

  • Keywords has-patch added

Added a condition checking if the menu can be used before it's used. This condition exists in other places in the core when wp_get_nav_menu_object is used.

Note: See TracTickets for help on using tickets.