Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#39300 closed defect (bug) (fixed)

REST API Terms Controller Dynamic Filter Bug

Reported by: shazahm1hotmailcom's profile shazahm1@… Owned by: jnylen0's profile jnylen0
Milestone: 4.7.1 Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: has-patch commit fixed-major
Focuses: Cc:

Description

The rest_{$this->taxonomy}_collection_params is incorrect. It is wrapped in single quotes instead of double quotes so the variable can not be parsed.

Line 977
return apply_filters( 'rest_{$this->taxonomy}_collection_params', $query_params, $taxonomy );

Attachments (3)

39300.diff (865 bytes) - added by JPry 8 years ago.
39300.2.diff (921 bytes) - added by JPry 8 years ago.
Update the docblock
39300.3.diff (9.5 KB) - added by jnylen0 8 years ago.
Also update the docblocks for the other 3 similar filters

Download all attachments as: .zip

Change History (12)

@JPry
8 years ago

#1 @JPry
8 years ago

  • Focuses rest-api added
  • Keywords has-patch added

@JPry
8 years ago

Update the docblock

#2 @ocean90
8 years ago

  • Focuses rest-api removed
  • Milestone changed from Awaiting Review to 4.7.1

Nice catch! Introduced in [39223].

#3 @jnylen0
8 years ago

  • Owner set to jnylen0
  • Status changed from new to accepted

Thanks for the report and fix, and sorry for the bug :)

Let's just change the quotes here, not the inline documentation. If we make changes to this docblock, then we need to make the same changes to the other three (posts and users and comments). The _obj suffix is also useful to indicate that the filter callback gets the full post type or taxonomy object, not just the name string.

#4 follow-up: @dd32
8 years ago

  • Keywords commit added

39300.2.diff looks good to me, The documentation should be updated to both reflect the doc standard and also correct variable naming. The description adequately describes the content of the variable, no need to append _obj to it.

@jnylen0
8 years ago

Also update the docblocks for the other 3 similar filters

#5 in reply to: ↑ 4 @jnylen0
8 years ago

  • Keywords commit removed

Replying to dd32:

The documentation should be updated to both reflect the doc standard and also correct variable naming. The description adequately describes the content of the variable, no need to append _obj to it.

This is fine, but updating only the terms docblock leaves the code in an inconsistent state with the other 3 filters that do the same thing for other object types. Updated the rest also in 39300.3.diff.

#6 @pento
8 years ago

  • Keywords commit added

New patch is cool. We cool.

#7 @jnylen0
8 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 39621:

REST API: Improve the rest_*_collection_params filter docs and fix the terms filter.

The rest_{$taxonomy}_collection_params filter in 4.7 is incorrectly using
single quotes instead of double quotes, which means it is not working correctly
as a dynamic filter. This fixes the quotes around the filter name, and also
updates the docblocks for the other 3 similar filters for better conformance to
the documentation standards.

Props shazahm1hotmailcom, JPry, jnylen0.
Fixes #39300.

#8 @jnylen0
8 years ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Needs to be ported to the 4.7 branch.

#9 @pento
8 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 39631:

REST API: Improve the rest_*_collection_params filter docs and fix the terms filter.

The rest_{$taxonomy}_collection_params filter in 4.7 is incorrectly using single quotes instead of double quotes, which means it is not working correctly as a dynamic filter. This fixes the quotes around the filter name, and also updates the docblocks for the other 3 similar filters for better conformance to the documentation standards.

Merge of [39621] to the 4.7 branch.

Props shazahm1hotmailcom, JPry, jnylen0.
Fixes #39300.

Note: See TracTickets for help on using tickets.