Changeset 65229
- Timestamp:
- 11/03/2026 02:50:29 PM (12 days ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/post.php (modified) (1 diff)
-
tests/phpunit/tests/post/wpPostMimeTypeWhere.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r65021 r65229 3956 3956 if ( is_string( $post_mime_types ) ) { 3957 3957 $post_mime_types = array_map( 'trim', explode( ',', $post_mime_types ) ); 3958 // Skip empty items left by extra commas, so they do not match the '' wildcard. 3959 $post_mime_types = array_diff( $post_mime_types, array( '' ) ); 3958 3960 } 3959 3961 -
trunk/tests/phpunit/tests/post/wpPostMimeTypeWhere.php
r64974 r65229 66 66 ); 67 67 } 68 69 /** 70 * Tests that empty items in a comma-separated string do not remove the restriction. 71 * 72 * @ticket 66454 73 * 74 * @dataProvider data_ignores_empty_items_in_comma_separated_string 75 * 76 * @param string $post_mime_types Comma-separated MIME types. 77 * @param string $expected Expected SQL clause. 78 */ 79 public function test_ignores_empty_items_in_comma_separated_string( $post_mime_types, $expected ) { 80 $this->assertSame( $expected, wp_post_mime_type_where( $post_mime_types ) ); 81 } 82 83 /** 84 * Data provider. 85 * 86 * @return array[] 87 */ 88 public static function data_ignores_empty_items_in_comma_separated_string() { 89 return array( 90 'trailing comma' => array( 'image/jpeg,', " AND (post_mime_type = 'image/jpeg') " ), 91 'trailing comma and space' => array( 'image/jpeg, ', " AND (post_mime_type = 'image/jpeg') " ), 92 'leading comma' => array( ',image/jpeg', " AND (post_mime_type = 'image/jpeg') " ), 93 'double comma' => array( 'image/jpeg,,video', " AND (post_mime_type = 'image/jpeg' OR post_mime_type LIKE 'video/%') " ), 94 'type with trailing comma' => array( 'image,', " AND (post_mime_type LIKE 'image/%') " ), 95 ); 96 } 97 98 /** 99 * Tests that an empty string and a wildcard in a comma-separated string still match every MIME type. 100 * 101 * @ticket 66454 102 * 103 * @dataProvider data_matches_every_mime_type 104 * 105 * @param string $post_mime_types MIME types. 106 */ 107 public function test_matches_every_mime_type( $post_mime_types ) { 108 $this->assertSame( '', wp_post_mime_type_where( $post_mime_types ) ); 109 } 110 111 /** 112 * Data provider. 113 * 114 * @return array[] 115 */ 116 public static function data_matches_every_mime_type() { 117 return array( 118 'empty string' => array( '' ), 119 'only commas and spaces' => array( ' , ' ), 120 'wildcard after a type' => array( 'image/jpeg,%' ), 121 ); 122 } 68 123 }
Note:
See TracChangeset
for help on using the changeset viewer.