mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
lib/blocklib: MDL-20146 - Don't mask errors as a way to ignore missing code files
Instead of simply ignoring all errors from blocks, allow the errors to be exposed and test if the file exists. The previous solution makes it very hard to debug problems with blocks and gives the 'white screen of death' even with debugging set as high as it can go. Also ensure that blocks without code are not added to the list of instances, as I assume was the intended behaviour.
This commit is contained in:
parent
88b49294ec
commit
d836aa4b4f
1 changed files with 12 additions and 3 deletions
|
@ -753,7 +753,9 @@ class block_manager {
|
||||||
protected function create_block_instances($birecords) {
|
protected function create_block_instances($birecords) {
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach ($birecords as $record) {
|
foreach ($birecords as $record) {
|
||||||
$results[] = block_instance($record->blockname, $record, $this->page);
|
if ($blockobject = block_instance($record->blockname, $record, $this->page)) {
|
||||||
|
$results[] = $blockobject;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
@ -1296,8 +1298,15 @@ function block_load_class($blockname) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once($CFG->dirroot.'/blocks/moodleblock.class.php');
|
$blockpath = $CFG->dirroot.'/blocks/'.$blockname.'/block_'.$blockname.'.php';
|
||||||
@include_once($CFG->dirroot.'/blocks/'.$blockname.'/block_'.$blockname.'.php'); // do not throw errors if block code not present
|
|
||||||
|
if (file_exists($blockpath)) {
|
||||||
|
require_once($CFG->dirroot.'/blocks/moodleblock.class.php');
|
||||||
|
include_once($blockpath);
|
||||||
|
}else{
|
||||||
|
debugging("$blockname code does not exist in $blockpath", DEBUG_DEVELOPER);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return class_exists($classname);
|
return class_exists($classname);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue