From 16352fc10c1a6df5b67e495982477b0bd4507968 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 31 Oct 2014 10:27:17 +0100 Subject: [PATCH 1/9] Move Logger to the Application namespace fixes #7148 --- .../controllers/AuthenticationController.php | 2 +- application/controllers/DashboardController.php | 2 +- application/controllers/ErrorController.php | 2 +- application/controllers/FilterController.php | 2 +- application/controllers/ListController.php | 4 +--- application/controllers/StaticController.php | 2 +- .../forms/Config/General/LoggingConfigForm.php | 2 +- application/forms/PreferenceForm.php | 2 +- .../Icinga/Application/ApplicationBootstrap.php | 2 +- library/Icinga/Application/Cli.php | 2 +- .../Icinga/{Logger => Application}/Logger.php | 16 ++++++++-------- .../{ => Application}/Logger/LogWriter.php | 2 +- .../Logger/Writer/FileWriter.php | 6 +++--- .../Logger/Writer/SyslogWriter.php | 6 +++--- library/Icinga/Application/Modules/Manager.php | 2 +- library/Icinga/Application/Modules/Module.php | 2 +- library/Icinga/Application/Web.php | 2 +- library/Icinga/Authentication/AuthChain.php | 2 +- .../Authentication/Backend/LdapUserBackend.php | 2 +- library/Icinga/Authentication/Manager.php | 2 +- library/Icinga/Protocol/Ldap/Connection.php | 2 +- library/Icinga/Web/Hook.php | 2 +- library/Icinga/Web/Menu.php | 2 +- library/Icinga/Web/MenuRenderer.php | 2 +- library/Icinga/Web/Notification.php | 2 +- library/Icinga/Web/Session/PhpSession.php | 2 +- library/Icinga/Web/Widget/Chart/InlinePie.php | 2 +- .../controllers/CommandController.php | 2 +- .../Backend/Ido/Query/GroupsummaryQuery.php | 2 +- .../Monitoring/Backend/Ido/Query/IdoQuery.php | 2 +- .../Command/Transport/LocalCommandFile.php | 2 +- .../Command/Transport/RemoteCommandFile.php | 2 +- .../Icinga/Logger/Writer/StreamWriterTest.php | 4 ++-- 33 files changed, 45 insertions(+), 47 deletions(-) rename library/Icinga/{Logger => Application}/Logger.php (93%) rename library/Icinga/{ => Application}/Logger/LogWriter.php (92%) rename library/Icinga/{ => Application}/Logger/Writer/FileWriter.php (94%) rename library/Icinga/{ => Application}/Logger/Writer/SyslogWriter.php (92%) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 8b2bb3715..1d47a7d41 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -9,7 +9,7 @@ use Icinga\Web\Controller\ActionController; use Icinga\Form\Authentication\LoginForm; use Icinga\Authentication\AuthChain; use Icinga\Application\Config; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Exception\AuthenticationException; use Icinga\Exception\NotReadableError; use Icinga\Exception\ConfigurationError; diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index 4942f5cdb..db5978c19 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -3,7 +3,7 @@ // {{{ICINGA_LICENSE_HEADER}}} use Icinga\Web\Url; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Config\PreservingIniWriter; use Icinga\Application\Config as IcingaConfig; use Icinga\Web\Widget\Dashboard; diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index 074e2fdc2..23051bd9a 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -4,7 +4,7 @@ // namespace Icinga\Application\Controllers; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Web\Controller\ActionController; use Icinga\Application\Icinga; diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php index 2ffa869db..09e8f0368 100644 --- a/application/controllers/FilterController.php +++ b/application/controllers/FilterController.php @@ -4,7 +4,7 @@ use Icinga\Web\Controller\ActionController; use Icinga\Filter\Filter; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; /** * Application wide interface for filtering diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php index 004c52148..8f9a39e1b 100644 --- a/application/controllers/ListController.php +++ b/application/controllers/ListController.php @@ -5,9 +5,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Web\Hook; use Icinga\Web\Url; -use Icinga\Data\ResourceFactory; -use Icinga\Logger\Logger; -use Icinga\Logger\Writer\FileWriter; +use Icinga\Application\Logger; use Icinga\Protocol\File\FileReader; use \Zend_Controller_Action_Exception as ActionError; diff --git a/application/controllers/StaticController.php b/application/controllers/StaticController.php index c8b1d9b73..fc5f1354f 100644 --- a/application/controllers/StaticController.php +++ b/application/controllers/StaticController.php @@ -4,7 +4,7 @@ use Icinga\Web\Controller\ActionController; use Icinga\Application\Icinga; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Web\FileCache; use Zend_Controller_Action_Exception as ActionException; diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index 733c306b9..50b61d246 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -5,7 +5,7 @@ namespace Icinga\Form\Config\General; use Icinga\Application\Icinga; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Web\Form; use Icinga\Web\Form\Validator\WritablePathValidator; diff --git a/application/forms/PreferenceForm.php b/application/forms/PreferenceForm.php index 0b1ba9a9b..633e2183a 100644 --- a/application/forms/PreferenceForm.php +++ b/application/forms/PreferenceForm.php @@ -6,7 +6,7 @@ namespace Icinga\Form; use Exception; use DateTimeZone; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\User\Preferences; use Icinga\User\Preferences\PreferencesStore; use Icinga\Util\TimezoneDetect; diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 958642940..368c93a8f 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -11,7 +11,7 @@ use Icinga\Application\Modules\Manager as ModuleManager; use Icinga\Data\ResourceFactory; use Icinga\Exception\ConfigurationError; use Icinga\Exception\NotReadableError; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Util\DateTimeFactory; use Icinga\Util\Translator; use Icinga\Exception\IcingaException; diff --git a/library/Icinga/Application/Cli.php b/library/Icinga/Application/Cli.php index d329ce439..e82eaabbb 100644 --- a/library/Icinga/Application/Cli.php +++ b/library/Icinga/Application/Cli.php @@ -9,7 +9,7 @@ use Icinga\Application\ApplicationBootstrap; use Icinga\Cli\Params; use Icinga\Cli\Loader; use Icinga\Cli\Screen; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Application\Benchmark; use Icinga\Exception\ProgrammingError; use Zend_Config; diff --git a/library/Icinga/Logger/Logger.php b/library/Icinga/Application/Logger.php similarity index 93% rename from library/Icinga/Logger/Logger.php rename to library/Icinga/Application/Logger.php index a5458e498..cb06ef8c3 100644 --- a/library/Icinga/Logger/Logger.php +++ b/library/Icinga/Application/Logger.php @@ -2,13 +2,13 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Logger; +namespace Icinga\Application; use Exception; use Zend_Config; +use Icinga\Application\Logger\Writer\FileWriter; +use Icinga\Application\Logger\Writer\SyslogWriter; use Icinga\Exception\ConfigurationError; -use Icinga\Logger\Writer\FileWriter; -use Icinga\Logger\Writer\SyslogWriter; /** * Logger @@ -57,7 +57,7 @@ class Logger /** * Log writer * - * @var \Icinga\Logger\LogWriter + * @var \Icinga\Application\Logger\LogWriter */ protected $writer; @@ -133,12 +133,12 @@ class Logger * * @param Zend_Config $config The configuration to initialize the writer with * - * @return \Icinga\Logger\LogWriter The requested log writer - * @throws ConfigurationError If the requested writer cannot be found + * @return \Icinga\Application\Logger\LogWriter The requested log writer + * @throws ConfigurationError If the requested writer cannot be found */ protected function createWriter(Zend_Config $config) { - $class = 'Icinga\\Logger\\Writer\\' . ucfirst(strtolower($config->log)) . 'Writer'; + $class = 'Icinga\\Application\\Logger\\Writer\\' . ucfirst(strtolower($config->log)) . 'Writer'; if (! class_exists($class)) { throw new ConfigurationError( 'Cannot find log writer of type "%s"', @@ -258,7 +258,7 @@ class Logger /** * Get the log writer to use * - * @return \Icinga\Logger\LogWriter + * @return \Icinga\Application\Logger\LogWriter */ public function getWriter() { diff --git a/library/Icinga/Logger/LogWriter.php b/library/Icinga/Application/Logger/LogWriter.php similarity index 92% rename from library/Icinga/Logger/LogWriter.php rename to library/Icinga/Application/Logger/LogWriter.php index 3222e50be..370af35c1 100644 --- a/library/Icinga/Logger/LogWriter.php +++ b/library/Icinga/Application/Logger/LogWriter.php @@ -2,7 +2,7 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Logger; +namespace Icinga\Application\Logger; use Zend_Config; diff --git a/library/Icinga/Logger/Writer/FileWriter.php b/library/Icinga/Application/Logger/Writer/FileWriter.php similarity index 94% rename from library/Icinga/Logger/Writer/FileWriter.php rename to library/Icinga/Application/Logger/Writer/FileWriter.php index 527358e1c..220b9be79 100644 --- a/library/Icinga/Logger/Writer/FileWriter.php +++ b/library/Icinga/Application/Logger/Writer/FileWriter.php @@ -2,13 +2,13 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Logger\Writer; +namespace Icinga\Application\Logger\Writer; use Exception; use Zend_Config; +use Icinga\Application\Logger; +use Icinga\Application\Logger\LogWriter; use Icinga\Exception\ConfigurationError; -use Icinga\Logger\Logger; -use Icinga\Logger\LogWriter; use Icinga\Util\File; /** diff --git a/library/Icinga/Logger/Writer/SyslogWriter.php b/library/Icinga/Application/Logger/Writer/SyslogWriter.php similarity index 92% rename from library/Icinga/Logger/Writer/SyslogWriter.php rename to library/Icinga/Application/Logger/Writer/SyslogWriter.php index f67c618d2..9a5ac28e5 100644 --- a/library/Icinga/Logger/Writer/SyslogWriter.php +++ b/library/Icinga/Application/Logger/Writer/SyslogWriter.php @@ -2,11 +2,11 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Logger\Writer; +namespace Icinga\Application\Logger\Writer; use Zend_Config; -use Icinga\Logger\Logger; -use Icinga\Logger\LogWriter; +use Icinga\Application\Logger; +use Icinga\Application\Logger\LogWriter; /** * Log to the syslog service diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index 60c2ee85b..db6f0e527 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -6,7 +6,7 @@ namespace Icinga\Application\Modules; use Icinga\Application\ApplicationBootstrap; use Icinga\Application\Icinga; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Data\DataArray\ArrayDatasource; use Icinga\Data\SimpleQuery; use Icinga\Exception\ConfigurationError; diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index b1b051a6c..b97483f95 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -12,7 +12,7 @@ use Zend_Controller_Router_Route_Regex as RegexRoute; use Icinga\Application\ApplicationBootstrap; use Icinga\Application\Config; use Icinga\Application\Icinga; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Util\Translator; use Icinga\Web\Hook; use Icinga\Web\Menu; diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 89cad22ab..d43b1d34d 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -9,7 +9,7 @@ require_once __DIR__ . '/ApplicationBootstrap.php'; use Icinga\Authentication\Manager as AuthenticationManager; use Icinga\Exception\ConfigurationError; use Icinga\Exception\NotReadableError; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Util\TimezoneDetect; use Icinga\Web\Request; use Icinga\Web\Response; diff --git a/library/Icinga/Authentication/AuthChain.php b/library/Icinga/Authentication/AuthChain.php index 4ab87f7ae..12c7143bf 100644 --- a/library/Icinga/Authentication/AuthChain.php +++ b/library/Icinga/Authentication/AuthChain.php @@ -6,7 +6,7 @@ namespace Icinga\Authentication; use Iterator; use Zend_Config; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Exception\ConfigurationError; /** diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index 3ee3c17dd..b859dfb3d 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -4,7 +4,7 @@ namespace Icinga\Authentication\Backend; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\User; use Icinga\Authentication\UserBackend; use Icinga\Protocol\Ldap\Connection; diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index fa974546d..c7d03b16a 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -9,7 +9,7 @@ use Zend_Config; use Icinga\Application\Config; use Icinga\Exception\IcingaException; use Icinga\Exception\NotReadableError; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\User; use Icinga\User\Preferences; use Icinga\User\Preferences\PreferencesStore; diff --git a/library/Icinga/Protocol/Ldap/Connection.php b/library/Icinga/Protocol/Ldap/Connection.php index 6fa41e2aa..8f5c14c4f 100644 --- a/library/Icinga/Protocol/Ldap/Connection.php +++ b/library/Icinga/Protocol/Ldap/Connection.php @@ -7,7 +7,7 @@ namespace Icinga\Protocol\Ldap; use Icinga\Protocol\Ldap\Exception as LdapException; use Icinga\Application\Platform; use Icinga\Application\Config; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Zend_Config; /** diff --git a/library/Icinga/Web/Hook.php b/library/Icinga/Web/Hook.php index 36974fb5b..01d1e0e2c 100644 --- a/library/Icinga/Web/Hook.php +++ b/library/Icinga/Web/Hook.php @@ -5,7 +5,7 @@ namespace Icinga\Web; use Exception; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Exception\ProgrammingError; /** diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index 305cdd705..870c2f1f3 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -9,7 +9,7 @@ use RecursiveIterator; use Zend_Config; use Icinga\Application\Config; use Icinga\Application\Icinga; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Exception\ConfigurationError; use Icinga\Exception\ProgrammingError; use Icinga\Web\Url; diff --git a/library/Icinga/Web/MenuRenderer.php b/library/Icinga/Web/MenuRenderer.php index 2fbcedc01..bbd5c208d 100644 --- a/library/Icinga/Web/MenuRenderer.php +++ b/library/Icinga/Web/MenuRenderer.php @@ -6,7 +6,7 @@ namespace Icinga\Web; use Exception; use RecursiveIteratorIterator; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; /** * A renderer to draw a menu with its sub-menus using an unordered html list diff --git a/library/Icinga/Web/Notification.php b/library/Icinga/Web/Notification.php index 178a07e0a..c85dbcc13 100644 --- a/library/Icinga/Web/Notification.php +++ b/library/Icinga/Web/Notification.php @@ -6,7 +6,7 @@ namespace Icinga\Web; use Icinga\Exception\ProgrammingError; use Icinga\Application\Platform; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Web\Session; /** diff --git a/library/Icinga/Web/Session/PhpSession.php b/library/Icinga/Web/Session/PhpSession.php index 65f940a13..cb311cc4a 100644 --- a/library/Icinga/Web/Session/PhpSession.php +++ b/library/Icinga/Web/Session/PhpSession.php @@ -4,7 +4,7 @@ namespace Icinga\Web\Session; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Exception\ConfigurationError; /** diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php index 4b4409e78..d22923131 100644 --- a/library/Icinga/Web/Widget/Chart/InlinePie.php +++ b/library/Icinga/Web/Widget/Chart/InlinePie.php @@ -7,7 +7,7 @@ namespace Icinga\Web\Widget\Chart; use Icinga\Web\Widget\AbstractWidget; use Icinga\Web\Url; use Icinga\Util\Format; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; /** * A SVG-PieChart intended to be displayed as a small icon next to labels, to offer a better visualization of the diff --git a/modules/monitoring/application/controllers/CommandController.php b/modules/monitoring/application/controllers/CommandController.php index 1aae9de20..77a963d94 100644 --- a/modules/monitoring/application/controllers/CommandController.php +++ b/modules/monitoring/application/controllers/CommandController.php @@ -4,7 +4,7 @@ use Icinga\Application\Icinga; use Icinga\Application\Config; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Module\Monitoring\Form\Command\DisableNotificationWithExpireForm; use Icinga\Module\Monitoring\Form\Command\SingleArgumentCommandForm; use Icinga\Web\Form; diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php index ab1947f7e..5a6bce41f 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php @@ -4,7 +4,7 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Zend_Db_Select; class GroupSummaryQuery extends IdoQuery diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 06472b44d..c6dcbbeae 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -5,7 +5,7 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; use Icinga\Exception\IcingaException; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Data\Db\DbQuery; use Icinga\Exception\ProgrammingError; use Icinga\Application\Icinga; diff --git a/modules/monitoring/library/Monitoring/Command/Transport/LocalCommandFile.php b/modules/monitoring/library/Monitoring/Command/Transport/LocalCommandFile.php index c3133d469..73a2e5288 100644 --- a/modules/monitoring/library/Monitoring/Command/Transport/LocalCommandFile.php +++ b/modules/monitoring/library/Monitoring/Command/Transport/LocalCommandFile.php @@ -6,7 +6,7 @@ namespace Icinga\Module\Monitoring\Command\Transport; use Exception; use LogicException; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Module\Monitoring\Command\Exception\TransportException; use Icinga\Module\Monitoring\Command\IcingaCommand; use Icinga\Module\Monitoring\Command\Renderer\IcingaCommandFileCommandRenderer; diff --git a/modules/monitoring/library/Monitoring/Command/Transport/RemoteCommandFile.php b/modules/monitoring/library/Monitoring/Command/Transport/RemoteCommandFile.php index d22e2c863..0e447a4f3 100644 --- a/modules/monitoring/library/Monitoring/Command/Transport/RemoteCommandFile.php +++ b/modules/monitoring/library/Monitoring/Command/Transport/RemoteCommandFile.php @@ -5,7 +5,7 @@ namespace Icinga\Module\Monitoring\Command\Transport; use LogicException; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; use Icinga\Module\Monitoring\Command\Exception\TransportException; use Icinga\Module\Monitoring\Command\IcingaCommand; use Icinga\Module\Monitoring\Command\Renderer\IcingaCommandFileCommandRenderer; diff --git a/test/php/library/Icinga/Logger/Writer/StreamWriterTest.php b/test/php/library/Icinga/Logger/Writer/StreamWriterTest.php index 11fec9740..9dd43ae83 100644 --- a/test/php/library/Icinga/Logger/Writer/StreamWriterTest.php +++ b/test/php/library/Icinga/Logger/Writer/StreamWriterTest.php @@ -5,9 +5,9 @@ namespace Tests\Icinga\Logger\Writer; use Zend_Config; -use Icinga\Logger\Logger; +use Icinga\Application\Logger; +use Icinga\Application\Logger\Writer\FileWriter; use Icinga\Test\BaseTestCase; -use Icinga\Logger\Writer\FileWriter; class StreamWriterTest extends BaseTestCase { From b38e3affb9ab421ee2e65e4fd0f238e17d811209 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 31 Oct 2014 10:54:53 +0100 Subject: [PATCH 2/9] Move INI writer classes to the File namespace fixes #7150 --- .../controllers/DashboardController.php | 22 +-- application/forms/ConfigForm.php | 4 +- .../Icinga/{Config => File/Ini}/IniEditor.php | 2 +- .../Ini/IniWriter.php} | 9 +- .../User/Preferences/Store/IniStore.php | 8 +- .../Ini/IniWriterTest.php} | 132 +++++++++--------- 6 files changed, 88 insertions(+), 89 deletions(-) rename library/Icinga/{Config => File/Ini}/IniEditor.php (99%) rename library/Icinga/{Config/PreservingIniWriter.php => File/Ini/IniWriter.php} (97%) rename test/php/library/Icinga/{Config/PreservingIniWriterTest.php => File/Ini/IniWriterTest.php} (77%) diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php index db5978c19..0ae931c18 100644 --- a/application/controllers/DashboardController.php +++ b/application/controllers/DashboardController.php @@ -2,16 +2,16 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -use Icinga\Web\Url; +use Icinga\Application\Config; use Icinga\Application\Logger; -use Icinga\Config\PreservingIniWriter; -use Icinga\Application\Config as IcingaConfig; -use Icinga\Web\Widget\Dashboard; -use Icinga\Form\Dashboard\AddUrlForm; -use Icinga\Exception\NotReadableError; use Icinga\Exception\ConfigurationError; -use Icinga\Web\Controller\ActionController; use Icinga\Exception\IcingaException; +use Icinga\Exception\NotReadableError; +use Icinga\File\Ini\IniWriter; +use Icinga\Form\Dashboard\AddUrlForm; +use Icinga\Web\Controller\ActionController; +use Icinga\Web\Url; +use Icinga\Web\Widget\Dashboard; /** * Handle creation, removal and displaying of dashboards, panes and components @@ -36,7 +36,7 @@ class DashboardController extends ActionController { $dashboard = new Dashboard(); try { - $dashboardConfig = IcingaConfig::app($config); + $dashboardConfig = Config::app($config); if (count($dashboardConfig) === 0) { return null; } @@ -92,7 +92,7 @@ class DashboardController extends ActionController ltrim($form->getValue('url'), '/') ); - $configFile = IcingaConfig::app('dashboard/dashboard')->getConfigFile(); + $configFile = Config::app('dashboard/dashboard')->getConfigFile(); if ($this->writeConfiguration(new Zend_Config($dashboard->toArray()), $configFile)) { $this->redirectNow(Url::fromPath('dashboard', array('pane' => $form->getValue('pane')))); } else { @@ -125,7 +125,7 @@ class DashboardController extends ActionController $dashboard->activate($pane); } - $this->view->configPath = IcingaConfig::resolvePath(self::DEFAULT_CONFIG); + $this->view->configPath = Config::resolvePath(self::DEFAULT_CONFIG); if ($dashboard === null) { $this->view->title = 'Dashboard'; @@ -158,7 +158,7 @@ class DashboardController extends ActionController */ protected function writeConfiguration(Zend_Config $config, $target) { - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); try { $writer->write(); diff --git a/application/forms/ConfigForm.php b/application/forms/ConfigForm.php index 86790d618..d1f2ed1dd 100644 --- a/application/forms/ConfigForm.php +++ b/application/forms/ConfigForm.php @@ -7,7 +7,7 @@ namespace Icinga\Form; use Exception; use Icinga\Web\Form; use Icinga\Application\Config; -use Icinga\Config\PreservingIniWriter; +use Icinga\File\Ini\IniWriter; /** * Form base-class providing standard functionality for configuration forms @@ -43,7 +43,7 @@ class ConfigForm extends Form */ public function save() { - $writer = new PreservingIniWriter( + $writer = new IniWriter( array( 'config' => $this->config, 'filename' => $this->config->getConfigFile() diff --git a/library/Icinga/Config/IniEditor.php b/library/Icinga/File/Ini/IniEditor.php similarity index 99% rename from library/Icinga/Config/IniEditor.php rename to library/Icinga/File/Ini/IniEditor.php index 61639563e..6ee19fa74 100644 --- a/library/Icinga/Config/IniEditor.php +++ b/library/Icinga/File/Ini/IniEditor.php @@ -2,7 +2,7 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Config; +namespace Icinga\File\Ini; /** * Edit the sections and keys of an ini in-place diff --git a/library/Icinga/Config/PreservingIniWriter.php b/library/Icinga/File/Ini/IniWriter.php similarity index 97% rename from library/Icinga/Config/PreservingIniWriter.php rename to library/Icinga/File/Ini/IniWriter.php index 2cafd5416..7dc79034d 100644 --- a/library/Icinga/Config/PreservingIniWriter.php +++ b/library/Icinga/File/Ini/IniWriter.php @@ -2,17 +2,16 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -namespace Icinga\Config; +namespace Icinga\File\Ini; use Zend_Config; use Zend_Config_Ini; use Zend_Config_Writer_FileAbstract; -use Icinga\Config\IniEditor; /** - * A ini file adapter that respects the file structure and the comments of already existing ini files + * A INI file adapter that respects the file structure and the comments of already existing ini files */ -class PreservingIniWriter extends Zend_Config_Writer_FileAbstract +class IniWriter extends Zend_Config_Writer_FileAbstract { /** * Stores the options @@ -22,7 +21,7 @@ class PreservingIniWriter extends Zend_Config_Writer_FileAbstract protected $options; /** - * Create a new PreservingIniWriter + * Create a new INI writer * * @param array $options Supports all options of Zend_Config_Writer and additional * options for the internal IniEditor: diff --git a/library/Icinga/User/Preferences/Store/IniStore.php b/library/Icinga/User/Preferences/Store/IniStore.php index 1f01925c9..acffff223 100644 --- a/library/Icinga/User/Preferences/Store/IniStore.php +++ b/library/Icinga/User/Preferences/Store/IniStore.php @@ -5,12 +5,12 @@ namespace Icinga\User\Preferences\Store; use Zend_Config; -use Icinga\Util\File; -use Icinga\Config\PreservingIniWriter; use Icinga\Exception\NotReadableError; use Icinga\Exception\NotWritableError; +use Icinga\File\Ini\IniWriter; use Icinga\User\Preferences; use Icinga\User\Preferences\PreferencesStore; +use Icinga\Util\File; /** * Load and save user preferences from and to INI files @@ -34,7 +34,7 @@ class IniStore extends PreferencesStore /** * Writer which stores the preferences * - * @var PreservingIniWriter + * @var IniWriter */ protected $writer; @@ -114,7 +114,7 @@ class IniStore extends PreferencesStore ); } - $this->writer = new PreservingIniWriter( + $this->writer = new IniWriter( array( 'config' => new Zend_Config($this->preferences), 'filename' => $this->preferencesFile diff --git a/test/php/library/Icinga/Config/PreservingIniWriterTest.php b/test/php/library/Icinga/File/Ini/IniWriterTest.php similarity index 77% rename from test/php/library/Icinga/Config/PreservingIniWriterTest.php rename to test/php/library/Icinga/File/Ini/IniWriterTest.php index da7e9674d..0146ed009 100644 --- a/test/php/library/Icinga/Config/PreservingIniWriterTest.php +++ b/test/php/library/Icinga/File/Ini/IniWriterTest.php @@ -6,10 +6,10 @@ namespace Tests\Icinga\Config; use Zend_Config; use Zend_Config_Ini; +use Icinga\File\Ini\IniWriter; use Icinga\Test\BaseTestCase; -use Icinga\Config\PreservingIniWriter; -class PreservingIniWriterTest extends BaseTestCase +class IniWriterTest extends BaseTestCase { protected $tempFile; protected $tempFile2; @@ -34,22 +34,22 @@ class PreservingIniWriterTest extends BaseTestCase { $target = $this->writeConfigToTemporaryFile(''); $config = new Zend_Config(array('key' => 'value')); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); - $this->assertEquals('value', $newConfig->get('key'), 'PreservingIniWriter does not insert in empty files'); + $this->assertEquals('value', $newConfig->get('key'), 'IniWriter does not insert in empty files'); } public function testWhetherSimplePropertiesAreInsertedInExistingFiles() { $target = $this->writeConfigToTemporaryFile('key1 = "1"'); $config = new Zend_Config(array('key2' => '2')); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); - $this->assertEquals('2', $newConfig->get('key2'), 'PreservingIniWriter does not insert in existing files'); + $this->assertEquals('2', $newConfig->get('key2'), 'IniWriter does not insert in existing files'); } /** @@ -59,11 +59,11 @@ class PreservingIniWriterTest extends BaseTestCase { $target = $this->writeConfigToTemporaryFile('key = "value"'); $config = new Zend_Config(array('key' => 'eulav')); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); - $this->assertEquals('eulav', $newConfig->get('key'), 'PreservingIniWriter does not update simple properties'); + $this->assertEquals('eulav', $newConfig->get('key'), 'IniWriter does not update simple properties'); } /** @@ -73,30 +73,30 @@ class PreservingIniWriterTest extends BaseTestCase { $target = $this->writeConfigToTemporaryFile('key = "value"'); $config = new Zend_Config(array()); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); - $this->assertNull($newConfig->get('key'), 'PreservingIniWriter does not delete simple properties'); + $this->assertNull($newConfig->get('key'), 'IniWriter does not delete simple properties'); } public function testWhetherNestedPropertiesAreInserted() { $target = $this->writeConfigToTemporaryFile(''); $config = new Zend_Config(array('a' => array('b' => 'c'))); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertInstanceOf( '\Zend_Config', $newConfig->get('a'), - 'PreservingIniWriter does not insert nested properties' + 'IniWriter does not insert nested properties' ); $this->assertEquals( 'c', $newConfig->get('a')->get('b'), - 'PreservingIniWriter does not insert nested properties' + 'IniWriter does not insert nested properties' ); } @@ -107,19 +107,19 @@ class PreservingIniWriterTest extends BaseTestCase { $target = $this->writeConfigToTemporaryFile('a.b = "c"'); $config = new Zend_Config(array('a' => array('b' => 'cc'))); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertInstanceOf( '\Zend_Config', $newConfig->get('a'), - 'PreservingIniWriter does not update nested properties' + 'IniWriter does not update nested properties' ); $this->assertEquals( 'cc', $newConfig->get('a')->get('b'), - 'PreservingIniWriter does not update nested properties' + 'IniWriter does not update nested properties' ); } @@ -130,13 +130,13 @@ class PreservingIniWriterTest extends BaseTestCase { $target = $this->writeConfigToTemporaryFile('a.b = "c"'); $config = new Zend_Config(array()); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertNull( $newConfig->get('a'), - 'PreservingIniWriter does not delete nested properties' + 'IniWriter does not delete nested properties' ); } @@ -144,19 +144,19 @@ class PreservingIniWriterTest extends BaseTestCase { $target = $this->writeConfigToTemporaryFile(''); $config = new Zend_Config(array('section' => array('key' => 'value'))); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertInstanceOf( '\Zend_Config', $newConfig->get('section'), - 'PreservingIniWriter does not insert sections' + 'IniWriter does not insert sections' ); $this->assertEquals( 'value', $newConfig->get('section')->get('key'), - 'PreservingIniWriter does not insert simple section properties' + 'IniWriter does not insert simple section properties' ); } @@ -171,14 +171,14 @@ key = "value" EOD ); $config = new Zend_Config(array('section' => array('key' => 'eulav'))); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertEquals( 'eulav', $newConfig->get('section')->get('key'), - 'PreservingIniWriter does not update simple section properties' + 'IniWriter does not update simple section properties' ); } @@ -193,13 +193,13 @@ key = "value" EOD ); $config = new Zend_Config(array('section' => array())); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertNull( $newConfig->get('section')->get('key'), - 'PreservingIniWriter does not delete simple section properties' + 'IniWriter does not delete simple section properties' ); } @@ -207,24 +207,24 @@ EOD { $target = $this->writeConfigToTemporaryFile(''); $config = new Zend_Config(array('section' => array('a' => array('b' => 'c')))); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertInstanceOf( '\Zend_Config', $newConfig->get('section'), - 'PreservingIniWriter does not insert sections' + 'IniWriter does not insert sections' ); $this->assertInstanceOf( '\Zend_Config', $newConfig->get('section')->get('a'), - 'PreservingIniWriter does not insert nested section properties' + 'IniWriter does not insert nested section properties' ); $this->assertEquals( 'c', $newConfig->get('section')->get('a')->get('b'), - 'PreservingIniWriter does not insert nested section properties' + 'IniWriter does not insert nested section properties' ); } @@ -239,14 +239,14 @@ a.b = "c" EOD ); $config = new Zend_Config(array('section' => array('a' => array('b' => 'cc')))); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertEquals( 'cc', $newConfig->get('section')->get('a')->get('b'), - 'PreservingIniWriter does not update nested section properties' + 'IniWriter does not update nested section properties' ); } @@ -261,13 +261,13 @@ a.b = "c" EOD ); $config = new Zend_Config(array('section' => array())); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertNull( $newConfig->get('section')->get('a'), - 'PreservingIniWriter does not delete nested section properties' + 'IniWriter does not delete nested section properties' ); } @@ -281,29 +281,29 @@ EOD ) ); $config->setExtend('bar', 'foo'); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertInstanceOf( '\Zend_Config', $newConfig->get('foo'), - 'PreservingIniWriter does not insert extended sections' + 'IniWriter does not insert extended sections' ); $this->assertInstanceOf( '\Zend_Config', $newConfig->get('bar'), - 'PreservingIniWriter does not insert extending sections' + 'IniWriter does not insert extending sections' ); $this->assertEquals( '2', $newConfig->get('bar')->get('key2'), - 'PreservingIniWriter does not insert simple properties into extending sections' + 'IniWriter does not insert simple properties into extending sections' ); $this->assertEquals( '1', $newConfig->get('foo')->get('key1'), - 'PreservingIniWriter does not properly define extending sections' + 'IniWriter does not properly define extending sections' ); } @@ -327,14 +327,14 @@ EOD ) ); $config->setExtend('bar', 'foo'); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertEquals( '22', $newConfig->get('bar')->get('key2'), - 'PreservingIniWriter does not update simple properties of extending sections' + 'IniWriter does not update simple properties of extending sections' ); } @@ -358,13 +358,13 @@ EOD ) ); $config->setExtend('bar', 'foo'); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertNull( $newConfig->get('bar')->get('key2'), - 'PreservingIniWriter does not delete simple properties of extending sections' + 'IniWriter does not delete simple properties of extending sections' ); } @@ -378,34 +378,34 @@ EOD ) ); $config->setExtend('bar', 'foo'); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertInstanceOf( '\Zend_Config', $newConfig->get('foo'), - 'PreservingIniWriter does not insert extended sections' + 'IniWriter does not insert extended sections' ); $this->assertInstanceOf( '\Zend_Config', $newConfig->get('bar'), - 'PreservingIniWriter does not insert extending sections' + 'IniWriter does not insert extending sections' ); $this->assertInstanceOf( '\Zend_Config', $newConfig->get('bar')->get('d'), - 'PreservingIniWriter does not insert nested properties into extending sections' + 'IniWriter does not insert nested properties into extending sections' ); $this->assertEquals( 'f', $newConfig->get('bar')->get('d')->get('e'), - 'PreservingIniWriter does not insert nested properties into extending sections' + 'IniWriter does not insert nested properties into extending sections' ); $this->assertEquals( 'c', $newConfig->get('bar')->get('a')->get('b'), - 'PreservingIniWriter does not properly define extending sections with nested properties' + 'IniWriter does not properly define extending sections with nested properties' ); } @@ -429,14 +429,14 @@ EOD ) ); $config->setExtend('bar', 'foo'); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertEquals( 'ff', $newConfig->get('bar')->get('d')->get('e'), - 'PreservingIniWriter does not update nested properties of extending sections' + 'IniWriter does not update nested properties of extending sections' ); } @@ -460,13 +460,13 @@ EOD ) ); $config->setExtend('bar', 'foo'); - $writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); + $writer = new IniWriter(array('config' => $config, 'filename' => $target)); $writer->write(); $newConfig = new Zend_Config_Ini($target); $this->assertNull( $newConfig->get('bar')->get('d'), - 'PreservingIniWriter does not delete nested properties of extending sections' + 'IniWriter does not delete nested properties of extending sections' ); } @@ -504,7 +504,7 @@ key1 = "1" key2 = "2" EOD; $target = $this->writeConfigToTemporaryFile($config); - $writer = new PreservingIniWriter( + $writer = new IniWriter( array( 'config' => new Zend_Config( array( @@ -535,7 +535,7 @@ EOD; $this->assertEquals( trim($reverted), trim($writer->render()), - 'PreservingIniWriter does not preserve section and/or property order' + 'IniWriter does not preserve section and/or property order' ); } @@ -559,7 +559,7 @@ EOD; [one] EOD; $target = $this->writeConfigToTemporaryFile($config); - $writer = new PreservingIniWriter( + $writer = new IniWriter( array( 'config' => new Zend_Config( array( @@ -574,7 +574,7 @@ EOD; $this->assertEquals( trim($reverted), trim($writer->render()), - 'PreservingIniWriter does not preserve section and/or property order' + 'IniWriter does not preserve section and/or property order' ); } @@ -588,14 +588,14 @@ key = "value" ; boring comment EOD; $target = $this->writeConfigToTemporaryFile($config); - $writer = new PreservingIniWriter( + $writer = new IniWriter( array('config' => new Zend_Config(array('key' => 'value')), 'filename' => $target) ); $this->assertEquals( $config, $writer->render(), - 'PreservingIniWriter does not preserve comments on empty lines' + 'IniWriter does not preserve comments on empty lines' ); } @@ -608,7 +608,7 @@ key = "value" ; some comment for a small sized pro xxl = "very loooooooooooooooooooooong" ; my value is very lo... EOD; $target = $this->writeConfigToTemporaryFile($config); - $writer = new PreservingIniWriter( + $writer = new IniWriter( array( 'config' => new Zend_Config( array( @@ -625,7 +625,7 @@ EOD; $this->assertEquals( $config, $writer->render(), - 'PreservingIniWriter does not preserve comments on property lines' + 'IniWriter does not preserve comments on property lines' ); } @@ -637,14 +637,14 @@ EOD; key = "value" EOD; $target = $this->writeConfigToTemporaryFile($config); - $writer = new PreservingIniWriter( + $writer = new IniWriter( array('config' => new Zend_Config(array('section' => array('key' => 'value'))), 'filename' => $target) ); $this->assertEquals( $config, $writer->render(), - 'PreservingIniWriter does not preserve comments on empty section lines' + 'IniWriter does not preserve comments on empty section lines' ); } @@ -658,7 +658,7 @@ key = "value" ; some comment for a small sized pro xxl = "very loooooooooooooooooooooong" ; my value is very lo... EOD; $target = $this->writeConfigToTemporaryFile($config); - $writer = new PreservingIniWriter( + $writer = new IniWriter( array( 'config' => new Zend_Config( array( @@ -677,13 +677,13 @@ EOD; $this->assertEquals( $config, $writer->render(), - 'PreservingIniWriter does not preserve comments on property lines' + 'IniWriter does not preserve comments on property lines' ); } public function testKeyNormalization() { - $normalKeys = new PreservingIniWriter( + $normalKeys = new IniWriter( array ( 'config' => new Zend_Config(array ( 'foo' => 'bar', @@ -704,7 +704,7 @@ EOD; ); - $nestedKeys = new PreservingIniWriter( + $nestedKeys = new IniWriter( array ( 'config' => new Zend_Config(array ( 'foo' => 'bar', From f09548901721de535811497e29fe9f8474de0dd2 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Fri, 31 Oct 2014 11:34:48 +0100 Subject: [PATCH 3/9] Fix multiple contacts display in service and host detail pane fixes #7329 --- .../library/Monitoring/Object/MonitoredObject.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 3d3bde8dd..36b36710c 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -317,10 +317,12 @@ abstract class MonitoredObject 'contact_alias', 'contact_email', 'contact_pager', - )) - ->where('host_name', $this->host_name); + )); if ($this->type === self::TYPE_SERVICE) { + $contacts->where('service_host_name', $this->host_name); $contacts->where('service_description', $this->service_description); + } else { + $contacts->where('host_name', $this->host_name); } $this->contacts = $contacts->getQuery()->fetchAll(); return $this; From f25f4f06d802cab366767fd6e1a5cec97a0ea091 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 1 Nov 2014 01:11:12 +0100 Subject: [PATCH 4/9] js/loader: disable click handler block on refresh This used to be ways too slow when many elements where involved. Left the old code there as a reminder. In case we really need it we should use something faster like an overlay or so. --- public/js/icinga/loader.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index dca88c394..83a13326c 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -691,11 +691,12 @@ var $content = $('
' + content + '
'); // Disable all click events while rendering - $('*').click(function (event) { - event.stopImmediatePropagation(); - event.stopPropagation(); - event.preventDefault(); - }); + // (Disabling disabled, was ways too slow) + // $('*').click(function (event) { + // event.stopImmediatePropagation(); + // event.stopPropagation(); + // event.preventDefault(); + // }); $('.container', $container).each(function() { self.stopPendingRequestsFor($(this)); @@ -738,8 +739,8 @@ icinga.ui.initializeControls($container); icinga.ui.fixControls(); - // Re-enable all click events - $('*').off('click'); + // Re-enable all click events (disabled as of performance reasons) + // $('*').off('click'); }, /** From 6298d303c451a19280f9df502819622009cf2850 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 1 Nov 2014 01:12:59 +0100 Subject: [PATCH 5/9] js/loader: trigger 'beforerender' container event --- public/js/icinga/loader.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 83a13326c..7fbe8badc 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -672,6 +672,8 @@ } } + $container.trigger('beforerender'); + var discard = false; $.each(self.icinga.behaviors, function(name, behavior) { if (behavior.renderHook) { From 95f9bebdc5effb2f007902c11a6423b18753837a Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 1 Nov 2014 01:23:55 +0100 Subject: [PATCH 6/9] js/loader: support multi-container redirection Redirections to #!-separated URLs (multiple containers) should also work when not re-rendering the whole layout. --- public/js/icinga/loader.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 7fbe8badc..31a0d10a8 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -269,15 +269,24 @@ } } else { - if (req.$target.attr('id') === 'col2') { // TODO: multicol - if ($('#col1').data('icingaUrl') === redirect) { - icinga.ui.layout1col(); - req.$target = $('#col1'); - delete(this.requests['col2']); - } - } - this.loadUrl(redirect, req.$target); + if (redirect.match(/#!/)) { + var parts = redirect.split(/#!/); + icinga.ui.layout2col(); + this.loadUrl(parts.shift(), $('#col1')); + this.loadUrl(parts.shift(), $('#col2')); + } else { + + if (req.$target.attr('id') === 'col2') { // TODO: multicol + if ($('#col1').data('icingaUrl') === redirect) { + icinga.ui.layout1col(); + req.$target = $('#col1'); + delete(this.requests['col2']); + } + } + + this.loadUrl(redirect, req.$target); + } } return true; }, From 18bd49e636b7fb715f798b7b2bf0dc791199640c Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 1 Nov 2014 01:47:55 +0100 Subject: [PATCH 7/9] Monitoring/Object: re-add process_perfdata We would live better with unique column names on hosts and services * Got introduced in 6095e440 and removed in c0e34473 * This might be a canditate for a regression test, as only graphers (PNP) are using this columns right now * It makes IMO absolutely no sense to keep all those long column names in that object classes --- modules/monitoring/library/Monitoring/Object/Host.php | 3 ++- modules/monitoring/library/Monitoring/Object/Service.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 455d29980..483cb2bae 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -130,7 +130,8 @@ class Host extends MonitoredObject 'host_notes_url', 'host_modified_host_attributes', 'host_problem', - 'host_process_performance_data' + 'host_process_performance_data', + 'process_perfdata' => 'host_process_performance_data' )) ->where('host_name', $this->host); } diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 7a0812d8b..28d0338f2 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -191,6 +191,7 @@ class Service extends MonitoredObject 'service_flap_detection_enabled_changed', 'service_modified_service_attributes', 'service_process_performance_data', + 'process_perfdata' => 'service_process_performance_data', 'service_percent_state_change', 'service_host_name' )) From f9fee2df700228d5a8624afdc0701f4b90d9a8bf Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Tue, 4 Nov 2014 12:35:41 +0100 Subject: [PATCH 8/9] Do not interrupt authentication chain on invalid ldap connection infos Catch LdapExceptions and throw AuthenticationException to not interrupt authentication chain fixes #7497 --- .../Authentication/Backend/LdapUserBackend.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index b859dfb3d..662200180 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -68,8 +68,16 @@ class LdapUserBackend extends UserBackend */ public function assertAuthenticationPossible() { - $q = $this->conn->select()->from($this->userClass); - $result = $q->fetchRow(); + try { + $q = $this->conn->select()->from($this->userClass); + $result = $q->fetchRow(); + } catch (LdapException $e) { + throw new AuthenticationException( + 'Connection not possible: %s', + $e->getMessage() + ); + } + if (! isset($result)) { throw new AuthenticationException( 'No objects with objectClass="%s" in DN="%s" found.', @@ -158,7 +166,7 @@ class LdapUserBackend extends UserBackend } catch (AuthenticationException $e) { // Authentication not possible throw new AuthenticationException( - 'Authentication against backend "%s" not possible: ', + 'Authentication against backend "%s" not possible: %s', $this->getName(), $e ); From 45d3005f3c835923493b0016a8801eb82447cec5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 4 Nov 2014 13:20:41 +0100 Subject: [PATCH 9/9] Throw exceptions on PHP warnings Sometimes we miss PHP warnings because our layout overlays them. --- library/Icinga/Application/ApplicationBootstrap.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 368c93a8f..7d22eaafa 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -388,6 +388,7 @@ abstract class ApplicationBootstrap return false; // Continue with the normal error handler } switch($errno) { + case E_WARNING: case E_STRICT: throw new ErrorException($errstr, 0, $errno, $errfile, $errline); }