From 24f64e6d300a2b88428e5bb4210f0ca4a62ac5a5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 17 Sep 2013 11:24:05 +0200 Subject: [PATCH] Fix conflicts from rebase, using inet_aton with pgsql, PHP strict standards violations, CS compliance refs #4255 --- library/Icinga/Application/Modules/Module.php | 5 ++- library/Icinga/Data/Db/Query.php | 3 +- library/Icinga/Data/PivotTable.php | 3 +- library/Icinga/Data/QueryInterface.php | 1 - .../controllers/ListController.php | 43 ------------------- .../controllers/ShowController.php | 2 - .../Backend/Ido/Query/AbstractQuery.php | 4 +- .../Backend/Ido/Query/EventHistoryQuery.php | 1 + .../Backend/Ido/Query/NotificationQuery.php | 2 +- .../library/Monitoring/View/AbstractView.php | 3 +- .../Monitoring/View/StatehistoryView.php | 2 + .../Icinga/Protocol/Statusdat/QueryTest.php | 1 + 12 files changed, 17 insertions(+), 53 deletions(-) diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index 1bc88c84b..aa00f7b34 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -274,7 +274,10 @@ class Module $this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName, $moduleLibraryDir); if (is_dir($this->getFormDir())) { - $this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName. '\\Form', $this->getFormDir()); + $this->app->getLoader()->registerNamespace( + 'Icinga\\Module\\' . $moduleName. '\\Form', + $this->getFormDir() + ); } } diff --git a/library/Icinga/Data/Db/Query.php b/library/Icinga/Data/Db/Query.php index 1d0facd0a..7867d4b1e 100644 --- a/library/Icinga/Data/Db/Query.php +++ b/library/Icinga/Data/Db/Query.php @@ -66,7 +66,9 @@ class Query extends AbstractQuery protected function createQueryObjects() { + $this->beforeCreatingCountQuery(); $this->beforeCreatingSelectQuery(); + $this->selectQuery = clone($this->baseQuery); $this->selectQuery->columns($this->columns); if ($this->hasOrder()) { @@ -79,7 +81,6 @@ class Query extends AbstractQuery } } - $this->beforeCreatingCountQuery(); if ($this->uglySlowConservativeCount) { $query = clone($this->selectQuery); if ($this->maxCount === null) { diff --git a/library/Icinga/Data/PivotTable.php b/library/Icinga/Data/PivotTable.php index afd04c572..5399252c5 100644 --- a/library/Icinga/Data/PivotTable.php +++ b/library/Icinga/Data/PivotTable.php @@ -112,8 +112,7 @@ class PivotTable ->where($ycol, $listY) ->where($xcol, $listX) ->order($ycol) - ->order($xcol) - ; + ->order($xcol); $pivot = array(); $emptyrow = (object) array(); foreach ($this->query->listColumns() as $col) { diff --git a/library/Icinga/Data/QueryInterface.php b/library/Icinga/Data/QueryInterface.php index e49e9d796..815bbf93f 100644 --- a/library/Icinga/Data/QueryInterface.php +++ b/library/Icinga/Data/QueryInterface.php @@ -160,4 +160,3 @@ interface QueryInterface extends Countable */ public function paginate($limit = null, $page = null); } - diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 50e49b0d7..e64e5d51b 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -163,49 +163,6 @@ class Monitoring_ListController extends ActionController 'host_address' => 'Host Address', 'host_last_check' => 'Last Host Check' )); - - $this->inheritCurrentSortColumn(); - } - - /** - * Display hostgroup list - * - * @TODO Implement hostgroup overview (feature #4184) - */ - public function hostgroupsAction() - { - $this->view->hostgroups = $this->query('hostgroup', array( - 'hostgroup_name', - 'hostgroup_alias', - )); - } - - /** - * Display servicegroup list - * - * @TODO Implement servicegroup overview (feature #4185) - */ - public function servicegroupsAction() - { - $this->view->servicegroups = $this->backend->select() - ->from('servicegroup', array( - 'servicegroup_name', - 'servicegroup_alias', - )); - } - - /** - * Display contactgroups overview - * - * - */ - public function contactgroupsAction() - { - $this->view->contactgroups = $this->query('contactgroup', array( - 'contactgroup_name', - 'contactgroup_alias', ->>>>>>> Slight changes in the ListController... more tbd - )); } /** diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 9152ab737..1262d010d 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -199,7 +199,6 @@ class Monitoring_ShowController extends ActionController ->fetchPairs(); Benchmark::measure('Service action done'); $object = $this->view->object->prefetch(); - $this->prepareGrapherHook(); } /** @@ -300,7 +299,6 @@ class Monitoring_ShowController extends ActionController ->where('object_type', 'host') ->fetchPairs(); $this->view->object->prefetch(); - $this->prepareGrapherHook(); } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/AbstractQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/AbstractQuery.php index 604a0d361..114b883f0 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/AbstractQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/AbstractQuery.php @@ -56,6 +56,7 @@ abstract class AbstractQuery extends Query foreach ($this->columnMap as $table => & $columns) { foreach ($columns as $key => & $value) { $value = preg_replace('/ COLLATE .+$/', '', $value); + $value = preg_replace('/inet_aton\(([[:word:].]+)\)/i', '$1::inet - \'0.0.0.0\'', $value); } } } @@ -120,7 +121,8 @@ abstract class AbstractQuery extends Query protected function joinBaseTables() { - $table = array_shift(array_keys($this->columnMap)); + reset($this->columnMap); + $table = key($this->columnMap); $this->baseQuery = $this->db->select()->from( array($table => $this->prefix . $table), diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php index 7a2335d05..c11c8ac65 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/EventHistoryQuery.php @@ -2,6 +2,7 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; +use \Zend_Db_Select; use Icinga\Exception\ProgrammingError; class EventHistoryQuery extends AbstractQuery diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php index 4d5e8d811..ae4b2d94b 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php @@ -119,7 +119,7 @@ class NotificationQuery extends AbstractQuery array( 'cmd_m' => $this->prefix . 'contactnotificationmethods' ), - 'cmd_c.notification_id = cmd_m.contactnotification_id', + 'cmd_c.contactnotification_id = cmd_m.contactnotification_id', array() ); $this->baseQuery->join( diff --git a/modules/monitoring/library/Monitoring/View/AbstractView.php b/modules/monitoring/library/Monitoring/View/AbstractView.php index 6173e5fee..d5988c820 100644 --- a/modules/monitoring/library/Monitoring/View/AbstractView.php +++ b/modules/monitoring/library/Monitoring/View/AbstractView.php @@ -241,7 +241,8 @@ class AbstractView extends AbstractQuery if (empty($this->sortDefaults)) { return $this->availableColumns[0]; } else { - return array_shift(array_keys($this->sortDefaults)); + reset($this->sortDefaults); + return key($this->sortDefaults); } } diff --git a/modules/monitoring/library/Monitoring/View/StatehistoryView.php b/modules/monitoring/library/Monitoring/View/StatehistoryView.php index 386be2de8..0c696d042 100644 --- a/modules/monitoring/library/Monitoring/View/StatehistoryView.php +++ b/modules/monitoring/library/Monitoring/View/StatehistoryView.php @@ -2,6 +2,8 @@ namespace Icinga\Monitoring\View; +use Icinga\Module\Monitoring\View\AbstractView; + class StatehistoryView extends AbstractView { protected $availableColumns = array( diff --git a/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php b/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php index 1f6c554ab..44b4047bd 100755 --- a/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php +++ b/test/php/library/Icinga/Protocol/Statusdat/QueryTest.php @@ -1,6 +1,7 @@