[wp-trac] [WordPress Trac] #52326: `get_post_status()` is can be incrorrect for attachments.

WordPress Trac noreply at wordpress.org
Wed Jan 20 02:07:26 UTC 2021


#52326: `get_post_status()` is can be incrorrect for attachments.
-------------------------------------------------+-------------------------
 Reporter:  peterwilsoncc                        |       Owner:
                                                 |  peterwilsoncc
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  5.7
Component:  Media                                |     Version:  2.2
 Severity:  normal                               |  Resolution:
 Keywords:  has-unit-tests has-patch needs-dev-  |     Focuses:
  note                                           |
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):

 * status:  new => assigned
 * owner:  (none) => peterwilsoncc
 * version:   => 2.2
 * milestone:  Awaiting Review => 5.7
 * keywords:  has-unit-tests has-patch => has-unit-tests has-patch needs-
     dev-note


Old description:

> `get_post_status()` can return an incorrect status for attachments in the
> following circumstances:
>
> * Attachment with `inherit` status from `future` post: returns
> `'publish'`, ought to be `'future'`
> * Attachment with status `draft` and no parent: returns `'publish'`,
> ought to be `'draft'` (can't be done in admin, only via code)
> * Attachment with `inherit` status and `post_parent` set to existent
> post: returns `false`, ought to be `'publish'`.
>
> I've attached unit tests to demonstrate.

New description:

 `get_post_status()` can return an incorrect status for attachments in the
 following circumstances:

 * Attachment with `inherit` status from `future` post: returns
 `'publish'`, ought to be `'future'`
 * Attachment with status `draft` and no parent: returns `'publish'`, ought
 to be `'draft'` (can't be done in admin, only via code)
 * Attachment with `inherit` status and `post_parent` set to nonexistent
 post: returns `false`, ought to be `'publish'`.

 I've attached unit tests to demonstrate.

--

Comment:

 Putting this on the milestone as it's going to be helpful for #5272.

 Will need a comment in the general dev note (rather than a dedicated one)
 that the `get_post_status` filter now runs for attachments too.

 `trash` changes were introduced in 4.0.0 but various other bugs have been
 around since the function was introduced in 2.2.0.

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


More information about the wp-trac mailing list