Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#34446 closed defect (bug) (fixed)

WordPress Notice after add support for post type archives in menu

Reported by: sebastianpisula's profile sebastian.pisula Owned by: johnbillion's profile johnbillion
Milestone: 4.4.1 Priority: normal
Severity: normal Version: 4.4
Component: Menus Keywords: fixed-major
Focuses: Cc:

Description

I have notice:

Notice: Undefined property: stdClass::$post_parent in wp-includes\class-wp-walker.php on line 218

I have error in CPT meta box in second tab ("See all"). I use WordPress 4.4-beta1-35395

Attachments (2)

34446.diff (510 bytes) - added by johnbillion 8 years ago.
34446.patch (667 bytes) - added by sebastian.pisula 8 years ago.

Download all attachments as: .zip

Change History (10)

#1 @swissspidy
8 years ago

Hey there

Would you mind sharing the code you're using?

Not sure if you're using a custom post type or extending the built-in menu post type. Changing behaviour of built-in post types can lead to unexpected results and is not really supported.

#2 @sebastian.pisula
8 years ago

register_post_type( 'news', array(
            'label'               => 'News',
            'labels'              => array(
                'name'               => 'News',
                'singular_name'      => 'News',
                'menu_name'          => 'News',
                'name_admin_bar'     => 'News',
                'parent_item_colon'  => 'Parent news:',
                'all_items'          => 'All news',
                'add_new_item'       => 'Add new item',
                'add_new'            => 'Add new',
                'new_item'           => 'New Item',
                'edit_item'          => 'Edit item',
                'update_item'        => 'Update item',
                'view_item'          => 'View item',
                'search_items'       => 'Search items',
                'not_found'          => 'Not Found',
                'not_found_in_trash' => 'Not found in trash',
            ),
            'supports'            => array(
                'title',
                'editor',
                'excerpt',
                'author',
                'thumbnail',
                'comments',
                'trackbacks',
                'revisions',
                'custom-fields',
                'post-formats',
            ),
            'hierarchical'        => true,
            'public'              => true,
            'show_ui'             => true,
            'show_in_menu'        => true,
            'menu_position'       => 5,
            'menu_icon'           => 'dashicons-update',
            'show_in_admin_bar'   => true,
            'show_in_nav_menus'   => true,
            'can_export'          => true,
            'has_archive'         => 'news',
            'exclude_from_search' => false,
            'publicly_queryable'  => true,
            'rewrite'             => array(
                'slug'       => 'news',
                'with_front' => true,
                'pages'      => true,
                'feeds'      => true,
            ),
            'capability_type'     => 'page',
        ) );

#3 @johnbillion
8 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.4.1
  • Version set to 4.4

I'm seeing this too. Minimum code to reproduce:

register_post_type( 'foo', [
	'hierarchical' => true,
	'public'       => true,
	'has_archive'  => true,
] );

#4 @johnbillion
8 years ago

The notice is caused by this line which sets the nav menu item's parent property name to post_parent, but this property doesn't exist for the pseudo element which is being used for the post type archive link introduced in [35500].

@johnbillion
8 years ago

#5 @johnbillion
8 years ago

  • Keywords has-patch added; needs-patch removed

#6 @johnbillion
8 years ago

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

In 35876:

Avoid a PHP notice when trying to access the post_parent property of hierarchical post type nav menu items.

FIxes #34446

#7 @johnbillion
8 years ago

  • Keywords fixed-major added; has-patch removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

#8 @johnbillion
8 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 36044:

Avoid a PHP notice when trying to access the post_parent property of hierarchical post type nav menu items.

Merges [35876] to the 4.4 branch.

Fixes #34446

Note: See TracTickets for help on using tickets.