#82784DataHandler: copyRecords doesn't set sorting correctly for negative $destPid
Description
In DataHandler->copyRecord() accepts a $destPid which (according to the phpDoc) can either contain a page id or (indicated by a negative number) a content uid after which the source record is copied to. This “convention” is also used in DataHandler->moveRecord().
However DataHandler->copyRecord() does not implement the functionality. Only DataHandler->moveRecord() does.
How to reproduce:
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$data = [
'tt_content' => [
$sourceContentUid=> [
'copy' => ($targetContentUid * -1),
],
],
];
$dataHandler->start([], $data);
$dataHandler->process_cmdmap();
The copied element will just receive the sorting value of the source element instead of being sorted after the target content element.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 4
-
Coders.Care Extension Team commented <span data-processor="relativetime" data-value="2017-10-17T20:25:20+00:00" > 10/17/17, 20:25 </span>
-
Oliver Hader commented and changed status
NewAccepted <span data-processor="relativetime" data-value="2018-01-23T20:41:12+00:00" > 01/23/18, 20:41 </span>Should be verified with an additional DataHandler functional test using negative PID values
-
Benni Mack changed Sprint Focus Stabilization Sprint <span data-processor="relativetime" data-value="2023-06-06T13:08:27+00:00" > 06/06/23, 13:08 </span>
-
Benjamin Kott commented and changed status
AcceptedClosed <span data-processor="relativetime" data-value="2026-08-24T17:26:56+00:00" > 08/24/26, 17:26 </span>DataHandler: copyRecords doesn’t set sorting correctly for negative $destPid
Resolved by: no single commit identified. Not reproducible on main (15.0.0-dev); verified by functional test — copying tt_content 298 with copy => -299 yields pid 89, sorting 896, correctly placed after 299.
AFAICS sorting is done in process_datamap, which is called by process_cmdmap in case of ‘copy’ but not in case of ‘move’, since usually there is no data to be processed, when moving a record.
So sorting should be handled at lines 1058 to 1082 of \TYPO3\CMS\Core\DataHandling\DataHandler