Issue Bug Closed

#110242DataHandler::hasPageContextPermission() denies admin / bypassAccessCheckForRecords when BE user uid is 0

Maik Schneider 07/21/26, 07:14 updated 08/11/26, 08:51

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

  1. Build a BackendUserAuthentication with user = ['uid' => 0, 'admin' => 1] (or set $dataHandler->bypassAccessCheckForRecords = true).
  2. Run DataHandler::start() with a datamap inserting a record on a normal page.
  3. 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 !$beUserUid guard 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.

Reviews 3

History 69

  1. Gerrit Code Review pushed patch set 1 for main to change 94880 status Accepted Under Review <span data-processor="relativetime" data-value="2026-07-22T11:00:16+00:00" > 07/22/26, 11:00 </span>

  2. Georg Ringer commented <span data-processor="relativetime" data-value="2026-08-07T17:28:02+00:00" > 08/07/26, 17:28 </span>

    IMHO the change is correct.
    https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/DataHandler/Introduction/Index.html states

    > DataHandler requires a backend login to work. This is due to the fact that permissions are observed (of course) and thus DataHandler needs a backend user to evaluate against.

    So as you already set a config like admin=1, I suggest to also set a correct uid

  3. Oliver Hader commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-08-07T18:50:11+00:00" > 08/07/26, 18:50 </span>

    Applied in changeset commit:ee251c96d55b6e609a77334324be0b91bb0839e5.