diff --git a/lib/blocklib.php b/lib/blocklib.php index 04740029c0b..5a159c75d05 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -992,21 +992,23 @@ class block_manager { // If there are any un-removable blocks that were not created - force them. $undeletable = $this->get_undeletable_block_types(); - foreach ($undeletable as $forced) { - if (empty($forced)) { - continue; - } - $found = false; - foreach ($this->get_regions() as $region) { - foreach($this->birecordsbyregion[$region] as $instance) { - if ($instance->blockname == $forced) { - $found = true; + if (!$this->fakeblocksonly) { + foreach ($undeletable as $forced) { + if (empty($forced)) { + continue; + } + $found = false; + foreach ($this->get_regions() as $region) { + foreach($this->birecordsbyregion[$region] as $instance) { + if ($instance->blockname == $forced) { + $found = true; + } } } - } - if (!$found) { - $this->add_block_required_by_theme($forced); - $missing = true; + if (!$found) { + $this->add_block_required_by_theme($forced); + $missing = true; + } } } @@ -1036,6 +1038,11 @@ class block_manager { return; } + // Never auto create blocks when we are showing fake blocks only. + if ($this->fakeblocksonly) { + return; + } + $systemcontext = context_system::instance(); $defaultregion = $this->get_default_region(); // Add a special system wide block instance only for themes that require it. diff --git a/lib/setuplib.php b/lib/setuplib.php index 852d68a32c4..3572a0c1736 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -1391,7 +1391,7 @@ function disable_output_buffering() { */ function redirect_if_major_upgrade_required() { global $CFG; - $lastmajordbchanges = 2016110600.00; + $lastmajordbchanges = 2016112200.01; if (empty($CFG->version) or (float)$CFG->version < $lastmajordbchanges or during_initial_install() or !empty($CFG->adminsetuppending)) { try { diff --git a/lib/tests/blocklib_test.php b/lib/tests/blocklib_test.php index a7be723750c..b396373ee77 100644 --- a/lib/tests/blocklib_test.php +++ b/lib/tests/blocklib_test.php @@ -566,6 +566,18 @@ class core_blocklib_testcase extends advanced_testcase { list($page, $blockmanager) = $this->get_a_page_and_block_manager(array($regionname), $context, 'page-type'); + + $blockmanager->show_only_fake_blocks(true); + $blockmanager->load_blocks(); + $blockmanager->create_all_block_instances(); + $blocks = $blockmanager->get_blocks_for_region($regionname); + $this->assertEmpty($blocks); + + $PAGE->reset_theme_and_output(); + list($page, $blockmanager) = $this->get_a_page_and_block_manager(array($regionname), + $context, 'page-type'); + + $blockmanager->show_only_fake_blocks(false); $blockmanager->load_blocks(); $blockmanager->create_all_block_instances(); $blocks = $blockmanager->get_blocks_for_region($regionname);