Make WordPress Core

Changeset 38942


Ignore:
Timestamp:
10/26/2016 02:28:13 AM (8 years ago)
Author:
rachelbaker
Message:

REST API: Add missing sanitization callback for the hide_empty parameter of the Terms Controller.

Fixes a bug where the boolean parameter hide_empty was not being properly sanitized in the Terms controller.

Props websupporter.
Fixes #38465.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    r38832 r38942  
    868868            'type'              => 'boolean',
    869869            'default'           => false,
     870            'sanitize_callback' => 'rest_sanitize_request_arg',
    870871            'validate_callback' => 'rest_validate_request_arg',
    871872        );
  • trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php

    r38834 r38942  
    9393        $this->assertEquals( 'Season 5', $data[0]['name'] );
    9494        $this->assertEquals( 'The Be Sharps', $data[1]['name'] );
     95
     96        // Confirm the empty category "Uncategorized" category appears.
     97        $request->set_param( 'hide_empty', 'false' );
     98        $response = $this->server->dispatch( $request );
     99        $data = $response->get_data();
     100        $this->assertEquals( 3, count( $data ) );
    95101    }
    96102
Note: See TracChangeset for help on using the changeset viewer.