diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2018-09-20 22:59:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-20 22:59:33 +0300 |
commit | 0fa962253f0dfa49a41840cc5cc3284085a27d46 (patch) | |
tree | 3832e45a96dbab60529c1e47252778aafcfba0ab /plugins/CorePluginsAdmin | |
parent | 40d68b9d36723468659819b731a33d4c9c365e89 (diff) |
Set backtrace on error object and check Piwik_ShouldPrintBackTraceWithMessage() (#13450)
* Set backtrace on error object and check Piwik_ShouldPrintBackTraceWithMessage() in controller instead of FrontController in case plugins decide to create their own safemode.
* Add backtrace to HTML safemode view too.
* Fixing test.
Diffstat (limited to 'plugins/CorePluginsAdmin')
-rw-r--r-- | plugins/CorePluginsAdmin/Controller.php | 9 | ||||
-rw-r--r-- | plugins/CorePluginsAdmin/templates/safemode.twig | 6 |
2 files changed, 11 insertions, 4 deletions
diff --git a/plugins/CorePluginsAdmin/Controller.php b/plugins/CorePluginsAdmin/Controller.php index e45182da73..df1be62318 100644 --- a/plugins/CorePluginsAdmin/Controller.php +++ b/plugins/CorePluginsAdmin/Controller.php @@ -316,7 +316,9 @@ class Controller extends Plugin\ControllerAdmin $errorMessage = $lastError['message']; - if (!empty($lastError['backtrace'])) { + if (!empty($lastError['backtrace']) + && \Piwik_ShouldPrintBackTraceWithMessage() + ) { $errorMessage .= $lastError['backtrace']; } @@ -333,6 +335,11 @@ class Controller extends Plugin\ControllerAdmin if (Common::isPhpCliMode()) { throw new Exception("Error: " . var_export($lastError, true)); } + + if (!\Piwik_ShouldPrintBackTraceWithMessage()) { + unset($lastError['backtrace']); + } + $view = new View('@CorePluginsAdmin/safemode'); $view->lastError = $lastError; $view->isAllowedToTroubleshootAsSuperUser = $this->isAllowedToTroubleshootAsSuperUser(); diff --git a/plugins/CorePluginsAdmin/templates/safemode.twig b/plugins/CorePluginsAdmin/templates/safemode.twig index 89edb5575c..923651f8d7 100644 --- a/plugins/CorePluginsAdmin/templates/safemode.twig +++ b/plugins/CorePluginsAdmin/templates/safemode.twig @@ -34,9 +34,9 @@ <p> The following error just broke Matomo{% if showVersion %} (v{{ piwikVersion }}){% endif %}: </p> - <pre>{{ lastError.message }}</pre> - <p>in</p> - <pre>{{ lastError.file }} line {{ lastError.line }}</pre> + <pre>{{ lastError.message }} +{% if lastError.backtrace is defined %}{{ lastError.backtrace }}{% else %}in {{ lastError.file }} line {{ lastError.line }}{% endif %} + </pre> <hr> <h3>Troubleshooting</h3> |