diff --git a/Classes/Hooks/Datahandler/CommandMapBeforeStartHook.php b/Classes/Hooks/Datahandler/CommandMapBeforeStartHook.php index 97a033f4..91287333 100644 --- a/Classes/Hooks/Datahandler/CommandMapBeforeStartHook.php +++ b/Classes/Hooks/Datahandler/CommandMapBeforeStartHook.php @@ -195,11 +195,14 @@ protected function rewriteSimpleCommandMap(array $cmdmap): array if (in_array($operation, ['copy', 'move'], true) === false) { continue; } + if (empty($cmd[$operation])) { + continue; + } if (is_array($cmd[$operation])) { continue; } - if ((int)$cmd[$operation] < 0) { - $target = (int)$cmd[$operation]; + $target = (int)$cmd[$operation]; + if ($target < 0) { $targetRecordForOperation = $this->database->fetchOneRecord((int)abs($target)); if ($targetRecordForOperation === null) { continue; @@ -231,7 +234,23 @@ protected function rewriteSimpleCommandMap(array $cmdmap): array ], ], ]; + } else { + $cmd = [ + $operation => [ + 'action' => 'paste', + 'target' => $target, + 'update' => [], + ], + ]; } + } else { + $cmd = [ + $operation => [ + 'action' => 'paste', + 'target' => $target, + 'update' => [], + ], + ]; } } } diff --git a/Tests/Functional/Datahandler/DefaultLanguage/ContainerTest.php b/Tests/Functional/Datahandler/DefaultLanguage/ContainerTest.php index c7a7358e..29551388 100644 --- a/Tests/Functional/Datahandler/DefaultLanguage/ContainerTest.php +++ b/Tests/Functional/Datahandler/DefaultLanguage/ContainerTest.php @@ -296,6 +296,38 @@ public function copyContainerOtherPageOnTop(): void self::assertCSVDataSet(__DIR__ . '/Fixtures/Container/CopyContainerOtherPageOnTopResult.csv'); } + #[Test] + public function copyContainerOtherPageOnTopWithSimpleCommand(): void + { + $this->importCSVDataSet(__DIR__ . '/Fixtures/Container/CopyContainerOtherPageOnTopWithSimpleCommand.csv'); + $cmdmap = [ + 'tt_content' => [ + 1 => [ + 'copy' => 3, + ], + ], + ]; + $this->dataHandler->start([], $cmdmap, $this->backendUser); + $this->dataHandler->process_cmdmap(); + self::assertCSVDataSet(__DIR__ . '/Fixtures/Container/CopyContainerOtherPageOnTopWithSimpleCommandResult.csv'); + } + + #[Test] + public function copyContainerOtherPageAfterElementWithSimpleCommand(): void + { + $this->importCSVDataSet(__DIR__ . '/Fixtures/Container/CopyContainerOtherPageAfterElementWithSimpleCommand.csv'); + $cmdmap = [ + 'tt_content' => [ + 1 => [ + 'copy' => -10, + ], + ], + ]; + $this->dataHandler->start([], $cmdmap, $this->backendUser); + $this->dataHandler->process_cmdmap(); + self::assertCSVDataSet(__DIR__ . '/Fixtures/Container/CopyContainerOtherPageAfterElementWithSimpleCommandResult.csv'); + } + #[Test] public function copyContainerOtherPageAfterElement(): void { diff --git a/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageAfterElementWithSimpleCommand.csv b/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageAfterElementWithSimpleCommand.csv new file mode 100644 index 00000000..7ec65f1b --- /dev/null +++ b/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageAfterElementWithSimpleCommand.csv @@ -0,0 +1,9 @@ +"pages" +,"uid","pid","title" +,1,0,"" +,3,0,"" +"tt_content" +,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l18n_parent" +,1,1,"b13-2cols-with-header-container","container",64,0,0,0,0 +,2,1,"header","col1-first",128,0,200,1,0 +,10,3,"header","outside",512,0,0,0,0 diff --git a/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageAfterElementWithSimpleCommandResult.csv b/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageAfterElementWithSimpleCommandResult.csv new file mode 100644 index 00000000..5004b398 --- /dev/null +++ b/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageAfterElementWithSimpleCommandResult.csv @@ -0,0 +1,11 @@ +"pages" +,"uid","pid","title" +,1,0,"" +,3,0,"" +"tt_content" +,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l18n_parent" +,1,1,"b13-2cols-with-header-container","container",64,0,0,0,0 +,2,1,"header","col1-first",128,0,200,1,0 +,10,3,"header","outside",512,0,0,0,0 +,11,3,"b13-2cols-with-header-container","container",768,0,0,0,0 +,12,3,"header","col1-first",1024,0,200,11,0 diff --git a/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageOnTopWithSimpleCommand.csv b/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageOnTopWithSimpleCommand.csv new file mode 100644 index 00000000..7ec65f1b --- /dev/null +++ b/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageOnTopWithSimpleCommand.csv @@ -0,0 +1,9 @@ +"pages" +,"uid","pid","title" +,1,0,"" +,3,0,"" +"tt_content" +,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l18n_parent" +,1,1,"b13-2cols-with-header-container","container",64,0,0,0,0 +,2,1,"header","col1-first",128,0,200,1,0 +,10,3,"header","outside",512,0,0,0,0 diff --git a/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageOnTopWithSimpleCommandResult.csv b/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageOnTopWithSimpleCommandResult.csv new file mode 100644 index 00000000..f4c100a0 --- /dev/null +++ b/Tests/Functional/Datahandler/DefaultLanguage/Fixtures/Container/CopyContainerOtherPageOnTopWithSimpleCommandResult.csv @@ -0,0 +1,11 @@ +"pages" +,"uid","pid","title" +,1,0,"" +,3,0,"" +"tt_content" +,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l18n_parent" +,1,1,"b13-2cols-with-header-container","container",64,0,0,0,0 +,2,1,"header","col1-first",128,0,200,1,0 +,10,3,"header","outside",512,0,0,0,0 +,11,3,"b13-2cols-with-header-container","container",256,0,0,0,0 +,12,3,"header","col1-first",384,0,200,11,0