[wp-trac] [WordPress Trac] #55877: wp_insert_post() should check that a post type exists before using it

WordPress Trac noreply at wordpress.org
Tue May 31 18:35:44 UTC 2022


#55877: wp_insert_post() should check that a post type exists before using it
----------------------------------------+---------------------
 Reporter:  Chouby                      |       Owner:  (none)
     Type:  defect (bug)                |      Status:  new
 Priority:  normal                      |   Milestone:  6.1
Component:  Posts, Post Types           |     Version:  5.1
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:
----------------------------------------+---------------------

Comment (by rafiahmedd):

 @mukesh27 it looks good. I just have a suggestion here, I think it good if
 we make our if condition like this {{{#!php

 {{{
 <?php
 if (  ! empty( $post_type_object )  && ! $update && 'pending' ===
 $post_status && ! current_user_can( $post_type_object->cap->publish_posts
 ) )
 }}}
 }}}


 As we are checking the **$post_type_object** first so whenever it will be
 null then it won't go to the second condition and it will save some time.

 Thanks

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


More information about the wp-trac mailing list