Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#41038 closed defect (bug) (invalid)

Possible ambiguity with parameters for posts_request filter

Reported by: dunar21's profile dunar21 Owned by:
Milestone: Priority: normal
Severity: trivial Version: 4.8
Component: Query Keywords:
Focuses: administration Cc:


I received the below listed error in my server logs relative to Relevanssi's plugin.

The Relevanssi dev provided these links indicating that he though there are indeed two parameters:

Maybe there is something I am missing, but in the source code, only one parameter (an array) is being sent with the hook, while the hook notes indicate two parameters.

Also, in the code reference, the syntax indicates two parameters, but the description of parameters indicates only one (either a string or an instance of WP_Query.

There seems to be discrepancy here. The source code is clearly passing an array as a parameter, the only parameter, unless the hook parsing algorithm separates array parameters into individual one.

It could definitely be that I am missing something here, but just in case I am not, I will notify you guys of the issue.

15:39:27 [error] 121306#0: *78296689 FastCGI sent in stderr: “PHP
message: PHP Fatal error: Uncaught ArgumentCountError: Too few
arguments to function relevanssi_prevent_default_request(), 1 passed in
…/public/wp-includes/class-wp-hook.php on line
298 and exactly 2 expected in
Stack trace:
#0 …/public/wp-includes/class-wp-hook.php(298): relevanssi_prevent_default_request(‘SELECT wp_posts…’)
#1 …/public/wp-includes/plugin.php(203): WP_Hook->apply_filters(‘SELECT wp_posts…’, Array)

Change History (3)

#1 @dunar21
7 years ago

  • Resolution set to invalid
  • Severity changed from normal to trivial
  • Status changed from new to closed

apply_filters_ref_array, sorry

#2 @dd32
7 years ago

  • Milestone Awaiting Review deleted

This is caused by a change in PHP 7.1, where passing too few args to a user defined function now results in a fatal error:

Although relevanssi asks for two parameters by default, I'm assuming some other code has unhooked/rehooked it incorrectly:

#3 @dunar21
7 years ago

Yes, thanks. It was another plugin that was attempting to also apply_filters for posts_request, but was only passing in the query and no instance of the WP_Query object because it was using $wpdb. Thanks for the reply and sorry to submit this prematurely, before investigating further.

Note: See TracTickets for help on using tickets.