Make WordPress Core

Ticket #42209: 42209.diff

File 42209.diff, 1.5 KB (added by birgire, 8 years ago)
  • src/wp-includes/class-wp-taxonomy.php

    diff --git src/wp-includes/class-wp-taxonomy.php src/wp-includes/class-wp-taxonomy.php
    index e749eef..a753b78 100644
    final class WP_Taxonomy { 
    332332                $args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] );
    333333                unset( $args['capabilities'] );
    334334
    335                 $args['object_type'] = array_unique( (array) $object_type );
     335                $args['object_type'] = array_values( array_unique( (array) $object_type ) );
    336336
    337337                // If not set, use the default meta box
    338338                if ( null === $args['meta_box_cb'] ) {
  • tests/phpunit/tests/taxonomy/getObjectTaxonomies.php

    diff --git tests/phpunit/tests/taxonomy/getObjectTaxonomies.php tests/phpunit/tests/taxonomy/getObjectTaxonomies.php
    index 2c0710d..b5a3ba8 100644
    class Tests_Taxonomy_GetObjectTaxonomies extends WP_UnitTestCase { 
    8181                $this->assertInternalType( 'object', $found['wptests_tax2'] );
    8282                $this->assertSame( 'wptests_tax2', $found['wptests_tax2']->name );
    8383        }
     84
     85        /**
     86         * @ticket 42209
     87         */
     88        public function test_should_ensure_sequential_array_index_of_post_types() {
     89                register_taxonomy( 'foo', array(
     90                        0 => 'post',
     91                        1 => 'page',
     92                ) );
     93                register_taxonomy( 'bar', array(
     94                        0 => 'post',
     95                        2 => 'page',
     96                ) );
     97
     98                $foo = get_taxonomy( 'foo' );
     99                $bar = get_taxonomy( 'bar' );
     100
     101                $expected = array( 'post', 'page' );
     102
     103                $this->assertSame( $expected, $foo->object_type );
     104                $this->assertSame( $expected, $bar->object_type );
     105        }
    84106}