]> git.mjollnir.org Git - moodle.git/commitdiff
Avoided some notices when one block has been deleted from moodle/blocks
authorstronk7 <stronk7>
Mon, 24 Apr 2006 15:01:35 +0000 (15:01 +0000)
committerstronk7 <stronk7>
Mon, 24 Apr 2006 15:01:35 +0000 (15:01 +0000)
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.

lib/blocklib.php

index 5ca1802ce654be7a23660b11648c96ccdbc2b9eb..34a5d6c4dd05ce45f7ca0350d0321d857811f78d 100644 (file)
@@ -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;
         }