From 810b81b682d06118b8fcd2e6a0c704a8d482ad71 Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Thu, 21 Apr 2016 12:46:39 +0200 Subject: [PATCH] AbstractException.php: Exception should not use 'Store', if 'Store' can't be instantiated. --- .../qfq/qfq/exceptions/AbstractException.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/extension/qfq/qfq/exceptions/AbstractException.php b/extension/qfq/qfq/exceptions/AbstractException.php index c5c2d1720..acd1939be 100644 --- a/extension/qfq/qfq/exceptions/AbstractException.php +++ b/extension/qfq/qfq/exceptions/AbstractException.php @@ -9,6 +9,7 @@ namespace qfq; require_once(__DIR__ . '/../../qfq/store/Store.php'); +require_once(__DIR__ . '/UserFormException.php'); class AbstractException extends \Exception { @@ -25,7 +26,13 @@ class AbstractException extends \Exception { */ public function formatException() { $debug = ''; - $store = Store::getInstance(); + try { + // In a very early stage, it might be possible that Store can't be initialized: take care not to use it. + $store = Store::getInstance(); + } catch (UserFormException $e) { + $store = null; + } + $html = ''; $this->messageArray['File'] = $this->getFile(); @@ -33,8 +40,10 @@ class AbstractException extends \Exception { $this->messageArray['Message'] = $this->getMessage(); $this->messageArray['Code'] = $this->getCode(); $this->messageArray['Stacktrace'] = '<pre>' . $this->getTraceAsString() . '</pre>'; - $this->messageArray['Page Id'] = $store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); - $this->messageArray['Content Id'] = $store->getVar(TYPO3_TT_CONTENT_UID, STORE_TYPO3); + if ($store !== null) { + $this->messageArray['Page Id'] = $store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); + $this->messageArray['Content Id'] = $store->getVar(TYPO3_TT_CONTENT_UID, STORE_TYPO3); + } $html .= "Code: " . $this->messageArray['Code'] . "<br>"; $html .= "Message: " . Support::wrapTag("<strong>", $this->messageArray['Message']) . "</br>"; @@ -50,7 +59,7 @@ class AbstractException extends \Exception { $html = "<h2>Error</h2>" . Support::wrapTag('<p>', $html); $html = Support::wrapTag("<div class='warning'>", $html); - if ($store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes') { + if ($store !== null && $store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes') { // Layout $debug = '<tr bgcolor="#dddddd"><td colspan="2">Exception</td></tr>'; -- GitLab