[wp-trac] [WordPress Trac] #37026: PHP Notice: Trying to get property of non-object in wp-admin\nav-menus.php on line 836

WordPress Trac noreply at wordpress.org
Thu May 29 03:07:27 UTC 2025


#37026: PHP Notice:  Trying to get property of non-object in wp-admin\nav-menus.php
on line 836
--------------------------+-----------------------------
 Reporter:  skylarkcob    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Menus         |     Version:  4.5.2
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+-----------------------------
Changes (by sabernhardt):

 * milestone:   => Future Release


Comment:

 Related: #63484

 At first, checking for `false` seemed to be enough because the docblock
 for `wp_get_nav_menu_object()` said it returns either `WP_Term` or
 `false`.
 `<?php if ( ! empty( $menu_locations[ $location ] ) && $menu_locations[
 $location ] !== $nav_menu_selected_id && wp_get_nav_menu_object(
 $menu_locations[ $location ] ) ) : ?>`

 However, `is_nav_menu()` also checks for an error or incorrect taxonomy,
 so I used that instead in the refreshed patch.
 `<?php if ( ! empty( $menu_locations[ $location ] ) && is_nav_menu(
 $menu_locations[ $location ] ) && $menu_locations[ $location ] !==
 $nav_menu_selected_id ) : ?>`

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/37026#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list