MDL-30655 Blocks: Moving block to top of list can cause (harmless) PHP warnings
authorsam marshall <s.marshall@open.ac.uk>
Thu, 8 Dec 2011 12:36:55 +0000 (12:36 +0000)
committersam marshall <s.marshall@open.ac.uk>
Fri, 9 Dec 2011 17:45:23 +0000 (17:45 +0000)
lib/blocklib.php

index d5d1c3b..508b94c 100644 (file)
@@ -1467,8 +1467,10 @@ class block_manager {
         } else {
             $newweight = ceil($newweight);
             for ($weight = $bestgap - 1; $weight >= $newweight; $weight--) {
-                foreach ($usedweights[$weight] as $biid) {
-                    $this->reposition_block($biid, $newregion, $weight + 1);
+                if (array_key_exists($weight, $usedweights)) {
+                    foreach ($usedweights[$weight] as $biid) {
+                        $this->reposition_block($biid, $newregion, $weight + 1);
+                    }
                 }
             }
             $this->reposition_block($block->instance->id, $newregion, $newweight);