diff --git src/wp-includes/class-wp-taxonomy.php src/wp-includes/class-wp-taxonomy.php
index e749eef..a753b78 100644
--- src/wp-includes/class-wp-taxonomy.php
+++ src/wp-includes/class-wp-taxonomy.php
@@ -332,7 +332,7 @@ final class WP_Taxonomy {
 		$args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] );
 		unset( $args['capabilities'] );
 
-		$args['object_type'] = array_unique( (array) $object_type );
+		$args['object_type'] = array_values( array_unique( (array) $object_type ) );
 
 		// If not set, use the default meta box
 		if ( null === $args['meta_box_cb'] ) {
diff --git tests/phpunit/tests/taxonomy/getObjectTaxonomies.php tests/phpunit/tests/taxonomy/getObjectTaxonomies.php
index 2c0710d..b5a3ba8 100644
--- tests/phpunit/tests/taxonomy/getObjectTaxonomies.php
+++ tests/phpunit/tests/taxonomy/getObjectTaxonomies.php
@@ -81,4 +81,26 @@ class Tests_Taxonomy_GetObjectTaxonomies extends WP_UnitTestCase {
 		$this->assertInternalType( 'object', $found['wptests_tax2'] );
 		$this->assertSame( 'wptests_tax2', $found['wptests_tax2']->name );
 	}
+
+	/**
+	 * @ticket 42209
+	 */
+	public function test_should_ensure_sequential_array_index_of_post_types() {
+		register_taxonomy( 'foo', array(
+			0 => 'post',
+			1 => 'page',
+		) );
+		register_taxonomy( 'bar', array(
+			0 => 'post',
+			2 => 'page',
+		) );
+
+		$foo = get_taxonomy( 'foo' );
+		$bar = get_taxonomy( 'bar' );
+
+		$expected = array( 'post', 'page' );
+
+		$this->assertSame( $expected, $foo->object_type );
+		$this->assertSame( $expected, $bar->object_type );
+	}
 }
