[BUGFIX] Ensure most site related exceptions are handled
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / FormDataProvider / SiteTcaInline.php
index 630771e..3f7e7b7 100644 (file)
@@ -23,6 +23,7 @@ use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
 use TYPO3\CMS\Backend\Form\InlineStackProcessor;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -47,7 +48,7 @@ class SiteTcaInline extends AbstractDatabaseRecordProvider implements FormDataPr
                 continue;
             }
             $childTableName = $fieldConfig['config']['foreign_table'] ?? '';
-            if (!in_array($childTableName, ['site_errorhandling', 'site_language', 'site_route'])) {
+            if (!in_array($childTableName, ['site_errorhandling', 'site_language', 'site_route', 'site_base_variant'], true)) {
                 throw new \RuntimeException('Inline relation to other tables not implemented', 1522494737);
             }
             $result['processedTca']['columns'][$fieldName]['children'] = [];
@@ -115,7 +116,11 @@ class SiteTcaInline extends AbstractDatabaseRecordProvider implements FormDataPr
         if ($result['command'] === 'edit') {
             $siteConfigurationForPageUid = (int)$result['databaseRow']['rootPageId'][0];
             $siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
-            $site = $siteFinder->getSiteByRootPageId($siteConfigurationForPageUid);
+            try {
+                $site = $siteFinder->getSiteByRootPageId($siteConfigurationForPageUid);
+            } catch (SiteNotFoundException $e) {
+                $site = null;
+            }
             $siteConfiguration = $site ? $site->getConfiguration() : [];
             if (is_array($siteConfiguration[$fieldName])) {
                 $connectedUids = array_keys($siteConfiguration[$fieldName]);