#53167 closed defect (bug) (fixed)
upload_filetypes should map to get_allowed_mime_types
| Reported by: | spacedmonkey | Owned by: | adamsilverstein |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.6 |
| Component: | Networks and Sites | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch has-unit-tests commit needs-dev-note |
| Cc: | Focuses: | multisite, performance |
Description
Currently in multisite upload_filetypes site option is massively out of date with mime / ext allowed in get_allowed_mime_types.
Attachments (1)
Change History (36)
This ticket was mentioned in PR #1232 on WordPress/wordpress-develop by spacedmonkey.
6 years ago
#1
- Keywords has-patch added
This ticket was mentioned in Slack in #core-multisite by spacedmonkey. View the logs.
6 years ago
#3
@
5 years ago
- Focuses performance added
This also relates to performance since it complicates usage of modern image formats like WebP on multisite environments.
This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.
3 years ago
This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.
3 years ago
This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.
3 years ago
#8
@
3 years ago
- Keywords needs-testing-info has-unit-tests added
PR looks good, thanks @spacedmonkey! Some steps to test would be helpful here so we can get some manual testing.
This ticket was mentioned in PR #6380 on WordPress/wordpress-develop by @pbearne.
3 years ago
#9
Trac ticket: 53167
This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.
3 years ago
#11
@
3 years ago
I didn't find difference between patches 🤔
@pbearne and @spacedmonkey can you provide testing instructions please?
#12
@
3 years ago
@oglekler this change will only effect new installs of multisite. You will have to reset the local environment and install multisite with this patch installed to see this change.
This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.
2 years ago
This ticket was mentioned in Slack in #core-performance by joemcgill. View the logs.
2 years ago
#15
@
2 years ago
I didn't find difference between patches 🤔
I think its just updated against trunk.
@pbearne and @spacedmonkey can you provide testing instructions please?
- Test with a new install of a multisite network with the patch in place. Ideally on a server that supports AVIF.
- Create a new site in the multisite
- try uploading an AVIF image in the media library, it should work.
Check wp site option get upload_filetypes to see if the option includes avif for example.
This ticket was mentioned in Slack in #core-test by oglekler. View the logs.
2 years ago
#17
@
2 years ago
53167.diff is a refresh against trunk
#19
@
2 years ago
Steps to replicate:
Install patch / checkout PR
Create a fresh install of WordPress.
Convert site to multisite.
Go Network > Settings
In the Upload file types field it should look like this.
jpg jpeg jpe gif png bmp tiff tif webp avif ico heic asf asx wmv wmx wm avi divx flv mov qt mpeg mpg mpe mp4 m4v ogv webm mkv 3gp 3gpp 3g2 3gp2 txt asc c cc h srt csv tsv ics rtx css vtt dfxp mp3 m4a m4b aac ra ram wav ogg oga flac mid midi wma wax mka rtf pdf class tar zip gz gzip rar 7z psd xcf doc pot pps ppt wri xla xls xlt xlw mdb mpp docx docm dotx dotm xlsx xlsm xlsb xltx xltm xlam pptx pptm ppsx ppsm potx potm ppam sldx sldm onetoc onetoc2 onetmp onepkg oxps xps odt odp ods odg odc odb odf wp wpd key numbers pages
Which is different from the current list.
$misc_exts = array( // Images. 'jpg', 'jpeg', 'png', 'gif', 'webp', // Video. 'mov', 'avi', 'mpg', '3gp', '3g2', // "audio". 'midi', 'mid', // Miscellaneous. 'pdf', 'doc', 'ppt', 'odt', 'pptx', 'docx', 'pps', 'ppsx', 'xls', 'xlsx', 'key', );
CC @joemcgill @pbearne @mukesh27
This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.
2 years ago
#21
@
2 years ago
Playground links:
- Latest WordPress
- PR 6360 (Server doesn't support AVIF but you can try uploading another added filetype, like ZIP for example)
This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.
2 years ago
#23
@
2 years ago
Test Report
Patch tested - https://github.com/WordPress/wordpress-develop/pull/6380
Environment:
OS: Windows 11
Browser: Chrome v125
Actual Result: The newly added file extensions are now properly visible in the "Upload File Types" section within network settings. Also, files with these extensions can be uploaded successfully✅
Screenshots:
Upload file types in network settings: https://prnt.sc/JExTb0WrsBMH
Upload .avif file: https://prnt.sc/-J73tfInlD1a
#24
@
2 years ago
- Keywords commit added
As this has now been tested and validated it works, I am marking as commit.
This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.
2 years ago
This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.
2 years ago
#27
@
2 years ago
One thing that I was curious about when looking at this patch is whether there was a reason that the default mime types allowed for multisite was chosen for a good reason. Looking back at #24434, which is an early example of updating this list, the sentiment by Core devs at the time was that the list seemed somewhat arbitrary, so I think that pulling this list from get_allowed_mime_types makes sense.
I'll also note that this will only affect newly created networks, since this is only used to populate the schema for new networks, not change the allowed mime types for existing networks. To do so, a network admin would need to updated the list of allowed upload file types in /wp-admin/network/settings.php, which updates the upload_filetypes option for the site. I confirmed that applying this PR to an existing site does not change the set of allowed file types.
I think this makes sense and makes maintenance of this list much less manual.
#28
@
2 years ago
- Keywords needs-testing-info removed
Test Report
Patch tested: PR-6380
Screenshots
Added ZIP in allowed file list: https://prnt.sc/zPjZaT4x__tr
Can upload the ZIP file: https://prnt.sc/1TrSatbnXi-t
✅ The issue is resolved with a patch.
Removing 'needs-testing-info' as Comment:19 has the information.
This ticket was mentioned in Slack in #core-performance by joemcgill. View the logs.
2 years ago
@mukesh27 commented on PR #1232:
8 weeks ago
#33
Thanks for the PR, @spacedmonkey!
This appears to have been addressed in r58400, which already landed. Closing this PR as resolved.
If I've missed something this PR covers that the committed fix doesn't, please reopen or comment on the ticket. Happy to take another look.
@mukesh27 commented on PR #6380:
8 weeks ago
#34
Thanks for the PR, @pbearne!
This appears to have been addressed in r58400, which already landed. Closing this PR as resolved.
If I've missed something this PR covers that the committed fix doesn't, please reopen or comment on the ticket. Happy to take another look.
This ticket was mentioned in PR #15956 on WordPress/wordpress-develop by @desrosj.
5 days ago
#35
Adds a multisite Site Health check that recommends the file types a network created today would allow uploading, when the network's list is missing any of them.
The upload_filetypes network option is populated once, in populate_network_meta(), and upgrades never change it:
- [50810] (5.8) added
webpto the defaults, and [57524] (6.5) addedavif. - [58400] (6.6, #53167) switched new networks to every extension from
get_allowed_mime_types(), and notes that existing networks are not affected.
So networks created before 5.8 cannot upload WebP, those created before 6.5 cannot upload AVIF, and those created before 6.6 are missing most of the types a single site allows. Any type core adds later (JPEG XL, for example) will also be missing from every existing network. With client-side media processing, a missing image type can also stop generated sub-sizes from being sideloaded (see PR 15859).
The check
- Registered on every site of a network, when
is_multisite(). On multisite, only super admins can see Site Health (wp_maybe_grant_site_health_caps()), as with the other checks that look at the network. - Good when the network allows every default type. Recommended otherwise, listing the missing extensions and saying that adding them is optional.
- Only missing defaults are reported. Types the network allows beyond them (SVG, say) are ignored.
- Matched the way
check_upload_mimes()matches. An extension isn't reported when another extension of the same type already allows it, sojpeisn't reported whenjpgis allowed. - HTML and JavaScript are never recommended. The defaults are built as
get_allowed_mime_types()builds them for a user withoutunfiltered_html. This also means the result doesn't depend on who is viewing it, or whether it runs from cron. - The "Update the allowed upload file types" link to Network Settings is only shown to users with
manage_network_options.
Open question: the length of the list
On a network still on the oldest defaults, the check currently lists about 130 extensions. For networks created between 5.8 and 6.5, it still lists dozens of non-image types (bmp, tiff, ico, heic, txt, csv, zip, the Office and OpenDocument formats, and so on). It may be better to limit the recommendation to image formats, or to group the list by type.
Testing
tests/phpunit/tests/admin/wpSiteHealthGetTestNetworkUploadFiletypes.php:
npm run test:php -- -c tests/phpunit/multisite.xml --filter Tests_Admin_wpSiteHealthGetTestNetworkUploadFiletypes npm run test:php -- --filter Tests_Admin_wpSiteHealthGetTestNetworkUploadFiletypes
The site-health group passes on single site (122 tests) and multisite (130 tests).
Manually: on a multisite install, set Network Admin → Settings → Upload file types to jpg jpeg png gif, then open Tools → Site Health on any site as a super admin.
Trac ticket: TBD
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Researching how the network defaults changed, and drafting the check, tests and this description. To be reviewed by me.
🤖 Generated with Claude Code
Trac ticket: https://core.trac.wordpress.org/ticket/53167