[BUGFIX] Check query wizard always fails 98/43598/3
authorFrancois Suter <francois@typo3.org>
Sun, 27 Sep 2015 15:42:18 +0000 (17:42 +0200)
committerFrancois Suter <francois@typo3.org>
Sun, 27 Sep 2015 15:43:59 +0000 (17:43 +0200)
Due to a missing parameter when instantiating the query parser,
the check query wizard fails without error message.

The parameter is added and the error reporting is improved.

Resolves: #70136
Releases: 2.0
Change-Id: I1151a71a90821a8cc3d1e1833a3e6f7623006b39
Reviewed-on: http://review.typo3.org/43598
Reviewed-by: Francois Suter <francois@typo3.org>
Tested-by: Francois Suter <francois@typo3.org>
ChangeLog
Classes/Ajax/AjaxHandler.php

index 37e7309..a330c53 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-27 Francois Suter (Cobweb)  <typo3@cobweb.ch>
+
+       * Fixed crashing query check wizard, resolves #70136
+
 2015-06-09 Francois Suter (Cobweb)  <typo3@cobweb.ch>
 
        * Moved to namespaces, verified compatibility with TYPO3 CMS 7, resolves #67370
index 2b00786..27cee40 100644 (file)
@@ -49,8 +49,11 @@ class AjaxHandler {
                        // Get the query to parse from the GET/POST parameters
                        $query = GeneralUtility::_GP('query');
                        // Create an instance of the parser
+                       // NOTE: NULL is passed for the parent object as there's no controller in this context,
+                       // but that's a bit risky. Maybe extension "tesseract" could provide a dummy controller
+                       // (or some logic should be split: the query parser should not also be a query builder).
                        /** @var $parser \Tesseract\Dataquery\Parser\QueryParser */
-                       $parser = GeneralUtility::makeInstance('Tesseract\\Dataquery\\Parser\\QueryParser');
+                       $parser = GeneralUtility::makeInstance('Tesseract\\Dataquery\\Parser\\QueryParser', NULL);
                        // Clean up and prepare the query string
                        $query = $parser->prepareQueryString($query);
                        // Parse the query
@@ -87,7 +90,12 @@ class AjaxHandler {
                        $parsingSeverity = FlashMessage::ERROR;
                        $parsingTitle = $languageService->sL('LLL:EXT:dataquery/locallang.xml:query.failure');
                        $exceptionCode = $e->getCode();
+                       // Display "improved" exception message (if available)
                        $parsingMessage = $languageService->sL('LLL:EXT:dataquery/locallang.xml:query.exception-' . $exceptionCode);
+                       // If some unexpected exception occurred, display original message
+                       if (empty($parsingMessage)) {
+                               $parsingMessage = $e->getMessage();
+                       }
                }
                // Render parsing result as flash message
                /** @var $flashMessage FlashMessage */