Fix resource delete, trash restore, and nested system pages - #8
Open
Ibochkarev wants to merge 4 commits into
Open
Fix resource delete, trash restore, and nested system pages#8Ibochkarev wants to merge 4 commits into
Ibochkarev wants to merge 4 commits into
Conversation
The Deleted checkbox on Resource/Update only flipped the current resource, so children stayed live in the tree. Defer the flag to Resource/Delete and Resource/Undelete so form save matches context-menu soft-delete, including deletedon/deletedby.
Restoring a child from trash left its deleted parent in place, and purging a parent only mentioned the parent in the success message. Deleting a folder that contained site_start, error_page, or site_unavailable_page also skipped the root-level protection. Restore now undeletes the ancestor chain. Purge counts removed descendants. Parent delete fails if the tree includes a system page. Creating or moving under a deleted parent is refused.
Connector actions still map Resource/Delete to Processors\Resource, so that package cannot be renamed. Exclude the soft-reserved keyword sniff there and in the legacy processor tests.
Codecov flagged 27 uncovered patch lines. Exercise deferred Delete failure, weblink form delete, move under a deleted parent, nested error_page, purge of parent+child ids, and Undelete of a child.
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.
Что сделано
Чекбокс Deleted в форме ресурса сохранял только сам ресурс. Дочерние оставались
deleted=0, поэтому дерево показывало их живыми. Восстановление дочернего из корзины оставляло родителя удалённым, поэтому дочерний исчезал из корзины, оставаясь под удалённой папкой. Purge родителя перманентно удалял дочерних, но сообщение об успехе перечисляло только родителя. Перемещениеsite_start, страницы 404 или страницы unavailable под папку с последующим удалением папки обходило корневую защиту.Resource/Updateоставляетdeletedбез изменений при собственном save, затем запускаетResource/DeleteилиResource/Undelete. Восстановление из корзины undelete цепочку предков. Purge включает id потомков в счётчик успеха. Delete падает, если ресурс или любой потомок этоsite_start,error_pageилиsite_unavailable_page. Create и move отказывают для удалённого родителя.Как проверить
deletedon/deletedby.site_start(или 404 / unavailable) под папку и попробуйте удалить папку. Delete должен отказать. Та же проверка уже блокирует удаление такой страницы на корневом уровне.Gate E (этот запуск):
php -lна затронутых процессорах: exit 0core/vendor/bin/phpunit -c _build/test/phpunit.xml --filter 'ResourceUpdateDeleteCascadeTest|ResourceTrashHierarchyTest': OK (6 тестов, 64 assertions), exit 0site_startзаблокировано; создание под удалённым родителем заблокированоСвязанные
Refs modxcms#14167. Связанные: modxcms#14350 перечислял удалённых дочерних в корзине.
Совместимость
Удаление через форму требует той же политики
delete/undeleteресурса, что и контекстное меню.Удаление через форму вызывает
OnBeforeDocFormDelete,OnDocFormDeleteиOnResourceDelete(с дочерними), как tree Delete.Восстановление дочернего теперь также undelete удалённых предков (и вызывает
OnResourceUndeleteдля них).Оригинал: modxcms#17003