From 4578a5eb7a33b9c90598d2ea639baa7c3a8148f7 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Mon, 20 Jul 2009 03:04:08 +0000 Subject: [PATCH] block MDL-19398 Initialise all blocks on this page before output is started. --- lib/blocklib.php | 12 ++++++++++++ lib/pagelib.php | 1 + 2 files changed, 13 insertions(+) diff --git a/lib/blocklib.php b/lib/blocklib.php index c1289ca004..2cb56eb97d 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -660,6 +660,18 @@ class block_manager { return $results; } + /** + * Create all the bock instances for all the blocks that were loaded by + * load_blocks. This is used, for example, to ensure that all blocks get a + * chance to initialise themselves via the {@link block_base::specialize()} + * method, before any output is done. + */ + public function create_all_block_instances() { + foreach ($this->get_regions() as $region) { + $this->ensure_instances_exist($region); + } + } + /** * Return an array of content vars from a set of block instances * diff --git a/lib/pagelib.php b/lib/pagelib.php index bf19c141d8..4e00186161 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -880,6 +880,7 @@ class moodle_page { $this->_block_actions_done = true; redirect($this->url->out(false, array(), false)); } + $this->blocks->create_all_block_instances(); } // If maintenance mode is on, change the page header. -- 2.39.5