mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-81419 core: Ensure that frames exist before checking them
This commit is contained in:
parent
4da813d35e
commit
794c62db58
@ -385,11 +385,13 @@ function get_whoops(): ?\Whoops\Run {
|
||||
|
||||
// Append a custom handler to add some more information to the frames.
|
||||
$whoops->appendHandler(function ($exception, $inspector, $run) {
|
||||
// Moodle exceptions often have a link to the Moodle docs pages for them.
|
||||
// Add that to the first frame in the stack.
|
||||
$collection = $inspector->getFrames();
|
||||
|
||||
$isdebugging = str_ends_with($collection[1]->getFile(), '/lib/weblib.php');
|
||||
// Detect if the Whoops handler was immediately invoked by a call to `debugging()`.
|
||||
// If so, we remove the top frames in the collection to avoid showing the inner
|
||||
// workings of debugging, and the point that we trigger the error that is picked up by Whoops.
|
||||
$isdebugging = count($collection) > 2;
|
||||
$isdebugging = $isdebugging && str_ends_with($collection[1]->getFile(), '/lib/weblib.php');
|
||||
$isdebugging = $isdebugging && $collection[2]->getFunction() === 'debugging';
|
||||
|
||||
if ($isdebugging) {
|
||||
@ -398,6 +400,8 @@ function get_whoops(): ?\Whoops\Run {
|
||||
return array_search($frame, $remove) === false;
|
||||
});
|
||||
} else {
|
||||
// Moodle exceptions often have a link to the Moodle docs pages for them.
|
||||
// Add that to the first frame in the stack.
|
||||
$info = get_exception_info($exception);
|
||||
if ($info->moreinfourl) {
|
||||
$collection[0]->addComment("{$info->moreinfourl}", 'More info');
|
||||
|
Loading…
x
Reference in New Issue
Block a user