fix(mixedimage): удаление и замена файлов TV (#17) - #46
Open
Ibochkarev wants to merge 1 commit into
Open
Conversation
Ibochkarev
marked this pull request as ready for review
August 9, 2026 04:16
TV media source context for delete, orphan cleanup when upload paths differ, and manager connector params (tv_id, formdata, previous_value). Fixes webinmd#17
Ibochkarev
force-pushed
the
fix/issue-17-file-remove-replace
branch
from
August 9, 2026 04:20
ebf3c5e to
aaeb96d
Compare
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.
Исправлены проблемы из #17: файл не удалялся с диска по кнопке «Очистить», при загрузке нового изображения старый оставался на сервере.
Зачем
remove.class.phpбыл пустым stub наmodBrowserFileRemoveProcessor. Родитель инициализирует media source только по ID источника, без контекста TV. Путь файла иbasePathне совпадали,removeObject()не находил файл.Upload не удалял предыдущий файл при смене пути (orphan
.png→.jpgприprefixFilename). Клиент не передавалtv_id,formdataиprevious_value.Что сделано
Backend
remove.class.php— bootstrap, возвращает FQCN processor (PSR-1).BrowserFileRemoveProcessor— загружает TV поtv_id, media source изcontext_keyвformdata, проверяетremoveFile, удаляет черезremoveObject().MixedImageTvMediaSource— helper для remove и upload: нормализация пути, загрузка TV, init source.upload.class.php—removePreviousFileIfReplaced()при разных путях иprevious_valueот клиента. Ошибка удаления не отменяет upload.Frontend (
mixedimage.js)getRemoveParams()—tv_id,formdata,HTTP_MODAUTH,fileчерезgetValue().getPreviousFileValue()+previous_valueв upload (desktop, drag-and-drop, URL).clearField()черезsetValueInput('')иMODx.fireResourceFormChange().isYesOption()дляremoveFile(MODX 3 хранит1/0).tv_id/tvIdв окне загрузки по URL.PHP / tpl
toJsBoolean()только для опцииremoveFileвmixedimage.class.php.jsonlexв tpl для окна upload по URL.Scope
Ветка содержит только изменения для #17. Превью после reload — отдельный PR #45. Crop и docs — #44.
Рекомендуемый порядок merge: #45 → #44 → #46 (rebase на master после каждого).
На ревью
returnremove processor для MODX 2/3.\у\modProcessor,\modTemplateVar,\modMediaSourceв helper.removeFile=Да.Fixes #17