Avoided some notices when one block has been deleted from moodle/blocks
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user