[wp-trac] [WordPress Trac] #56962: current_user_can( 'read_post' ) not working.

WordPress Trac noreply at wordpress.org
Wed Nov 2 16:17:23 UTC 2022


#56962: current_user_can( 'read_post' )  not working.
-----------------------------+------------------------------
 Reporter:  jcorbin          |       Owner:  (none)
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Role/Capability  |     Version:  6.1
 Severity:  major            |  Resolution:
 Keywords:  close            |     Focuses:
-----------------------------+------------------------------
Changes (by TimothyBlynJacobs):

 * keywords:   => close
 * component:  Users => Role/Capability


Comment:

 This was due to #44591. The reason this worked previously is that Core was
 previously passing on `null` to `get_post`. But we now check if a post ID
 was provided to avoid a PHP error.

 Instead of forcing a `do_not_allow`, the post caps could fallback to the
 global post to restore this behavior. Flagging this for @SergeyBiryukov to
 provide his opinion as well. However, given that this code would have been
 generating PHP notices for years, I personally don't think we should
 introduce more magic to this function.

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


More information about the wp-trac mailing list