[BUGFIX] Catch non existing directories for import syntax 51/58251/2
authorGeorg Ringer <georg.ringer@gmail.com>
Tue, 11 Sep 2018 17:27:05 +0000 (19:27 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Wed, 12 Sep 2018 06:54:25 +0000 (08:54 +0200)
Catch exceptions for non existing directories which are imported using
the @import syntax for TypoScript and return those as warning in the
template module.

Resolves: #86230
Releases: master
Change-Id: Ie4a6376407eeeaa7a717cb01ede5cabefa8a443f
Reviewed-on: https://review.typo3.org/58251
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php

index 6c980bd..1693473 100644 (file)
@@ -1002,16 +1002,20 @@ class TypoScriptParser
             // Used for the TypoScript comments
             $readableFilePrefix = $filename;
         } else {
-            // Apparently this is not a folder, so the restriction
-            // is the folder so we restrict into this folder
-            $finder->in(PathUtility::dirname($absoluteFileName));
-            if (!is_file($absoluteFileName)
-                && strpos(PathUtility::basename($absoluteFileName), '*') === false
-                && substr(PathUtility::basename($absoluteFileName), -11) !== '.typoscript') {
-                $absoluteFileName .= '*.typoscript';
+            try {
+                // Apparently this is not a folder, so the restriction
+                // is the folder so we restrict into this folder
+                $finder->in(PathUtility::dirname($absoluteFileName));
+                if (!is_file($absoluteFileName)
+                    && strpos(PathUtility::basename($absoluteFileName), '*') === false
+                    && substr(PathUtility::basename($absoluteFileName), -11) !== '.typoscript') {
+                    $absoluteFileName .= '*.typoscript';
+                }
+                $finder->name(PathUtility::basename($absoluteFileName));
+                $readableFilePrefix = PathUtility::dirname($filename);
+            } catch (\InvalidArgumentException $e) {
+                return self::typoscriptIncludeError($e->getMessage());
             }
-            $finder->name(PathUtility::basename($absoluteFileName));
-            $readableFilePrefix = PathUtility::dirname($filename);
         }
 
         foreach ($finder as $fileObject) {