Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit f809df70ceb3cdd466d669806b7a60b6e45fe2cd 1 parent 77ea1a8
stronk7 authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/blocklib.php
11 lib/blocklib.php
View
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.