[TASK] Improve error output in TS if INCLUDE_TYPOSCRIPT file not found 16/35516/2
authorSimon Schaufelberger <simonschaufi@googlemail.com>
Thu, 19 Jun 2014 16:42:53 +0000 (18:42 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Tue, 16 Dec 2014 15:27:32 +0000 (16:27 +0100)
The TSOB should show if a file which should be included could not be found.

Due the fact that parts of the TypoScript parser are written with static
methods, the only way is to check the TypoScript lines for the string
"### ERROR".

Resolves: #17090
Releases: master, 6.2
Change-Id: I6679413e9ff7ca027e23e9b2d6927fd95f8f4595
Reviewed-on: http://review.typo3.org/35516
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php

index abc4b0f..76e5894 100644 (file)
@@ -13,8 +13,10 @@ namespace TYPO3\CMS\Core\TypoScript\Parser;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use \TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * The TypoScript parser
@@ -469,6 +471,9 @@ class TypoScriptParser {
                                                        $this->lastComment .= rtrim($line) . LF;
                                                }
                                        }
+                                       if (StringUtility::beginsWith($line, '### ERROR')) {
+                                               $this->error(substr($line, 11));
+                                       }
                                }
                        }
                        // Unset comment
@@ -814,7 +819,7 @@ class TypoScriptParser {
                                // css_styled_content if those have been included through f.e.
                                // <INCLUDE_TYPOSCRIPT: source="FILE:EXT:css_styled_content/static/setup.txt">
                                $filePointer = strtolower($filename);
-                               if (GeneralUtility::isFirstPartOfStr($filePointer, 'ext:')) {
+                               if (StringUtility::beginsWith($filePointer, 'ext:')) {
                                        $filePointerPathParts = explode('/', substr($filePointer, 4));
 
                                        // remove file part, determine whether to load setup or constants
@@ -876,7 +881,7 @@ class TypoScriptParser {
                        if (!GeneralUtility::verifyFilenameAgainstDenyPattern($absfilename)) {
                                $newString .= self::typoscriptIncludeError('File "' . $filename . '" was not included since it is not allowed due to fileDenyPattern.');
                        } elseif (!@file_exists($absfilename)) {
-                               $newString .= self::typoscriptIncludeError('File "' . $filename . '" was not was not found.');
+                               $newString .= self::typoscriptIncludeError('File "' . $filename . '" was not found.');
                        } else {
                                $includedFiles[] = $absfilename;
                                // check for includes in included text