#110242DataHandler::hasPageContextPermission() denies admin / bypassAccessCheckForRecords when BE user uid is 0
Description
Summary
Since 14.3.5 / 13.4.33, DataHandler::hasPageContextPermission() returns false for a backend user with uid = 0, even when that user is an admin or when bypassAccessCheckForRecords is enabled. The !$beUserUid guard was moved in front of both escape hatches, so neither is reached for a uid-0 user. This worked in 14.3.4.
Behavior change
In Classes/DataHandling/DataHandler.php, hasPageContextPermission():
$beUserUid = $this->BE_USER->getUserId();
if (!$beUserUid) {
return false; // uid 0 returns here
}
if ($this->bypassAccessCheckForRecords || $this->BE_USER->isAdmin()) {
return true; // never reached for uid 0
}
The !$beUserUid guard now precedes the bypassAccessCheckForRecords / isAdmin() check. In 14.3.4 that path reached the bypass regardless of uid. Since bypassAccessCheckForRecords exists for exactly the user-less case, a falsy-uid guard defeating it looks like an ordering oversight, not intended tightening.
Impact
hasPageContextPermission() is the first sub-check inside hasPermissionToInsert(). When it returns false, the insert is rejected and logged as:
Attempt to insert record on pages:{pid} where table "{table}" is not allowed
The message is misleading: isTableAllowedForThisPage() is unchanged and passes — the real failure is the page-permission check short-circuiting on uid 0. The symptom points at TCA / rootLevel config while the cause is the guard ordering.
Steps to reproduce
- Build a
BackendUserAuthenticationwithuser = ['uid' => 0, 'admin' => 1](or set$dataHandler->bypassAccessCheckForRecords = true). - Run
DataHandler::start()with a datamap inserting a record on a normal page. - On 14.3.4 the insert succeeds; on 14.3.5 / 13.4.33 it is rejected.
Suggested change
Move the bypassAccessCheckForRecords / isAdmin() escape hatch before the !$beUserUid guard, so admin and explicit-bypass contexts are honoured independent of uid:
if ($this->bypassAccessCheckForRecords || $this->BE_USER->isAdmin()) {
return true;
}
$beUserUid = $this->BE_USER->getUserId();
if (!$beUserUid) {
return false;
}
This restores the 14.3.4 behaviour while keeping the refined root-level handling intact.
Secondary consideration: the
VirtualRecord::RootPage/shallIgnoreRootLevelRestriction()branch also sits after the!$beUserUidguard and may need to move above it too — worth confirming during review.
Notes
Reported at github.com/maikschneider/tca-api/issues/157; Oliver Hader confirmed reordering so bypassAccessCheckForRecords runs first is acceptable.