Issue Bug Closed

#107334sys_file_reference pid 0 when adding media on page creation

Rudy Gnodde 08/26/25, 13:50 updated 12/02/25, 13:58

Description

*Description*
If you link a file in the media field when creating a page, the resulting sys_file_reference record gets pid 0. This means non-admin users are unable to remove it.

*How to reproduce*
- Log in to a TYPO3 13 backend
- Go to the “Page” module
- Right click on an existing page
- Click on “New subpage“
- Input a title
- Go to the “Resources” tab and select a file for the “Media” field
- Save the page

*Expected result*
- pid of the sys_file_reference record is the uid of the new page
- Non-admin user is able to remove the sys_file_reference

*Actual result*
- pid of the sys_file_reference record is 0
- Non-admin user is not able to remove the sys_file_reference

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 9

  1. Rudy Gnodde commented <span data-processor="relativetime" data-value="2025-08-26T14:17:26+00:00" > 08/26/25, 14:17 </span>

    I just noticed `$GLOBALS[‘TCA’][‘sys_file_reference’][‘ctrl’][‘security’][‘ignoreRootLevelRestriction’]` is set to `true`, so this could also be a bug where the delete button isn’t shown to non-admin users even though `ignoreRootLevelRestriction` is set to `true`. Possibly a regression of #106569

  2. Rudy Gnodde commented <span data-processor="relativetime" data-value="2025-08-26T14:46:58+00:00" > 08/26/25, 14:46 </span>

    It is not a regression of #106569. The problem occurs in TYPO3\CMS\Backend\Form\Container\FileReferenceContainer::renderFileReferenceHeaderControl().

            $calcPerms = new Permission(
                $backendUser->calcPerms(BackendUtility::readPageAccess(
                    (int)($this->data['parentPageRow']['uid'] ?? 0),
                    $backendUser->getPagePermsClause(Permission::PAGE_SHOW)
                ))
            );

    Because the pid of the sys_file_reference record is 0, $this->data[‘parentPageRow’] is empty and the user does not have access to a page with uid 0.

  3. Rudy Gnodde commented <span data-processor="relativetime" data-value="2025-08-27T06:45:07+00:00" > 08/27/25, 06:45 </span>

    Yes, #103092 fixes the pid 0 problem. However, if `security.ignoreRootLevelRestriction` is set in TCA, shouldn’t users be able to remove the sys_file_reference even if pid is 0.

  4. Christian Kuhn commented and changed status Needs Feedback Resolved <span data-processor="relativetime" data-value="2025-08-27T08:12:22+00:00" > 08/27/25, 08:12 </span>

    Rudy Gnodde wrote in #note-7:
    > Yes, #103092 fixes the pid 0 problem. However, if `security.ignoreRootLevelRestriction` is set in TCA, shouldn’t users be able to remove the sys_file_reference even if pid is 0.

    Thx. I hope it is ok to close here as duplicate.

    Unsure about `security.ignoreRootLevelRestriction`, there may be further checks / settings that prevent users from accessing pid 0 in this case. If you have to fix your existing db set, you could do that manually lowlevel (i guess not that many records should be affected?), and you could have a look at ext:dbdoctor which comes with a (relatively early) fixer to move sys_file_reference records to correct pid.