Issue Bug Closed

#107432RuntimeException when creating new workspace version of sys_file_metadata records as editor

Stefan Froemken 09/11/25, 07:09 updated 08/11/26, 08:46

Description

Hello,

when creating a new workspace version of a sys_file_metadata record as a backend editor, TYPO3 throws a RuntimeException.

This happens because TYPO3 tries to check page permissions for the record. During this process, TYPO3 extracts the pid of the record and fetches the corresponding pages record from the database. However, sys_file_metadata records always have pid = 0. As a result, the database query for the pages record returns an empty array. Since this array does not contain a pid field, TYPO3 raises an exception.

Steps to reproduce

  1. Log in to the TYPO3 backend as an editor (non-admin). Editor has no LIVE workspace access and is assigned as valid user to a workspace.
  2. Navigate to the Filelist module.
  3. Select a file and open its metadata (from table sys_file_metadata).
  4. Change a value like title or description
  5. Save the records (which will try to create a new version of the metadata record).

Expected behavior

Creating a new workspace version of sys_file_metadata should work without errors. Since metadata records always have pid = 0, TYPO3 should handle this case gracefully without attempting to fetch a related pages record.

Actual behavior

TYPO3 throws the following exception:

(1/1) #1578950324 RuntimeException

The given page record is invalid. Missing uid.
in /vendor/typo3/cms-core/Classes/Authentication/BackendUserAuthentication.php line 329

Stack trace excerpt:

at TYPO3\CMS\Core\Authentication\BackendUserAuthentication->isInWebMount(array())
in /vendor/typo3/cms-core/Classes/DataHandling/DataHandler.php line 7620
...
at TYPO3\CMS\Core\DataHandling\DataHandler->hasPagePermission(1, array())

Additional information

The issue only occurs for editors (non-admin users).

sys_file_metadata records are always stored on pid = 0, which makes the page permission check invalid in this context.

As a result, TYPO3 receives an empty array instead of a valid pages record, leading to the RuntimeException.

Reviews 13

History 1523

  1. Garvin Hicking commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2025-09-11T08:03:42+00:00" > 09/11/25, 08:03 </span>

    Is this with 13.4.18? I think this bug was fixed there?! It sounds a lot like a duplicate of https://review.typo3.org/c/Packages/TYPO3.CMS/+/90469 or another patch I could not find right now with workspace relefance…

  2. Stefan Froemken commented <span data-processor="relativetime" data-value="2025-09-11T08:44:43+00:00" > 09/11/25, 08:44 </span>

    Hi Garvin, I have this issue with TYPO3 13.4.18. My problem seems to be related somewhere in DataHandler::versionizeRecord, while your linked issue is more related to code in sys_history. Looks like a new issue IMO.

  3. Stefan Froemken commented <span data-processor="relativetime" data-value="2025-09-18T09:31:00+00:00" > 09/18/25, 09:31 </span>

    Some problem while setStage (Ready for publish) and publish. I have updated my current Hook:

    <?php
    
    declare(strict_types=1);
    
    /*
     * This file is part of the package jweiland/[removed].
     *
     * For the full copyright and license information, please read the
     * LICENSE file that was distributed with this source code.
     */
    
    namespace JWeiland\SitePackage\Hook;
    
    use TYPO3\CMS\Core\DataHandling\DataHandler;
    
    /**
     * Because of a TYPO3 issue an editor cannot create a new version for his
     * workspace for sys_file_metadata records.
     * TYPO3 extracts the "pid" column from sys_file_metadata which is "0" by
     * default. So, retrieved pages record results in empty array. Because of missing "uid"
     * column the editor gets error: "The given page record is invalid. Missing uid."
     *
     * With this hook we temporarily allow an editor to create a new version of
     * sys_file_metadata records by bypassing the workspace permission check.
     *
     * If anything fails while customer session, please remove or comment the line with
     * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass']
     * from ext_localconf.php, flush cache, and you're done.
     *
     * link: https://forge.typo3.org/issues/107432
     */
    class DataHandlerHook
    {
        /**
         * Using processCmdmap_preProcess instead of processCmdmap hook is necessary here
         * because EXT:workspaces also hooks into processCmdmap. Since the loading order
         * cannot be controlled and EXT:workspaces is a core extension, our hook
         * implementation would never be executed before the workspaces hook.
         */
        public function processCmdmap_preProcess(
            string $command,
            string $table,
            string|int $id,
            mixed $value,
            DataHandler $dataHandler,
            mixed $pasteUpdate
        ): void {
            if ($command !== 'version') {
                return;
            }
    
            if ($table !== 'sys_file_metadata') {
                return;
            }
    
            // setStage is needed for "Ready to publish"
            $action = $value['action'] ?? null;
            if (!in_array($action, ['new', 'setStage', 'publish'], true)) {
                return;
            }
    
            $dataHandler->bypassAccessCheckForRecords = true;
        }
    
        public function processCmdmap_postProcess(
            string $command,
            string $table,
            string|int $id,
            mixed $value,
            DataHandler $dataHandler,
            mixed $pasteUpdate,
            array $pasteDatamap
        ): void {
            if ($command !== 'version') {
                return;
            }
    
            if ($table !== 'sys_file_metadata') {
                return;
            }
    
            $dataHandler->bypassAccessCheckForRecords = false;
        }
    }
  4. Gerrit Code Review pushed patch set 1 for main to change 94311 status Needs Feedback Under Review <span data-processor="relativetime" data-value="2026-06-04T08:10:09+00:00" > 06/04/26, 08:10 </span>

  5. Oliver Hader commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-07-14T11:55:09+00:00" > 07/14/26, 11:55 </span>

    Applied in changeset commit:8f04953cb719cd9c2e5fad70cccc77766c68af8f.