From 70c46470fe428a49c6ea5ecdb6d54df90fefa8de Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Fri, 17 Jan 2014 10:45:23 +1300 Subject: [PATCH] MDL-43714 blocks: fixed notice when moving to an empty region --- lib/ajax/blocks.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ajax/blocks.php b/lib/ajax/blocks.php index ab2452587ad..e78b75657a3 100644 --- a/lib/ajax/blocks.php +++ b/lib/ajax/blocks.php @@ -88,9 +88,14 @@ switch ($action) { $bui_newweight = null; if ($bui_beforeid == 0) { - // Moving to very bottom - $last = end($instances); - $bui_newweight = $last->instance->weight + 1; + if (count($instances) === 0) { + // Moving the block into an empty region. Give it the default weight. + $bui_newweight = 0; + } else { + // Moving to very bottom. + $last = end($instances); + $bui_newweight = $last->instance->weight + 1; + } } else { // Moving somewhere $lastweight = 0;