From 3850551e56fe5881b9e1eb75dbd3cf4ea2907ca7 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli <matthieu@mnapoli.fr> Date: Wed, 11 Mar 2015 09:41:04 +1300 Subject: [PATCH] Fixes #7356 Do not catch and silence exceptions blindly --- core/Config.php | 3 ++- core/Config/ConfigNotFoundException.php | 16 ++++++++++++++++ core/Console.php | 6 +++--- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 core/Config/ConfigNotFoundException.php diff --git a/core/Config.php b/core/Config.php index e28f581ea8..f0b5c3ed26 100644 --- a/core/Config.php +++ b/core/Config.php @@ -10,6 +10,7 @@ namespace Piwik; use Exception; +use Piwik\Config\ConfigNotFoundException; use Piwik\Ini\IniReader; use Piwik\Ini\IniReadingException; use Piwik\Ini\IniWriter; @@ -370,7 +371,7 @@ class Config extends Singleton public function checkLocalConfigFound() { if (!$this->existsLocalConfig()) { - throw new Exception(Piwik::translate('General_ExceptionConfigurationFileNotFound', array($this->pathLocal))); + throw new ConfigNotFoundException(Piwik::translate('General_ExceptionConfigurationFileNotFound', array($this->pathLocal))); } } diff --git a/core/Config/ConfigNotFoundException.php b/core/Config/ConfigNotFoundException.php new file mode 100644 index 0000000000..5860367ba7 --- /dev/null +++ b/core/Config/ConfigNotFoundException.php @@ -0,0 +1,16 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Config; + +/** + * Exception thrown when the config file doesn't exist. + */ +class ConfigNotFoundException extends \Exception +{ +} diff --git a/core/Console.php b/core/Console.php index 02e5f86871..fac27d8036 100644 --- a/core/Console.php +++ b/core/Console.php @@ -8,6 +8,7 @@ */ namespace Piwik; +use Piwik\Config\ConfigNotFoundException; use Piwik\Container\StaticContainer; use Piwik\Plugin\Manager as PluginManager; use Symfony\Bridge\Monolog\Handler\ConsoleHandler; @@ -43,10 +44,9 @@ class Console extends Application try { self::initPlugins(); - } catch(\Exception $e) { + } catch (ConfigNotFoundException $e) { // Piwik not installed yet, no config file? - - Log::debug("Could not initialize plugins: " . $e->getMessage() . "\n" . $e->getTraceAsString()); + Log::warning($e->getMessage()); } $commands = $this->getAvailableCommands(); -- GitLab