From 5715e97bce034891de857b8a7a21873982242d61 Mon Sep 17 00:00:00 2001 From: defacer Date: Fri, 12 Nov 2004 18:44:54 +0000 Subject: [PATCH] Fixed a warning which appears if you move a block to a position which doesn't currently have any blocks. --- lib/blocklib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/blocklib.php b/lib/blocklib.php index 96fa0ef421..7fbd3e6a99 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -366,7 +366,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid) // The block is the first one, so a move "up" probably means it changes position // Where is the instance going to be moved? $newpos = $page->blocks_move_position($instance, BLOCK_MOVE_UP); - $newweight = max(array_keys($pageblocks[$newpos])) + 1; + $newweight = (empty($pageblocks[$newpos]) ? 0 : max(array_keys($pageblocks[$newpos]))) + 1; blocks_execute_repositioning($instance, $newpos, $newweight); } @@ -395,7 +395,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid) // The block is the last one, so a move "down" probably means it changes position // Where is the instance going to be moved? $newpos = $page->blocks_move_position($instance, BLOCK_MOVE_DOWN); - $newweight = max(array_keys($pageblocks[$newpos])) + 1; + $newweight = (empty($pageblocks[$newpos]) ? 0 : max(array_keys($pageblocks[$newpos]))) + 1; blocks_execute_repositioning($instance, $newpos, $newweight); } @@ -422,7 +422,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid) // Where is the instance going to be moved? $newpos = $page->blocks_move_position($instance, BLOCK_MOVE_LEFT); - $newweight = max(array_keys($pageblocks[$newpos])) + 1; + $newweight = (empty($pageblocks[$newpos]) ? 0 : max(array_keys($pageblocks[$newpos]))) + 1; blocks_execute_repositioning($instance, $newpos, $newweight); break; @@ -433,7 +433,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid) // Where is the instance going to be moved? $newpos = $page->blocks_move_position($instance, BLOCK_MOVE_RIGHT); - $newweight = max(array_keys($pageblocks[$newpos])) + 1; + $newweight = (empty($pageblocks[$newpos]) ? 0 : max(array_keys($pageblocks[$newpos]))) + 1; blocks_execute_repositioning($instance, $newpos, $newweight); break; -- 2.39.5