Skip to content

Commit

Permalink
Fix for bug 2377:
Browse files Browse the repository at this point in the history
Make it more difficult for instances with invalid blockid to be added to
mdl_block_instance. This could result in warnings, although nothing more
serious than that.

Credits to Eloy and especially Dan Marsden for reporting and providing info.
  • Loading branch information
defacer committed Jan 17, 2005
1 parent 8dd3a58 commit 3cacefd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/blocklib.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid)
// Add a new instance of this block, if allowed
$block = blocks_get_record($blockid);

if(!$block->visible) {
// Only allow adding if the block is enabled
if(empty($block) || !$block->visible) {
// Only allow adding if the block exists and is enabled
return false;
}

Expand Down Expand Up @@ -589,8 +589,12 @@ function blocks_repopulate_page($page) {
$newinstance->weight = $weight;
$newinstance->visible = 1;
$newinstance->configdata = '';
insert_record('block_instance', $newinstance);
++$weight;

if(!empty($newinstance->blockid)) {
// Only add block if it was recognized
insert_record('block_instance', $newinstance);
++$weight;
}
}
}

Expand Down

0 comments on commit 3cacefd

Please sign in to comment.