Issue Feature Closed

#108346Not possible to save site-config with env-var based rootPageId

Rozbeh Chiryai Sharahi 11/27/25, 11:38 updated 03/31/26, 09:00

Description

Hello,

If a site config has a dynamic rootPageId (f.i. env(ROOT_PAGE_ID)) saving of config.yaml is no longer possible via the backend module.

`Existing config for site publikath-692837151d016185672059 not found`

This might be the case because the env variable is substituted after lookup via rootPageId.

Unless root-page-ids are hardcoded, backend module will not work.

Kind regards
Rozbeh Chiryai Sharahi

Reviews 5

History 825

  1. Garvin Hicking commented and changed status New Accepted <span data-processor="relativetime" data-value="2025-11-27T12:40:10+00:00" > 11/27/25, 12:40 </span>

    First off: I think we should support this use-case.

    The reason is that at several places we use the “raw” configuration page UID. And this will hold a value like '%env(PAGEUID)%' then, and not resolve to a real UID.

    There are calls to getRawConfigurationForSiteWithRootPageId in several FormEngine DataProviders like typo3/sysext/backend/Classes/Form/FormDataProvider/SiteDatabaseEditRow.php which also access the ‘vanillaUid’.

    I suppose if we very carefully pick the places where ‘rootPageUid’ is accessed from that raw result and replace them with ‘vanillaUid’ this could work. And the UID resolving then here:

    typo3/sysext/backend/Classes/Controller/SiteConfigurationController.php
    ->

        public function editAction(ServerRequestInterface $request): ResponseInterface
        {
    ...
            $formData = $this->formDataCompiler->compile($formDataCompilerInput, GeneralUtility::makeInstance(SiteConfigurationDataGroup::class));
    ...

    could use a better evaluation, and maybe this allows to make further code also fall in place.

    Looking forward to more investigation and your input, thanks for reporting :)
  2. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-11-27T12:49:49+00:00" > 11/27/25, 12:49 </span>

    This here allows to at least access and save the config. HOWEVER: It then saves the uid inside the config.yaml file, instead of the ‘%env(…)’ placeholder, so that must not happen, there must be another place adjusted as well before the persistance, to use the raw value again.

    (Also note: Editing the site will show the Page dropdown with an “INVALID VALUE” setting)

    diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteDatabaseEditRow.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteDatabaseEditRow.php
    index 552974850d2..b9d3d454093 100644
    --- a/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteDatabaseEditRow.php
    +++ b/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteDatabaseEditRow.php
    @@ -51,7 +51,7 @@ readonly class SiteDatabaseEditRow implements FormDataProviderInterface
             if ($tableName === 'site') {
                 $rootPageId = (int)$result['vanillaUid'];
                 $rowData = $this->getRawConfigurationForSiteWithRootPageId($rootPageId);
    -            $result['databaseRow']['uid'] = $rowData['rootPageId'];
    +            $result['databaseRow']['uid'] = $rootPageId;
                 $result['databaseRow']['identifier'] = $result['customData']['siteIdentifier'];
             } elseif (in_array($tableName, ['site_errorhandling', 'site_language', 'site_route', 'site_base_variant'], true)) {
                 $rootPageId = (int)($result['inlineTopMostParentUid'] ?? $result['inlineParentUid']);
    diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteTcaInline.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteTcaInline.php
    index 1d9785096ab..f0bd85b8b39 100644
    --- a/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteTcaInline.php
    +++ b/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteTcaInline.php
    @@ -121,7 +121,7 @@ class SiteTcaInline extends AbstractDatabaseRecordProvider implements FormDataPr
         {
             $connectedUids = [];
             if ($result['command'] === 'edit') {
    -            $siteConfigurationForPageUid = (int)$result['databaseRow']['rootPageId'][0];
    +            $siteConfigurationForPageUid = (int)($result['databaseRow']['rootPageId'][0] ?? $result['databaseRow']['uid']);
                 try {
                     $site = $this->siteFinder->getSiteByRootPageId($siteConfigurationForPageUid);
                 } catch (SiteNotFoundException $e) {
  3. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-11-27T13:21:16+00:00" > 11/27/25, 13:21 </span>

    (Note we also don’t seem to have some tests covering the env loading, editing, persisting cycle for site/xxx/config.yaml in a full suite. Only partially covered through some unit tests for YamlLoading and parts of Site Processing – I only found typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_package_initialization/Initialisation/Site/demo/config.yaml as an entry point to set this up. That’s used in typo3/sysext/core/Tests/Functional/Package/Event/PackageInitializationEventTest.php but that tests something completely different)

  4. Gerrit Code Review pushed patch set 1 for main to change 91925 status Accepted Under Review <span data-processor="relativetime" data-value="2025-11-28T05:51:50+00:00" > 11/28/25, 05:51 </span>

  5. Garvin Hicking commented <span data-processor="relativetime" data-value="2026-02-06T15:10:36+00:00" > 02/06/26, 15:10 </span>

    Steps to reproduce this problem with DDEV as an example, and a page UID 195 (the page needs to exist):

    1. Create a new site config (via GUI or via filesystem).

    2. Create an ENV variable in your setup webserver setup, like 'TYPO3_ROOT_PAGE_UID="195". In DDEV this can be done by editing .ddev/config.yaml and placing the code:

    web_environment:
        - TYPO3_ROOT_PAGE_UID=195

    3. Restart DDEV to apply the ENV variable

    4. Edit the sites/xxx/config.yaml file, set:

    base: 'https://%env(DDEV_HOSTNAME)%/your-demo'
    rootPageId: '%env(TYPO3_ROOT_PAGE_UID)%'
    websiteTitle: 'Breaking demo for page %env(TYPO3_ROOT_PAGE_UID)%'
    languages:
      -
        title: English
        enabled: true
        languageId: 0
        base: /
        locale: en_US.UTF-8
        navigationTitle: English
        flag: us
        typo3Language: default
        iso-639-1: en
        hreflang: en-US
        direction: ltr
        websiteTitle: ''

    5. Clear TYPO3 cache, enter site config, pick the created site

    6. Note that website title and base URI are shown with their %env(...)% entries in the input fields

    7. Also note that the root page id dropdown will complain about a “missing label” for the ENV entry

    8. Also note that your frontend site will work just fine, ENV vars are resolved/processed

    9. Now change something, like the website title. Save the site config.

    10. Boom, you’ll see an exception about a missing site identifier.

    11. Enter site config again and you’ll see warnings of what just happened.

    12. Check out config.yaml and note that the website title was not changed

    13. Take note that due to this, you are incapable to actually edit ANYTHING in the site config via GUI

  6. Rozbeh Chiryai Sharahi commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-03-10T14:15:09+00:00" > 03/10/26, 14:15 </span>

    Applied in changeset commit:1312dcbfd579bb2e59bc249a976af3cee21f9f21.