Repository navigation
[BUGFIX] do not copy children twice if container is in same cmdmap - #779
Open
Scopestyle wants to merge 1 commit into
Open
Scopestyle wants to merge 1 commit into
Scopestyle wants to merge 1 commit into
Conversation
If a container and its children are copied or moved with one cmdmap (e.g. Record module: select all, copy, paste into other page), the children are processed first (clipboard reverses the order) and keep tx_container_parent of the original container. Copying the container afterwards also copies these copies, so every child ends up three times on the target page. Copy/move commands of records are now removed if one of their containers has an identical command in the same cmdmap, the container copies/moves its children anyway. The container chain is resolved with workspace overlay. Fixes: b13#770 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scopestyle
marked this pull request as ready for review
October 2, 2026 16:53
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.
Fixes #770
When a container and its children end up in the same DataHandler cmdmap with
copy(for example in the Record module: select all, copy, paste into another page), every child ends up on the target page three times. In the nested case the inner element even ends up seven times.Cause
SimpleDataHandlerController::setPasteCmd()reverses the clipboard order, so the children are processed before their container. Each child is copied on its own. Itsupdateis empty, so the copy keepstx_container_parentof the original container.CommandMapPostProcessingHook::copyOrMoveChildren()collects the children throughDatabase::fetchRecordsByParentAndLanguage(), which has no pid restriction. So it picks up the original children and the copies from step 1, and copies all of them into the new container.This is not specific to the Record module. Any cmdmap that contains a container together with its children triggers it, for example custom modules, imports, or CLI code.
Fix
CommandMapBeforeStartHooknow removescopy/movecommands of records whose container (at any nesting level) has an identical command in the same cmdmap. The container already copies or moves its children, so the child's own command is redundant.updateis left untouched.tx_container_parentchain is read with a workspace overlay. A child that was moved out of its container in a workspace is therefore not dropped.unsetInconsistentCopyOrMoveCommands(). If a container's command was already removed, its children keep their own commands.Tests
New:
Tests/Functional/Datahandler/DefaultLanguage/ContainerWithChildrenInCmdmapTest.phpand one test inWorkspace/ContainerTest.php. Each cmdmap is in clipboard order (children first):copyContainerWithChildrenInCmdmapCopiesChildrenOnlyOncecopyNestedContainerWithChildrenInCmdmapCopiesChildrenOnlyOncemoveContainerWithChildrenInCmdmapKeepsChildrenInContainersortingvalues differ (each child is moved separately first)Workspace\…::copyContainerWithChildrenInCmdmapCopiesChildMovedOutOfContainerInWorkspaceRun locally with
Build/Scripts/runTests.sh:-s functional -- --do-not-fail-on-deprecation --exclude-group v14-only: 511 tests, OK-s functional: 535 tests, OKcgl -nandphpstan(13 and 14): OKNot covered
master, a cmdmap like "container → page X, child → container B / colPos 0 on page X" already ignores the child's target. The child ends up in the copied/moved container whether or not this change is applied, so no test can tell the two apart. That behaviour is separate from this PR.fetchRecordsByParentAndLanguage()has no pid restriction. Records on other pages that still point to a container (see [BUG] Pasting in List View does not reset the container parent #662) are therefore copied into each copy of that container. This PR does not change that.Tested in a real project on TYPO3 13.4.35 / container 3.2.3 with the same logic as a standalone hook. Copying whole pages (41, 35 and 28 elements) produced exactly one copy per element, each in the correct container.
🤖 Generated with Claude Code