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:
Kumi 2024-11-14 16:46:32 +01:00
parent 741addc3c8
commit 8a4c7c9113
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -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();