fix(media): Allow deleting files outside upload_files - #17029
Open
Ibochkarev wants to merge 1 commit into
Open
Ibochkarev wants to merge 1 commit into
Ibochkarev wants to merge 1 commit into
Conversation
removeObject() rejected any extension missing from upload_files, so core/cache/logs/error.log could not be deleted. Delete does not write a new extension. Create, upload, update, and rename still check the list. Fixes modxcms#15905
Ibochkarev
marked this pull request as ready for review
September 21, 2026 13:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
removeObject()calledcheckFileType()beforedelete(). When the media source propertyallowedFileTypesis empty, that method uses the system settingupload_files. The default list has nolog, so deletingcore/cache/logs/error.logfailed withfile_err_ext_not_allowed.#15643 (SEC-3837) added the check so the manager cannot write a disallowed extension. The setting text in
core/lexicon/en/setting.inc.phpdescribes uploads. Delete does not write a new extension.Browser/File/Removealready requires thefile_removepermission and the sourceremovepolicy.The call is gone from
removeObject().createObject(),updateObject(),uploadObjectsToContainer(), and the new name inrenameObject()still usecheckFileType().How to test
With
allowedFileTypesempty on the Filesystem source, deletecore/cache/logs/error.logfrom the file browser. It should be removed.Upload or create a file whose extension is not in
upload_files. That should still fail withfile_err_ext_not_allowed. Renaming a file to a disallowed extension should fail the same way.Related issue(s)/PR(s)
Resolves #15905
The check comes from #15643.
Compatibility notes
This applies to every media source that uses
modMediaSource::removeObject(). There is no schema change and no upgrade script.Breaking change assessment
No public API signature change. A user who already has
file_removecan now delete a file whose extension is outsideupload_files. Writing that extension is still rejected.Test coverage
No test added.
_build/testhas no media source coverage forremoveObject(), and there is no localproperties.inc.phpto run PHPUnit against a filesystem source.Contributors
@Jako reported that
error.logcannot be deleted and pointed at #15643.AI tool use
Cursor compared
removeObject()with the checks added in #15643 and removed the extension check from delete only.