Issue Bug Resolved

#107103\RuntimeException is thrown, when an editor tries to delete a redirect

Moritz Ngo 07/16/25, 12:35 updated 09/14/26, 06:50

Description

When an editor tries to delete a redirect record, a \RuntimeException is thrown.

(1/1) #1578950324 RuntimeException
The given page record is invalid. Missing uid.

clipboard-202507161433-mr5be.png

A similar bug has been reported here: https://forge.typo3.org/issues/106928

Reviews 2

Files 4

History 1216

  1. Garvin Hicking commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2025-07-16T13:55:05+00:00" > 07/16/25, 13:55 </span>

    Could you maybe upload the whole stacktrace to see where hasPagePermission is called from?

  2. Moritz Ngo commented and changed attached clipboard-202507171438-byvuf.png <span data-processor="relativetime" data-value="2025-07-17T13:56:19+00:00" > 07/17/25, 13:56 </span>

    Garvin Hicking wrote in #note-2:
    > Could you maybe upload the whole stacktrace to see where hasPagePermission is called from?

    Of course, here’s a screenshot of the stack trace:
    clipboard-202507171438-byvuf.png

    If I see that correctly in DataHandler::deleteRecord() (line 5494), the issue is that $pageRecord is an empty array, when sys_redirects are stored on pid 0, thus no $pageRecord will be fetched.
    That ultimately results in the \RuntimeException when checking hasPagePermission()

    EDIT: sorry had to re-upload the file

  3. Gerrit Code Review pushed patch set 1 for main to change 90384 status Needs Feedback Under Review <span data-processor="relativetime" data-value="2025-08-13T22:31:26+00:00" > 08/13/25, 22:31 </span>

  4. Kay Röseler commented and changed attached clipboard-202509171557-91dzz.png attached clipboard-202509171558-v5nlw.png <span data-processor="relativetime" data-value="2025-09-17T13:58:59+00:00" > 09/17/25, 13:58 </span>

    Gerrit Code Review wrote in #note-6:
    > Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
    > It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/90384

    Hello Core Team,

    We have now also encountered this problem during an upgrade project. Unfortunately, the patch offered here is only a partial solution. Although it prevents the runtime exception, user groups are still unable to delete redirects that were created via the backend module (with PID = 0).

    clipboard-202509171558-v5nlw.png

    Will there be a solution for this soon? Perhaps something similar to the other ticket (Bug #106928) for metadata?

    Many thanks and best regards,
    Kay

    Translated with DeepL.com (free version)

  5. Moritz Ngo commented <span data-processor="relativetime" data-value="2025-11-13T15:25:54+00:00" > 11/13/25, 15:25 </span>

    I’m using the following hacky workaround so editors won’t get the error message:

    <?php
    
    declare(strict_types=1);
    
    namespace My\Namespace\Backend\DataHandling;
    
    use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
    use TYPO3\CMS\Backend\Utility\BackendUtility;
    use TYPO3\CMS\Core\DataHandling\DataHandler;
    use TYPO3\CMS\Core\Information\Typo3Version;
    use TYPO3\CMS\Core\Utility\GeneralUtility;
    
    /**
     * This workaround prevents an exception when editors try to delete sys_redirect records.
     * It allows the deletion to proceed without throwing an error.
     * see https://forge.typo3.org/issues/107103
     */
    #[Autoconfigure(public: true, shared: true)]
    class WorkaroundToPreventExceptionWhenTryingToDeleteSysRedirectRecord
    {
        /**
         * @param array<string, mixed> $recordToDelete
         */
        public function processCmdmap_deleteAction(
            string $table,
            int $uid,
            array $recordToDelete,
            bool &$recordWasDeleted,
            DataHandler $pObj,
        ): void {
            $version = GeneralUtility::makeInstance(Typo3Version::class);
            if ($version->getMajorVersion() < 13) {
                return;
            }
    
            if ($table !== 'sys_redirect') {
                return;
            }
    
            // No need to apply workaround for admin users
            /** @extensionScannerIgnoreLine #100454 #100963 */
            if ($pObj->BE_USER->isAdmin()) {
                return;
            }
    
            $pObj->deleteEl($table, $uid, true);
    
            $record = BackendUtility::getRecord($table, $uid, '*', '', false);
            if ($record === null) {
                $recordWasDeleted = true;
                return;
            }
    
            $recordWasDeleted = (bool)($record['deleted'] ?? false);
        }
    }

    You have to register the Hook in your ext_localconf.php:

    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = WorkaroundToPreventExceptionWhenTryingToDeleteSysRedirectRecord::class;
  6. Christian Kuhn commented <span data-processor="relativetime" data-value="2025-12-08T16:17:18+00:00" > 12/08/25, 16:17 </span>

    I think the main issue is here that the “casual” process_cmdmap / process_datamap DataHandler API can not circumvent access checks (which is an important security measure since these array are usually comming from GET/POST). One solution would be to call DH->deleteAction() with $noAccessCheck = true directly, which means routing not to tce_db for such commands, but through the controller. ext:recycler does a similar thing for instance.

    the reported exception is “just” a follow up issue, and changing this then surfaces the main issue as found by Kay already.

  7. Benni Mack commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-09-14T06:50:10+00:00" > 09/14/26, 06:50 </span>

    Applied in changeset commit:b5596c88a7c63569416b9e7b95505be8c65020b6.