WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#9636 closed enhancement (fixed)

get_lastpost* functions only look at post_status

Reported by: mtdewvirus Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.8
Component: General Keywords: has-patch commit
Focuses: Cc:

Description

The get_lastpostdate and get_lastpostmodified functions only use post_status='publish' in the query. According to the name of the function, shouldn't they look for post_type='post'?

Possible solutions:

  • Modify current functions to only query posts, create another set of functions get_lastpage* to query pages, and a generic set that uses current logic
  • Add a parameter to the current functions to limit by posts or pages.

Attachments (3)

9636.diff (2.8 KB) - added by Denis-de-Bernardy 5 years ago.
9636.2.diff (678 bytes) - added by Denis-de-Bernardy 5 years ago.
use date() for the copyright notice
9636.3.diff (567 bytes) - added by Denis-de-Bernardy 5 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 ryan5 years ago

A post_type option that defaults to 'post' seems good.

Denis-de-Bernardy5 years ago

comment:2 Denis-de-Bernardy5 years ago

  • Keywords has-patch added; date posts pages removed

seems valid except in one case. the two functions only get used in feed-related code, to conditionally serve the feed. the exception is in the next patch.

Denis-de-Bernardy5 years ago

use date() for the copyright notice

comment:3 Denis-de-Bernardy5 years ago

  • Keywords commit added

(the second patch is debatable)

comment:4 Denis-de-Bernardy5 years ago

  • Milestone changed from Unassigned to 2.8

comment:5 Denis-de-Bernardy5 years ago

On a separate note, those queries are potentially dead slow -- leading to a seq scan of the entire table, from lack of any potential index.

Denis-de-Bernardy5 years ago

comment:6 Denis-de-Bernardy5 years ago

actually, ignore that 3rd diff. I'll open a separate ticket that optimizes the beast in its entirety.

comment:7 ryan5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [11108]) Limit get_lastpost* functions to post_type=post. Props Denis-de-Bernardy. fixes #9636

Note: See TracTickets for help on using tickets.