#62596 closed enhancement (fixed)
REST API: Add support for search_columns to the user endpoint.
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | REST API | Keywords: | has-patch gutenberg-merge |
Focuses: | Cc: |
Description
This ticket tracks the backport of the changes introduced in https://github.com/WordPress/gutenberg/pull/67330
The idea is to add "search_columns" support to the REST API user controller in order to fix a Gutenberg bug in the post author selector.
A similar change has been introduced before for the posts controller in https://core.trac.wordpress.org/ticket/43867
Change History (10)
This ticket was mentioned in PR #7909 on WordPress/wordpress-develop by @youknowriad.
4 months ago
#2
- Keywords has-patch added
@Mamaduka commented on PR #7909:
7 weeks ago
#3
@youknowriad, here's the patch.
diff --git tests/phpunit/tests/rest-api/rest-users-controller.php tests/phpunit/tests/rest-api/rest-users-controller.php index 009200f401..fcaf7cdf5f 100644 --- tests/phpunit/tests/rest-api/rest-users-controller.php +++ tests/phpunit/tests/rest-api/rest-users-controller.php @@ -713,6 +713,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $this->assertCount( 0, $response->get_data() ); } + /** + * @ticket 62596 + */ public function test_get_items_search_columns() { $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'search', 'yololololo' ); @@ -746,6 +749,27 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $this->assertCount( 1, $response->get_data() ); } + /** + * @ticket 62596 + */ + public function test_get_items_seach_columns_without_permission() { + self::factory()->user->create( + array( + 'display_name' => 'Adam', + 'user_email' => 'yololololo@example.localhost', + ) + ); + + // Test user without sufficient capabilities - 'list_users'. + wp_set_current_user( self::$editor ); + + $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); + $request->set_param( 'search', 'yololololo' ); + $request->set_param( 'search_columns', 'email' ); + $response = rest_get_server()->dispatch( $request ); + $this->assertCount( 0, $response->get_data() ); + } + public function test_get_items_slug_query() { wp_set_current_user( self::$user );
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
4 weeks ago
#6
@
4 weeks ago
- Keywords changed from has-patch, gutenberg-merge to has-patch gutenberg-merge
- Owner set to joemcgill
- Status changed from new to accepted
Planning to update the PHPUnit test on the PR and commit this.
@joemcgill commented on PR #7909:
4 weeks ago
#7
I've pushed a commit to this PR that applies the PHPUnit test added by @Mamaduka (thanks!) and will commit this once confirming that all checks are passing.
@joemcgill commented on PR #7909:
4 weeks ago
#8
Performance tests failing are fine. This is due to an unrelated change to those CI workflows that are failing due to this PR being more than 3 months old.
#9
@
4 weeks ago
- Resolution set to fixed
- Status changed from accepted to closed
I missed the leading # before the ticket number in the commit message. This was fixed by [59892].
Backports to change originally made in https://github.com/WordPress/gutenberg/pull/67330
This adds support to search_columns to the user controller, mirroring a change that was done in the past for the post controller.
Trac ticket: https://core.trac.wordpress.org/ticket/62596
Todo