[wp-trac] [WordPress Trac] #39698: Notice: Undefined property

WordPress Trac noreply at wordpress.org
Thu Jan 26 06:16:48 UTC 2017


#39698: Notice: Undefined property
-------------------------------+-----------------------------
 Reporter:  mitogh             |      Owner:
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:
 Severity:  normal             |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 The following error is triggered if DEBUG mode is enabled.

 {{{
 stdClass::$delete_posts in wp-admin/includes/class-wp-posts-list-table.php
 on line 403.
 }}}

 Where this is happening is here:

 {{{#!php
 if ( current_user_can( $post_type_obj->cap->delete_posts ) ) {
 // . . .
 }}}

 Based on my next example ''delete_posts'' is null when it reaches this
 line of code.


 Specifically this happens if a new post type is created only with just
 create_posts as capabilities.

 Here are the arguments of my post type.

 {{{#!php
 <?php
  add_action( 'init', function(){
   $args = array(
       'public' => true,
       'label'  => 'Books',
         'publicly_queryable' => false,
         'exclude_from_search' => true,
         'capabilities' => [
                 'create_posts' => false,
         ],
     );
     register_post_type( 'book', $args );
 });
 }}}

 I think ''capabilities'', argument should have a default value for
 ''delete_posts'' and any other value that is expected on a post_type.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39698>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list