Bug #67486
closed[DATALOSE] Datahandler writes wrong workspace pid to live records
0%
Description
How to reproduce: add a file to the pages media -> The pid points to the live id. Now switch to a workspace and add another file. Since the big IRRE refactoring #56376, all relations should point to the live ids. The new sys_file_reference record does that, but the already existing record now has the uid of the pages record in the workspace! Both relations show up in the workspace and publishing the pages record also works, but the real trouble starts when cleaning up with "lowlevel_cleaner versions". The pages record from the workspace will be deleted because it is published. The records on that versioned page will also be deleted, and thus the sys_file_reference is gone.
How to fix? \TYPO3\CMS\Core\DataHandling\DataHandler::remapListedDBRecords_procInline does an SQL update which writes to the records it processed. Removing these lines prevents the wrong pid, but i have no idea what the intention of these were. But that won't fix the records with invalid pids...
// Update child records if change to pid is required (only if the current record is not on a workspace): if ($thePidToUpdate) { $updateValues = array('pid' => $thePidToUpdate); foreach ($originalItemArray as $v) { if ($v['id'] && $v['table'] && is_null(BackendUtility::getLiveVersionIdOfRecord($v['table'], $v['id']))) { $GLOBALS['TYPO3_DB']->exec_UPDATEquery($v['table'], 'uid=' . (int)$v['id'], $updateValues); } } }