Skip to content

Commit d194248

Browse files
committed
Refactor WP REST Attachments Controller to remove MIME type enumeration from schema definition. Updated related tests and fixtures to reflect this change.
1 parent 78f33cb commit d194248

File tree

3 files changed

+2
-104
lines changed

3 files changed

+2
-104
lines changed

src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,8 +1342,7 @@ public function get_collection_params() {
13421342
'description' => __( 'Limit result set to attachments of a particular MIME type or MIME types.' ),
13431343
'type' => 'array',
13441344
'items' => array(
1345-
'type' => 'string',
1346-
'enum' => get_allowed_mime_types(),
1345+
'type' => 'string'
13471346
),
13481347
);
13491348

tests/phpunit/tests/rest-api/rest-attachments-controller.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,6 @@ public function test_get_items_multiple_mime_types_and_combination() {
582582

583583
$this->assertContains( $jpeg_id, $ids, 'JPEG ID not found in response for multiple MIME types with array format' );
584584
$this->assertContains( $mp4_id, $ids, 'MP4 ID not found in response for multiple MIME types with array format' );
585-
586-
// Test invalid mime type mixed with valid ones.
587-
$request->set_param( 'mime_type', array( 'video/mp4', 'cat/gif' ) );
588-
$response = rest_get_server()->dispatch( $request );
589-
$this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
590585
}
591586

592587
/**

tests/qunit/fixtures/wp-api-generated.js

Lines changed: 1 addition & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,103 +2982,7 @@ mockedApiResponse.Schema = {
29822982
"description": "Limit result set to attachments of a particular MIME type or MIME types.",
29832983
"type": "array",
29842984
"items": {
2985-
"type": "string",
2986-
"enum": {
2987-
"jpg|jpeg|jpe": "image/jpeg",
2988-
"gif": "image/gif",
2989-
"png": "image/png",
2990-
"bmp": "image/bmp",
2991-
"tiff|tif": "image/tiff",
2992-
"webp": "image/webp",
2993-
"avif": "image/avif",
2994-
"ico": "image/x-icon",
2995-
"heic": "image/heic",
2996-
"heif": "image/heif",
2997-
"heics": "image/heic-sequence",
2998-
"heifs": "image/heif-sequence",
2999-
"asf|asx": "video/x-ms-asf",
3000-
"wmv": "video/x-ms-wmv",
3001-
"wmx": "video/x-ms-wmx",
3002-
"wm": "video/x-ms-wm",
3003-
"avi": "video/avi",
3004-
"divx": "video/divx",
3005-
"flv": "video/x-flv",
3006-
"mov|qt": "video/quicktime",
3007-
"mpeg|mpg|mpe": "video/mpeg",
3008-
"mp4|m4v": "video/mp4",
3009-
"ogv": "video/ogg",
3010-
"webm": "video/webm",
3011-
"mkv": "video/x-matroska",
3012-
"3gp|3gpp": "video/3gpp",
3013-
"3g2|3gp2": "video/3gpp2",
3014-
"txt|asc|c|cc|h|srt": "text/plain",
3015-
"csv": "text/csv",
3016-
"tsv": "text/tab-separated-values",
3017-
"ics": "text/calendar",
3018-
"rtx": "text/richtext",
3019-
"css": "text/css",
3020-
"vtt": "text/vtt",
3021-
"dfxp": "application/ttaf+xml",
3022-
"mp3|m4a|m4b": "audio/mpeg",
3023-
"aac": "audio/aac",
3024-
"ra|ram": "audio/x-realaudio",
3025-
"wav|x-wav": "audio/wav",
3026-
"ogg|oga": "audio/ogg",
3027-
"flac": "audio/flac",
3028-
"mid|midi": "audio/midi",
3029-
"wma": "audio/x-ms-wma",
3030-
"wax": "audio/x-ms-wax",
3031-
"mka": "audio/x-matroska",
3032-
"rtf": "application/rtf",
3033-
"pdf": "application/pdf",
3034-
"class": "application/java",
3035-
"tar": "application/x-tar",
3036-
"zip": "application/zip",
3037-
"gz|gzip": "application/x-gzip",
3038-
"rar": "application/rar",
3039-
"7z": "application/x-7z-compressed",
3040-
"psd": "application/octet-stream",
3041-
"xcf": "application/octet-stream",
3042-
"doc": "application/msword",
3043-
"pot|pps|ppt": "application/vnd.ms-powerpoint",
3044-
"wri": "application/vnd.ms-write",
3045-
"xla|xls|xlt|xlw": "application/vnd.ms-excel",
3046-
"mdb": "application/vnd.ms-access",
3047-
"mpp": "application/vnd.ms-project",
3048-
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
3049-
"docm": "application/vnd.ms-word.document.macroEnabled.12",
3050-
"dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
3051-
"dotm": "application/vnd.ms-word.template.macroEnabled.12",
3052-
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
3053-
"xlsm": "application/vnd.ms-excel.sheet.macroEnabled.12",
3054-
"xlsb": "application/vnd.ms-excel.sheet.binary.macroEnabled.12",
3055-
"xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
3056-
"xltm": "application/vnd.ms-excel.template.macroEnabled.12",
3057-
"xlam": "application/vnd.ms-excel.addin.macroEnabled.12",
3058-
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
3059-
"pptm": "application/vnd.ms-powerpoint.presentation.macroEnabled.12",
3060-
"ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
3061-
"ppsm": "application/vnd.ms-powerpoint.slideshow.macroEnabled.12",
3062-
"potx": "application/vnd.openxmlformats-officedocument.presentationml.template",
3063-
"potm": "application/vnd.ms-powerpoint.template.macroEnabled.12",
3064-
"ppam": "application/vnd.ms-powerpoint.addin.macroEnabled.12",
3065-
"sldx": "application/vnd.openxmlformats-officedocument.presentationml.slide",
3066-
"sldm": "application/vnd.ms-powerpoint.slide.macroEnabled.12",
3067-
"onetoc|onetoc2|onetmp|onepkg": "application/onenote",
3068-
"oxps": "application/oxps",
3069-
"xps": "application/vnd.ms-xpsdocument",
3070-
"odt": "application/vnd.oasis.opendocument.text",
3071-
"odp": "application/vnd.oasis.opendocument.presentation",
3072-
"ods": "application/vnd.oasis.opendocument.spreadsheet",
3073-
"odg": "application/vnd.oasis.opendocument.graphics",
3074-
"odc": "application/vnd.oasis.opendocument.chart",
3075-
"odb": "application/vnd.oasis.opendocument.database",
3076-
"odf": "application/vnd.oasis.opendocument.formula",
3077-
"wp|wpd": "application/wordperfect",
3078-
"key": "application/vnd.apple.keynote",
3079-
"numbers": "application/vnd.apple.numbers",
3080-
"pages": "application/vnd.apple.pages"
3081-
}
2985+
"type": "string"
30822986
},
30832987
"required": false
30842988
}

0 commit comments

Comments
 (0)