Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#54422 closed defect (bug) (fixed)

WP_REST_Templates_Controller does not respect the fields param

Reported by: spacedmonkey's profile spacedmonkey Owned by: spacedmonkey's profile spacedmonkey
Milestone: 5.9 Priority: normal
Severity: normal Version: 5.8
Component: REST API Keywords: has-patch has-unit-tests
Focuses: rest-api Cc:

Description

WP_REST_Templates_Controller does not respect the fields param. The prepare_item_for_response method was not implemented correctly.

Change History (8)

This ticket was mentioned in PR #1870 on WordPress/wordpress-develop by spacedmonkey.


3 years ago
#1

  • Keywords has-patch has-unit-tests added; needs-patch removed

This ticket was mentioned in Slack in #core-restapi by spacedmonkey. View the logs.


3 years ago

adamziel commented on PR #1870:


3 years ago
#3

I read the PR and it makes sense, although I didn't have a chance to test it yet.

TimothyBJacobs commented on PR #1870:


3 years ago
#4

Thanks for putting this together @spacedmonkey. Let's rename the test classes and test files to follow the standards while we're at it.

hellofromtonya commented on PR #1870:


3 years ago
#5

Let's rename the test classes and test files to follow the standards while we're at it.

I took care of renaming file and test classes in commit https://github.com/WordPress/wordpress-develop/pull/1870/commits/27c3bb6af7fb37906f22c7974613b194159302d3.

TimothyBJacobs commented on PR #1870:


3 years ago
#6

Thanks @hellofromtonya!

#7 @spacedmonkey
3 years ago

  • Milestone changed from Future Release to 5.9

#8 @spacedmonkey
3 years ago

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

In 52186:

REST API: Make the templates controller follow core REST patterns.

The templates controller now respects the _fields parameter and filters the response accordingly. The schema has been updated to include all the fields returned. The content.block_version field has been added. The controller now returns WP_Error objects for improved error handling.

Add new unit tests.

Props TimothyBlynJacobs, hellofromtonya, zieladam.
Fixes #54422.

Note: See TracTickets for help on using tickets.