From accbd9d8473198f666b80f05613d26ae0d698ac7 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 7 Dec 2020 16:01:57 +0100 Subject: [PATCH] ApplicationStateController: Initalize `$autorefreshInterval` Instead of defining it with the setter. This prevents the user's preferences from having an effect on this route. --- .../ApplicationStateController.php | 6 ++---- .../Web/Controller/ActionController.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/application/controllers/ApplicationStateController.php b/application/controllers/ApplicationStateController.php index e04b70679..205518401 100644 --- a/application/controllers/ApplicationStateController.php +++ b/application/controllers/ApplicationStateController.php @@ -17,6 +17,8 @@ class ApplicationStateController extends Controller { protected $requiresAuthentication = false; + protected $autorefreshInterval = 60; + public function init() { $this->_helper->layout->disableLayout(); @@ -63,8 +65,6 @@ class ApplicationStateController extends Controller } } } - - $this->setAutorefreshInterval(60, true); } public function summaryAction() @@ -72,8 +72,6 @@ class ApplicationStateController extends Controller if ($this->Auth()->isAuthenticated()) { $this->getResponse()->setBody((string) Widget::create('ApplicationStateMessages')); } - - $this->setAutorefreshInterval(60, true); } public function acknowledgeMessageAction() diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 039f51db3..4ec2ddebb 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -64,6 +64,13 @@ class ActionController extends Zend_Controller_Action */ protected $moduleName; + /** + * A page's automatic refresh interval + * + * The initial value will not be subject to a user's preferences. + * + * @var int + */ protected $autorefreshInterval; protected $reloadCss = false; @@ -341,6 +348,18 @@ class ActionController extends Zend_Controller_Action } } + /** + * Set the interval (in seconds) at which the page should automatically refresh + * + * This may be adjusted based on the user's preferences. The result could be a + * lower or higher rate of the page's automatic refresh. If this is not desired, + * the only way to bypass this is to initialize the {@see ActionController::$autorefreshInterval} + * property or to set the `autorefreshInterval` property of the layout directly. + * + * @param int $interval + * + * @return $this + */ public function setAutorefreshInterval($interval) { if (! is_int($interval) || $interval < 1) {