[wp-trac] [WordPress Trac] #52094: Queries with perm readable/editable will not work for multiple post types and status queries

WordPress Trac noreply at wordpress.org
Thu Apr 8 22:31:59 UTC 2021


#52094: Queries with perm readable/editable will not work for multiple post types
and status queries
--------------------------+------------------------------
 Reporter:  leogermani    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+------------------------------

Comment (by leogermani):

 Here's a first proposed fix -> https://github.com/leogermani/wordpress-
 develop/pull/2

 This is a PR that depends on the PR that fixes #48556 and a patch should
 be properly created once #48556 is merged. (or we should turn both in one
 single patch)

 This patch also addresses the bug described in #51094 and adds a specific
 test for that.

 = What this patch does: =

 1. It fixed #51094 by checking if at least one valid post status was found
 in the query

 2. It fixes support for custom post statuses in the block of code that
 goes:


 {{{#!php
 <?php
 foreach ( get_post_stati( array(), 'objects' ) as $status =>
 $status_object ) {
         if ( in_array( $status, $q_status, true ) ) {
                 if ( $status_object->private ) {

 }}}


 3. It adds the current post Status logic inside a Loop and treat each post
 type differently, depending on the specific capabilities for each of them

 = Note =

 This patch introduces the same logic introduced by #48556 to the `status`
 query, so there's a bit of duplicate logic.

 I considered doing everything in the same block of code and simplifying
 the whole thing, but this would "fix" some current inconsistencies and,
 therefore, change some behavior I'm not sure we want to change. It could
 also end up being a bit more complicated to read. But I can give it a go
 if anyone thinks it's worth it. It's not very difficult

 The main "inconsistency" is that when we query for multiple post types, we
 do not consider the `perm` parameter. We basically assume `perm=readable`
 but there's no support for `perm=editable` for example. So we would start
 supporting it.

 Also there is how we handle "protected states that should show in the
 admin all list", that are not considered when querying for post statuses.

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


More information about the wp-trac mailing list