Bug #76215
closedDataHandler | bypassAccessCheckForRecords flag gets lost
100%
Description
The following code inside a backend-module fails due to access restrictions.
private function clonePages($copyPid, $targetPid) { $cmdmap['pages'][$copyPid]['copy'] = $targetPid; $this->tce->copyTree = 99; $this->tce->bypassAccessCheckForRecords = true; $this->tce->start(false, $cmdmap); $this->tce->process_cmdmap(); return $this->tce->copyMappingArray_merged; }
Goal:
Copy the page-tree of $copyPid recursive as new child-tree of $targetPid.
Issue:
The current backend-user does not have access (no db-mount) to the page $copyPid nor to the page $targetPid.
By setting $this->tce->bypassAccessCheckForRecords = true; however the access-check for $copyPid gets skipped, as intended.
For the access-check of $targetPid the flag is false for some reason what results in "Attempt to insert a record on page '###' (###) from table 'pages' without permissions. Or non-existing page."
I dont see a way to keep the flag set to true allthough in this case i need both checks to be skipped.
This can be checked by e.g. var_dumping $this->bypassAccessCheckForRecords in TYPO3\CMS\Core\DataHandling\DataHandler::doesRecordExist