Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Aubry <mattab@users.noreply.github.com>2016-07-21 05:09:46 +0300
committerGitHub <noreply@github.com>2016-07-21 05:09:46 +0300
commitafd490ae730db7f75240289c203dde1abd2035dc (patch)
tree7751f29de812a6ccd0440ab7632866e7adbdbff5 /core/FrontController.php
parent870465c6041cfdc344e89fb7878357638bfad1c6 (diff)
When Piwik config file becomes un-readable, make it clear that the file still exists but is not readable (#10331)
* * In messages, make it more clear whether config file exists and/or is (not) readable * When the config file exists but is not readable, provide users the choice between making the file readable, or starting a fresh install * As long as Piwik is not installed, piwik.php should not return 500 when config file is not readable * Fixes #10283 * UI tests: updated message when config file is not found
Diffstat (limited to 'core/FrontController.php')
-rw-r--r--core/FrontController.php29
1 files changed, 23 insertions, 6 deletions
diff --git a/core/FrontController.php b/core/FrontController.php
index f394aaf4f7..31ef714b98 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -71,6 +71,28 @@ class FrontController extends Singleton
private $initialized = false;
/**
+ * @param $lastError
+ * @return mixed|void
+ * @throws AuthenticationFailedException
+ * @throws Exception
+ */
+ private static function generateSafeModeOutput($lastError)
+ {
+ Common::sendResponseCode(500);
+
+ $controller = FrontController::getInstance();
+ try {
+ $controller->init();
+ $message = $controller->dispatch('CorePluginsAdmin', 'safemode', array($lastError));
+ } catch(Exception $e) {
+ // may fail in safe mode (eg. global.ini.php not found)
+ $message = sprintf("Piwik encoutered an error: %s (which lead to: %s)", $lastError['message'], $e->getMessage());
+ }
+
+ return $message;
+ }
+
+ /**
* Executes the requested plugin controller method.
*
* @throws Exception|\Piwik\PluginDeactivatedException in case the plugin doesn't exist, the action doesn't exist,
@@ -179,12 +201,7 @@ class FrontController extends Singleton
{
$lastError = error_get_last();
if (!empty($lastError) && $lastError['type'] == E_ERROR) {
- Common::sendResponseCode(500);
-
- $controller = FrontController::getInstance();
- $controller->init();
- $message = $controller->dispatch('CorePluginsAdmin', 'safemode', array($lastError));
-
+ $message = self::generateSafeModeOutput($lastError);
echo $message;
}
}