Make WordPress Core

Opened 18 months ago

Last modified 15 months ago

#58189 new defect (bug)

post_type parameter in update_post_caches() accepts more than a single post type

Reported by: drewapicture's profile DrewAPicture Owned by:
Milestone: Awaiting Review Priority: normal
Severity: trivial Version:
Component: Cache API Keywords: has-patch
Focuses: docs Cc:

Description

In update_post_caches(), the post_type parameter is documented as only accepting a single post type, which is inaccurate. It actually accepts a single post type, 'any' for any post type, and also an array of post types.

Attachments (1)

58189.diff (1.2 KB) - added by DrewAPicture 18 months ago.

Download all attachments as: .zip

Change History (3)

@DrewAPicture
18 months ago

#1 @spacedmonkey
18 months ago

I like this @DrewAPicture !

Something I was wonder to make this clearer. Should we change this line

function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true ) {

to

function update_post_caches( &$posts, $post_types = array( 'post' ), $update_term_cache = true, $update_meta_cache = true ) {

It gets converted to an array on line 7399 anyway.

I think it maybe would be clearer, if it was post types.

#2 @DrewAPicture
15 months ago

@spacedmonkey I feel like we should leave the parameter as-is. Yes we convert it to an array anyway with $ptypes but it strikes me that accepting multiples is the exception not the rule.

Note: See TracTickets for help on using tickets.