id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,focuses 51565,PHP Notices from wp_setup_nav_menu_item when object_id doesn't exist anymore,tristanleboss,,"Hello, The function `wp_setup_nav_menu_item` calls function `get_post_states` after trying to get the post linked to a menu item. Unfortunately, no check is done of `get_post` return value and, if the post linked to a menu item doesn't exist anymore, the variable `$menu_post` will be `null`. The susequent call to `get_post_states` (which uses $menu_post as its first argument with the null value) will give 2 PHP warnings: - Notice: Trying to get property 'post_status' of non-object - Notice: Trying to get property 'ID' of non-object Indeed, `get_post_states` don't check that its first argument is really a post object and directly tries to access its properties assuming it to be a valid object. I think both functions should be corrected: `wp_setup_nav_menu_item` should check the return value of `get_post` and `get_post_states` should also check if its first argument is indeed a valid post object. Culprit code from `wp_setup_nav_menu_item`: {{{#!php type_label = $object->labels->singular_name; // Denote post states for special pages (only in the admin). if ( function_exists( 'get_post_states' ) ) { $menu_post = get_post( $menu_item->object_id ); $post_states = get_post_states( $menu_post ); if ( $post_states ) { $menu_item->type_label = wp_strip_all_tags( implode( ', ', $post_states ) ); } } }}} ",defect (bug),new,normal,Awaiting Review,Menus,5.5.1,normal,,has-patch,,