[BUGFIX] Display detected fatal in extension check 81/26781/4
authorThomas Maroschik <tmaroschik@dfau.de>
Mon, 13 Jan 2014 11:16:39 +0000 (12:16 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 29 Jan 2014 19:04:37 +0000 (20:04 +0100)
In the installer fatals can happen during updates of
very outdated extensions. Many updates can lead to a
redirect to the extension check where the user gets
displayed a message that a fatal has been detected.
But the detected fatal error itself is not displayed.

This patch passes the error as url parameter to the
extension check and displays it there.

Fixes: #54943
Releases: 6.2
Change-Id: I111df5d5411015b21c4b2b5e9be3b83b311c8bc5
Reviewed-on: https://review.typo3.org/26781
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Thomas Maroschik
Reviewed-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Reviewed-by: Markus Klein
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/install/Classes/Controller/Action/AbstractAction.php
typo3/sysext/install/Classes/Controller/Action/ActionInterface.php
typo3/sysext/install/Classes/Controller/ToolController.php
typo3/sysext/install/Resources/Private/Partials/Action/Tool/ImportantActions/LastError.html [new file with mode: 0644]
typo3/sysext/install/Resources/Private/Templates/Action/Tool/LoadExtensions.html

index 39a816c..ad0eb8a 100644 (file)
@@ -63,6 +63,11 @@ abstract class AbstractAction {
         */
        protected $postValues = array();
 
+       /**
+        * @var array Contains the fatal error array of the last request when passed. Schema is the one returned by error_get_last()
+        */
+       protected $lastError = array();
+
        /**
         * @var array<\TYPO3\CMS\Install\Status\StatusInterface> Optional status message from controller
         */
@@ -103,6 +108,7 @@ abstract class AbstractAction {
                        ->assign('token', $this->token)
                        ->assign('context', $contextService->getContextString())
                        ->assign('contextService', $contextService)
+                       ->assign('lastError', $this->lastError)
                        ->assign('messages', $this->messages)
                        ->assign('typo3Version', TYPO3_version)
                        ->assign('siteName', $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'])
@@ -151,6 +157,15 @@ abstract class AbstractAction {
                $this->postValues = $postValues;
        }
 
+       /**
+        * Set the last error array as returned by error_get_last()
+        *
+        * @param array $lastError
+        */
+       public function setLastError(array $lastError) {
+               $this->lastError = $lastError;
+       }
+
        /**
         * Status messages from controller
         *
index 13dcd82..f6dd66c 100644 (file)
@@ -69,6 +69,13 @@ interface ActionInterface {
         */
        public function setPostValues(array $postValues);
 
+       /**
+        * Set the last error array as returned by error_get_last()
+        *
+        * @param array $lastError
+        */
+       public function setLastError(array $lastError);
+
        /**
         * Status messages from controller
         *
index 3043645..3ca861c 100644 (file)
@@ -129,6 +129,12 @@ class ToolController extends AbstractController {
                                        // Add action if specified
                                        $parameters[] = 'install[action]=loadExtensions';
 
+                                       // Add error to display a message what triggered the check
+                                       $errorEncoded = json_encode($error);
+                                       $parameters[] = 'install[lastError]=' . rawurlencode($errorEncoded);
+                                       // We do not use GeneralUtility here to be sure that hash generation works even if that class might not exist any more.
+                                       $parameters[] = 'install[lastErrorHash]=' . hash_hmac('sha1', $errorEncoded, $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . 'InstallToolError');
+
                                        $redirectLocation = 'Install.php?' . implode('&', $parameters);
 
                                        if (!headers_sent()) {
@@ -148,6 +154,23 @@ class ToolController extends AbstractController {
                });
        }
 
+       /**
+        * Get last error values of install tool.
+        *
+        * @return array
+        */
+       protected function getLastError() {
+               $getVars = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('install');
+               $lastError = array();
+               if (isset($getVars['lastError']) && isset($getVars['lastErrorHash']) && !empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
+                       $calculatedHash = hash_hmac('sha1', $getVars['lastError'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . 'InstallToolError');
+                       if ($calculatedHash === $getVars['lastErrorHash']) {
+                               $lastError = json_decode($getVars['lastError'], TRUE);
+                       }
+               }
+               return $lastError;
+       }
+
        /**
         * Call an action that needs authentication
         *
@@ -173,6 +196,7 @@ class ToolController extends AbstractController {
                $toolAction->setAction($action);
                $toolAction->setToken($this->generateTokenForAction($action));
                $toolAction->setPostValues($this->getPostValues());
+               $toolAction->setLastError($this->getLastError());
                $this->output($toolAction->handle());
        }
 }
diff --git a/typo3/sysext/install/Resources/Private/Partials/Action/Tool/ImportantActions/LastError.html b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/ImportantActions/LastError.html
new file mode 100644 (file)
index 0000000..fe1d4f8
--- /dev/null
@@ -0,0 +1,12 @@
+<f:if condition="{lastError}">
+       <div class="typo3-message message-warning">
+               <div class="header-container">
+                       <div class="message-header">
+                               <strong>Detected Fatal Error</strong>
+                       </div>
+                       <div class="message-body">
+                               {lastError.message} in {lastError.file} on line {lastError.line}
+                       </div>
+               </div>
+       </div>
+</f:if>
\ No newline at end of file
index f736a6c..09db9fc 100644 (file)
@@ -13,6 +13,8 @@
                are unloaded, you can restart the initial action to proceed your request.
        </p>
 
+       <f:render partial="Action/Tool/ImportantActions/LastError" arguments="{lastError: lastError}"/>
+
        <hr />
        <f:render partial="Action/Tool/ImportantActions/ExtensionCompatibilityTester" arguments="{_all}"/>
        <script type="text/javascript">