Make WordPress Core

Ticket #38465: 38465.diff

File 38465.diff, 1.4 KB (added by websupporter, 8 years ago)

Add sanitization and unit test

  • src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

     
    867867                        'description'       => __( 'Whether to hide resources not assigned to any posts.' ),
    868868                        'type'              => 'boolean',
    869869                        'default'           => false,
     870                        'sanitize_callback' => 'rest_sanitize_request_arg',
    870871                        'validate_callback' => 'rest_validate_request_arg',
    871872                );
    872873                if ( $taxonomy->hierarchical ) {
  • tests/phpunit/tests/rest-api/rest-categories-controller.php

     
    9292                $this->assertEquals( 2, count( $data ) );
    9393                $this->assertEquals( 'Season 5', $data[0]['name'] );
    9494                $this->assertEquals( 'The Be Sharps', $data[1]['name'] );
     95
     96                // Check if empty category shows up. The empty category is the "Uncategorized" category.
     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
    97103        public function test_get_items_parent_zero_arg() {