Ticket #30013: 30013.3.diff
File 30013.3.diff, 1.4 KB (added by , 9 years ago) |
---|
-
src/wp-includes/post-functions.php
835 835 function get_post_type_object( $post_type ) { 836 836 global $wp_post_types; 837 837 838 if ( empty($wp_post_types[$post_type]) )838 if ( ! is_scalar( $post_type ) || empty( $wp_post_types[ $post_type ] ) ) { 839 839 return null; 840 } 840 841 841 return $wp_post_types[ $post_type];842 return $wp_post_types[ $post_type ]; 842 843 } 843 844 844 845 /** -
tests/phpunit/tests/post/types.php
122 122 return $labels; 123 123 } 124 124 125 126 /** 127 * @ticket 30013 128 */ 129 public function test_get_post_type_object_with_non_scalar_values() { 130 $this->assertFalse( post_type_exists( 'foo' ) ); 131 132 register_post_type( 'foo' ); 133 134 $this->assertTrue( post_type_exists( 'foo' ) ); 135 136 $this->assertNotNull( get_post_type_object( 'foo' ) ); 137 $this->assertNull( get_post_type_object( array() ) ); 138 $this->assertNull( get_post_type_object( array( 'foo' ) ) ); 139 $this->assertNull( get_post_type_object( new stdClass ) ); 140 141 _unregister_post_type( 'foo' ); 142 143 $this->assertFalse( post_type_exists( 'foo' ) ); 144 } 125 145 }