diff --git a/library/Icinga/Data/Db/Query.php b/library/Icinga/Data/Db/Query.php index 0031a9987..3dead6476 100644 --- a/library/Icinga/Data/Db/Query.php +++ b/library/Icinga/Data/Db/Query.php @@ -80,6 +80,13 @@ class Query extends BaseQuery $this->baseQuery = $this->db->select(); } + public function __clone() + { + if ($this->baseQuery !== null) { + $this->baseQuery = clone $this->baseQuery; + } + } + /** * Return the raw base query * diff --git a/library/Icinga/Data/PivotTable.php b/library/Icinga/Data/PivotTable.php index fdf08dcba..4d102b636 100644 --- a/library/Icinga/Data/PivotTable.php +++ b/library/Icinga/Data/PivotTable.php @@ -9,10 +9,25 @@ use Icinga\Data\BaseQuery; class PivotTable { + /** + * The query to fetch as pivot table + * + * @var BaseQuery + */ protected $query; + /** + * The column to use for the x axis + * + * @var string + */ protected $xAxisColumn; + /** + * The column to use for the y axis + * + * @var string + */ protected $yAxisColumn; protected $limit; @@ -101,8 +116,8 @@ class PivotTable */ protected function fetchXAxis() { - $queryClass = get_class($this->query); - $query = new $queryClass($this->query->getDatasource(), array($this->xAxisColumn)); + $query = clone $this->query; + $query->setColumns(array($this->xAxisColumn)); return $query->fetchColumn(); } @@ -111,8 +126,8 @@ class PivotTable */ protected function fetchYAxis() { - $queryClass = get_class($this->query); - $query = new $queryClass($this->query->getDatasource(), array($this->yAxisColumn)); + $query = clone $this->query; + $query->setColumns(array($this->yAxisColumn)); return $query->fetchColumn(); } diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index e8ab18d84..ef378fab9 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -476,9 +476,8 @@ class Monitoring_ListController extends Controller $this->setupFilterControl($dataview, 'servicematrix'); $this->setupSortControl( array( - 'service_state' => 'Service status', - 'service_description' => 'Service description', - 'host_name' => 'Hostname' + 'host_name' => 'Hostname', + 'service_description' => 'Service description' ) );