diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index 882ca3543..c6352a07c 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -45,6 +45,11 @@ Please consider an upgrade of your central Icinga system to a newer distribution [icinga.com](https://icinga.com/subscription/support-details/) provides an overview about currently supported distributions. +**Framework changes affecting third-party code** + +* Url parameter `view=compact` is now deprecated. `showCompact` should be used instead. + Details are in pull request [#4164](https://github.com/Icinga/icingaweb2/pull/4164). + ## Upgrading to Icinga Web 2 2.7.x **Breaking changes** diff --git a/library/Icinga/Web/Controller.php b/library/Icinga/Web/Controller.php index 7409dfa7e..dba085a58 100644 --- a/library/Icinga/Web/Controller.php +++ b/library/Icinga/Web/Controller.php @@ -235,7 +235,7 @@ class Controller extends ModuleActionController 'sort', // setupSortControl() 'dir', // setupSortControl() 'backend', // Framework - 'view', // Framework + 'showCompact', // Framework '_dev' // Framework ); diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index df6dce1a1..44ebbc512 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -129,7 +129,10 @@ class ActionController extends Zend_Controller_Action $this->_helper->layout()->showFullscreen = $request->getUrl()->shift('showFullscreen'); $this->_helper->layout()->moduleName = $moduleName; - $this->view->compact = $request->getParam('view') === 'compact'; + if ($request->getUrl()->getParam('view') === 'compact') { + $request->getUrl()->remove('view'); + $this->view->compact = true; + } if ($request->getUrl()->shift('showCompact')) { $this->view->compact = true; } diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php index 441819ce3..db7172283 100644 --- a/library/Icinga/Web/Url.php +++ b/library/Icinga/Web/Url.php @@ -828,6 +828,32 @@ class Url return $url; } + /** + * Return a copy of this url with only the given parameter(s) + * + * The argument can be either a single query parameter name or + * an array of parameter names to keep on on the query + * + * @param string|array $keyOrArrayOfKeys + * + * @return static + */ + public function onlyWith($keyOrArrayOfKeys) + { + if (! is_array($keyOrArrayOfKeys)) { + $keyOrArrayOfKeys = [$keyOrArrayOfKeys]; + } + + $url = clone $this; + foreach ($url->getParams()->toArray(false) as $key => $_) { + if (! in_array($key, $keyOrArrayOfKeys, true)) { + $url->remove($key); + } + } + + return $url; + } + public function __clone() { $this->params = clone $this->params; diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index b2fc563b9..89e1a0bbd 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -285,12 +285,10 @@ class FilterEditor extends AbstractWidget } } - $url = $this->url()->setQueryString( - $filter->toQueryString() - )->addParams($preserve); - if ($modify) { - $url->getParams()->add('modifyFilter'); - } + $url = Url::fromRequest()->onlyWith($this->preserveParams); + $urlParams = $url->getParams(); + $url->setQueryString($filter->toQueryString()); + $url->getParams()->mergeValues($urlParams->toArray(false)); $this->redirectNow($url); } diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 1e6ce6db1..251a45506 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -355,7 +355,7 @@ class ListController extends Controller $this->view->form = $form; $this->params - ->remove('view') + ->remove('showCompact') ->remove('format'); $orientation = $this->params->shift('vertical', 0) ? 'vertical' : 'horizontal'; /* diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 1d65de919..6c6559210 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -35,7 +35,7 @@ class ServicesController extends Controller $serviceList = new ServiceList($this->backend); $this->applyRestriction('monitoring/filter/objects', $serviceList); $serviceList->addFilter(Filter::fromQueryString( - (string) $this->params->without(array('service_problem', 'service_handled', 'view')) + (string) $this->params->without(array('service_problem', 'service_handled', 'showCompact')) )); $this->serviceList = $serviceList; $this->serviceList->setColumns(array( diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 4941922a9..4ea24dfd3 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -43,7 +43,7 @@