Make WordPress Core

Changeset 50047


Ignore:
Timestamp:
01/28/2021 12:52:01 AM (6 years ago)
Author:
whyisjake
Message:

REST API: Only include the controller's own taxonomy in it's schema.

Previously, all taxonomies were incorrectly exposed as possible values.

This commit brings the changes from [49922] to the 5.6 branch.

Props johnbillion, TimothyBlynJacobs.

Fixes #51940.

Location:
branches/5.6
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

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

    r49610 r50047  
    966966                                        'description' => __( 'Type attribution for the term.' ),
    967967                                        'type'        => 'string',
    968                                         'enum'        => array_keys( get_taxonomies() ),
     968                                        'enum'        => array( $this->taxonomy ),
    969969                                        'context'     => array( 'view', 'embed', 'edit' ),
    970970                                        'readonly'    => true,
  • branches/5.6/tests/phpunit/tests/rest-api/rest-categories-controller.php

    r49603 r50047  
    11411141                $this->assertArrayHasKey( 'slug', $properties );
    11421142                $this->assertArrayHasKey( 'taxonomy', $properties );
    1143                 $this->assertSame( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] );
     1143                $this->assertSame( array( 'category' ), $properties['taxonomy']['enum'] );
    11441144        }
    11451145
  • branches/5.6/tests/phpunit/tests/rest-api/rest-tags-controller.php

    r49603 r50047  
    12341234                $this->assertArrayHasKey( 'slug', $properties );
    12351235                $this->assertArrayHasKey( 'taxonomy', $properties );
    1236                 $this->assertSame( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] );
     1236                $this->assertSame( array( 'post_tag' ), $properties['taxonomy']['enum'] );
    12371237        }
    12381238
Note: See TracChangeset for help on using the changeset viewer.