-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions and environment
M2.4.7
Steps to reproduce
Implement DI overrides to allow more than just jpeg, jpg, png, gif files to be uploaded to the CMS media gallery e.g. add PDF
Expected result
PDF files can be uploaded and used in CMS content.
Actual result
PDF files are now disallowed again in 2.4.7
Additional information
Why are they now disallowed? Simple - some developer decided to "fix" a check for allowed files types in the media-uploader.js script. Instead of supplying allowed types to the script, as specified in DI, s/he hardcoded the allowed extensions in the script.
_create: function () {
let self = this,
arrayFromObj = Array.from,
progressTmpl = mageTemplate('[data-template="uploader"]'),
uploaderElement = '#fileUploader',
targetElement = this.element.find('.fileinput-button.form-buttons')[0],
uploadUrl = $(uploaderElement).attr('data-url'),
fileId = null,
allowedExt = ['jpeg', 'jpg', 'png', 'gif'],
allowedResize = false,
options = {
In fact someone thought of doing this in earlier versions but never followed it through - acceptFileTypes is never used:
dropZone: '[data-tab-panel=image-management]',
sequentialUploads: true,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
maxFileSize: this.options.maxFileSize,
Come on, how does this kind of schoolboy error make it into production? We learnt in the '80s that you never duplicate code/constants. If you do then your code is wrong and needs to be restructured to remove duplication.
Now, in addition to adding multiple DI entries to allow more file types in CMS content (which is also very poor code design), we have to override Magento_Backend/js/media-uploader.js to allow them, and manage core changes going forward.
Magento developers - you must do better! The time and cost of your errors is considerable.
Release note
Fix error introduced in 2,4.7 that negates DI changes to allow additional file types in CMS pages/blocks.
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.