From 7be7335bdddfa44aeecbbebf20c318a9f21145d1 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Thu, 29 Aug 2013 13:34:36 +0200 Subject: [PATCH 1/2] Preferences: Fix error messages and convenience configuration refs #4648 --- config/preferences/.gitkeep | 0 config/preferences/KEEP.md | 1 - library/Icinga/Application/Web.php | 9 +++++++++ library/Icinga/User/Preferences/StoreFactory.php | 16 +++++++++++----- 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 config/preferences/.gitkeep delete mode 100755 config/preferences/KEEP.md diff --git a/config/preferences/.gitkeep b/config/preferences/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/config/preferences/KEEP.md b/config/preferences/KEEP.md deleted file mode 100755 index b4ffa9070..000000000 --- a/config/preferences/KEEP.md +++ /dev/null @@ -1 +0,0 @@ -# Keep this directory diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 703f32b3c..6498c7dff 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -249,6 +249,15 @@ class Web extends ApplicationBootstrap $preferences->attach($sessionStore); if ($this->getConfig()->preferences !== null) { + if (!$this->getConfig()->preferences->type) { + Logger::info( + 'Preferences provider configuration error. No type was omitted. For convenience we enable ' + . 'file based ini provider for you.' + ); + + $this->getConfig()->preferences->type = 'ini'; + } + $path = Config::resolvePath($this->getConfig()->preferences->configPath); if (is_dir($path) === false) { Logger::error( diff --git a/library/Icinga/User/Preferences/StoreFactory.php b/library/Icinga/User/Preferences/StoreFactory.php index 911212181..d4328e72b 100644 --- a/library/Icinga/User/Preferences/StoreFactory.php +++ b/library/Icinga/User/Preferences/StoreFactory.php @@ -28,11 +28,12 @@ namespace Icinga\User\Preferences; -use Icinga\User; -use Icinga\Exception\ProgrammingError; -use \Icinga\Application\DbAdapterFactory; use \Zend_Config; use \Zend_Db; +use \Icinga\User; +use \Icinga\Exception\ProgrammingError; +use \Icinga\Application\DbAdapterFactory; +use Icinga\Application\Logger; /** * Create preference stores from zend config @@ -66,7 +67,10 @@ final class StoreFactory $store = new $class(); if (!$store instanceof FlushObserverInterface) { - throw new ProgrammingError('Not instance of FlushObserverInterface: '. $class); + throw new ProgrammingError( + 'Preferences StoreFactory could not create provider (class ' . $class . '). ' + . 'Class is not instance of FlushObserverInterface.' + ); } $items = $config->toArray(); @@ -88,6 +92,8 @@ final class StoreFactory return $store; } - throw new ProgrammingError('Could not instantiate class: '. $class); + throw new ProgrammingError( + 'Preferences StoreFactory could not create provider (class ' . $class . '). Class not found.' + ); } } From a82abbe2f61cb5872b94f079f932c357b1135fe6 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 29 Aug 2013 14:40:33 +0200 Subject: [PATCH 2/2] Fix misplaced/redundant imports refs #4648 --- library/Icinga/Application/Web.php | 2 +- library/Icinga/User/Preferences/StoreFactory.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 6498c7dff..225cedf5f 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -30,13 +30,13 @@ namespace Icinga\Application; use \Exception; use \Zend_Layout; -use \Zend_Config; use \Zend_Paginator; use \Zend_View_Helper_PaginationControl; use \Zend_Controller_Action_HelperBroker; use \Zend_Controller_Router_Route; use \Zend_Controller_Action_Helper_ViewRenderer; use \Zend_Controller_Front; +use \Icinga\Application\Logger; use \Icinga\Authentication\Manager as AuthenticationManager; use \Icinga\Exception\ConfigurationError; use \Icinga\User\Preferences; diff --git a/library/Icinga/User/Preferences/StoreFactory.php b/library/Icinga/User/Preferences/StoreFactory.php index d4328e72b..fa2fa635e 100644 --- a/library/Icinga/User/Preferences/StoreFactory.php +++ b/library/Icinga/User/Preferences/StoreFactory.php @@ -29,11 +29,9 @@ namespace Icinga\User\Preferences; use \Zend_Config; -use \Zend_Db; use \Icinga\User; use \Icinga\Exception\ProgrammingError; use \Icinga\Application\DbAdapterFactory; -use Icinga\Application\Logger; /** * Create preference stores from zend config