fix: prevent null errors in dynamic URL path checks
Ensure the code verifies that the moodle_url object is not null before attempting to access its properties. This adjustment prevents potential errors when handling situations where the URL object might be missing, thus improving the robustness of the `mod_exp360_cm_info_dynamic` function.
This commit is contained in:
parent
741addc3c8
commit
8a4c7c9113
1 changed files with 11 additions and 9 deletions
2
lib.php
2
lib.php
|
@ -60,6 +60,7 @@ function mod_exp360_cm_info_dynamic(cm_info $cm)
|
|||
// Get the value of _url property, which is a moodle_url object
|
||||
$urlObject = $urlProperty->getValue($PAGE);
|
||||
|
||||
if ($urlObject) {
|
||||
// Now access the path property within the moodle_url object
|
||||
$urlReflection = new ReflectionClass($urlObject);
|
||||
$pathProperty = $urlReflection->getProperty('path');
|
||||
|
@ -73,6 +74,7 @@ function mod_exp360_cm_info_dynamic(cm_info $cm)
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$renderer = $PAGE->get_renderer('mod_exp360');
|
||||
$modals = $renderer->render_modals();
|
||||
|
|
Loading…
Reference in a new issue