Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#17361 closed defect (bug) (invalid)

get_page_by_path() returns deleted posts

Reported by: mark8barnes Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1.2
Component: General Keywords: close
Focuses: Cc:


I think the title is self-explanatory. This behaviour is counter-intuitive, as deleted posts aren't retrievable by the path. If the existing behaviour needs to remain for backwards compatibility, there should be an extra parameter added so deleted posts can be optionally excluded.

Change History (3)

#1 @nacin
10 years ago

  • Keywords close added

get_page_by_path() does no checks on post status. That means it also returns drafts, pending posts, future posts, and the like. You need to validate the post_status coming from the return value.

#2 @mark8barnes
10 years ago

Perhaps its just the name that's confusing. I expect this function to return posts that are accessible by a URI. Maybe it should have been called get_page_by_slug()

#3 @nacin
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

path is not a URI, it's just part of one. This isn't the slug, because the slug pertains only to that page, rather than the entire hierarchy. Hope that makes sense.

URI: http://example.com/about/team/

Path: /about/team/

Slug: /team/

Note: See TracTickets for help on using tickets.