From: stronk7 Date: Mon, 24 Apr 2006 15:01:35 +0000 (+0000) Subject: Avoided some notices when one block has been deleted from moodle/blocks X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f809df70ceb3cdd466d669806b7a60b6e45fe2cd;p=moodle.git Avoided some notices when one block has been deleted from moodle/blocks and from blocks admin page and their instances haven't been deleted. We should build some sort of check to do all the house-cleaning of "orphaned" blocks, perhaps each time we arrive to the blocks admin page. --- diff --git a/lib/blocklib.php b/lib/blocklib.php index 5ca1802ce6..34a5d6c4dd 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -264,6 +264,12 @@ function blocks_print_group(&$page, &$pageblocks, $position) { foreach($pageblocks[$position] as $instance) { $block = blocks_get_record($instance->blockid); + + if (empty($block)) { + // Block doesn't exist! We should delete this instance! + continue; + } + if(!$block->visible) { // Disabled by the admin continue; @@ -325,6 +331,11 @@ function blocks_preferred_width(&$instances) { continue; } + if (!array_key_exists($instance->blockid, $blocks)) { + // Block doesn't exist! We should delete this instance! + continue; + } + if(!$blocks[$instance->blockid]->visible) { continue; }