Issue Bug Closed

#76215DataHandler | bypassAccessCheckForRecords flag gets lost

Andreas Stenger 05/17/16, 18:09 updated 02/27/20, 12:41

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

Reviews 2