Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#50059 closed defect (bug) (invalid)

posts_results filter documentation of parameters incorrect.

Reported by: nwjames's profile nwjames Owned by:
Milestone: Priority: normal
Severity: minor Version: 5.4
Component: Query Keywords:
Focuses: docs Cc:

Description

Documentation in class-wp-query defines two parameters

  • @param WP_Post[] $posts Array of post objects.
  • @param WP_Query $this The WP_Query instance (passed by reference).

but code is called with a single parameter being an array of these two:

apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) )

Change History (1)

#1 @SergeyBiryukov
5 years ago

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

Hi there, welcome back to WordPress Trac! Thanks for the report.

It might be confusing, but the documentation is correct as is, apply_filters_ref_array() passes both of these parameters to the filter separately, not as a single array.

This is not specific for posts_results and is the case for any other instance of apply_filters_ref_array() in core, e.g. comments_pre_query, get_meta_sql, etc.

Note: See TracTickets for help on using tickets.