Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#50059 closed defect (bug) (invalid)

posts_results filter documentation of parameters incorrect.

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

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
6 years ago

  • Focuses docs added
  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → 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.