Browse Source

fix bug on missing config files

Olivier Massot 4 years ago
parent
commit
5008649320
1 changed files with 14 additions and 7 deletions
  1. 14 7
      ot_admin/Classes/Controller/SiteController.php

+ 14 - 7
ot_admin/Classes/Controller/SiteController.php

@@ -1991,7 +1991,6 @@ class SiteController extends ActionController
      */
     protected function findConfigFileAndContentFor(int $rootUid): array
     {
-
         $configs_directory = $_ENV['TYPO3_PATH_APP'] . "/config/sites/";
         $candidates = array_filter(
                 scandir($configs_directory),
@@ -2002,10 +2001,14 @@ class SiteController extends ActionController
         foreach ($candidates as $subdir) {
             if (preg_match('/\.*_' . $rootUid . '$/', $subdir)) {
                 $filename = $configs_directory . $subdir . '/config.yaml';
-                $yamlConfig = Yaml::parseFile($filename);
+                try {
+                    $yamlConfig = Yaml::parseFile($filename);
 
-                if ($yamlConfig['rootPageId'] === $rootUid) {
-                    return [$filename, $yamlConfig];
+                    if ($yamlConfig['rootPageId'] === $rootUid) {
+                        return [$filename, $yamlConfig];
+                    }
+                } catch (\Symfony\Component\Yaml\Exception\ParseException $e) {
+                    continue;
                 }
             }
         }
@@ -2013,9 +2016,13 @@ class SiteController extends ActionController
         // it wasn't found the easy way, let's look to each file... :(
         foreach ($candidates as $subdir) {
             $filename = $configs_directory . $subdir . '/config.yaml';
-            $yamlConfig = Yaml::parseFile($filename);
-            if ($yamlConfig['rootPageId'] === $rootUid) {
-                return [$filename, $yamlConfig];
+            try {
+                $yamlConfig = Yaml::parseFile($filename);
+                if ($yamlConfig['rootPageId'] === $rootUid) {
+                    return [$filename, $yamlConfig];
+                }
+            } catch (\Symfony\Component\Yaml\Exception\ParseException $e) {
+                continue;
             }
         }