WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28739 closed defect (bug) (fixed)

r28523 __call() some functions expecting params by reference

Reported by: sboisvert Owned by: wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version: 4.0
Component: Query Keywords:
Focuses: Cc:

Description

Given this code:

$wp_query->parse_tax_query($wp_query->query_vars);

you will get:
Warning: Parameter 1 to WP_Query::parse_tax_query() expected to be a reference, value given

https://github.com/voceconnect/objects-to-objects is an example of where this code is used.

changing parse_tax_query()'s declaration to public fixes this.

This was introduced in r28523

Change History (4)

#1 @SergeyBiryukov
7 years ago

  • Milestone changed from Awaiting Review to 4.0

#2 @wonderboymusic
7 years ago

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

In 28987:

WP_Query::parse_tax_query() has always been documented as protected. Plugins should never have used it. However, it did not have a protected access modifier, so its visibility was public by default. If the access modifier had been present, accessing the method in a plugin would have produced a fatal error. The access modifier was added in [28523], along with magic methods to allow it to be accessed for BC. This one method is problematic because it expects to be passed a reference. The WP_Query::__call() logic does not go out of its way to fix this signature discrepancy, and so a warning is thrown: Parameter 1 to WP_Query::parse_tax_query() expected to be a reference, value given.

Remove the protected access modifier from WP_Query::parse_tax_query().

Fixes #28739.

#3 @nacin
7 years ago

In 29658:

Query: Add comment to the parse_tax_query() method reflecting [28987].

see #28739.

#4 @nacin
7 years ago

[28987] is a great commit message, just wanted to make sure someone would find it again in the future.

Note: See TracTickets for help on using tickets.