[wp-trac] [WordPress Trac] #56399: get_page_by_title() Is Not Checking "publish" Post Status
WordPress Trac
noreply at wordpress.org
Thu Aug 18 11:35:31 UTC 2022
#56399: get_page_by_title() Is Not Checking "publish" Post Status
--------------------------------------+------------------------------
Reporter: xmic | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------------------
Comment (by xmic):
Replying to [comment:6 joyously]:
> This seems a bit edge-case since this function would not be encountered
by the user, and a plugin author could just as easily use `get_post` with
more parameters, like this function does.
> There are also other `get_page_by*` functions that behave the same as
this one.
A client's site wanted to get the page title e.g. "Employment" and
ensuring that the title was such a page called that, return the permalink.
This is used by developers still, who may not be aware that farther down
the line if a new post is to be used, then it cannot, because the older
post had the word "Employment" but was marked as "non-publish". Only later
down the line do they realise that the `get_page_by_title` function was
returning non-publish statuses as well.
> The function already returns the Post object, so the status can be
checked, if needed.
It returns a post object, but not the correct one.
> Just noting that this was previously discussed in #20350 and decided
against, specifically in comment:7:ticket:20350.
The fix provided allows an array of post_status. However I cannot
understand why a "non-publish" post will want to be returned? Surely a
knowledgeable developer will want to use the `$post_status` array to
include a search for that "non-publish" status?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56399#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list