diff --git a/controller/main.php b/controller/main.php index 2d61fba6..ea3d9c30 100644 --- a/controller/main.php +++ b/controller/main.php @@ -83,6 +83,9 @@ class main /** @var int Allowed columns */ protected $allowed_columns; + /** @var bool Portal active flag */ + protected $portal_active = false; + /** * Constructor * NOTE: The parameters of this method must match in order and type with @@ -133,8 +136,17 @@ class main */ public function handle($columns = array()) { + // Do not run portal if it's already active + if ($this->portal_active) + { + return; + } + $this->controller_helper->run_initial_tasks(); + // Set portal active + $this->portal_active = true; + // Check if we should limit the columns to display $this->set_allowed_columns($columns); diff --git a/tests/mock/template.php b/tests/mock/template.php index 8806962f..36fc4caa 100644 --- a/tests/mock/template.php +++ b/tests/mock/template.php @@ -58,4 +58,9 @@ class template { $this->test_case->assertSame($expected, $this->data[$row]); } + + public function delete_var($key) + { + unset($this->data[$key]); + } } diff --git a/tests/unit/controller/main_test.php b/tests/unit/controller/main_test.php index 6eb1109f..69973fd0 100644 --- a/tests/unit/controller/main_test.php +++ b/tests/unit/controller/main_test.php @@ -91,4 +91,13 @@ class main_test extends \board3\portal\tests\testframework\database_test_case $this->assertNull($this->controller_main->handle(array('left' => 1))); $this->template->assert_same(true, 'S_PORTAL_ALL'); } + + public function test_display_all_pages_twice() + { + $this->assertNull($this->controller_main->handle(array('left' => 1))); + $this->template->assert_same(true, 'S_PORTAL_ALL'); + $this->template->delete_var('S_PORTAL_ALL'); + $this->assertNull($this->controller_main->handle(array('left' => 1))); + $this->template->assert_same(null, 'S_PORTAL_ALL'); + } }