fix: prevent null PAGE error in path reflection

Added a null check for the $PAGE variable before attempting to access its protected properties via reflection. This ensures the function safely bypasses a known bug related to path handling without encountering a null reference error. Prevents potential errors during dynamic module info processing.
This commit is contained in:
Kumi 2024-11-14 16:44:09 +01:00
parent 18cbc156dc
commit 8be9310c36
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -51,6 +51,7 @@ function mod_exp360_cm_info_dynamic(cm_info $cm)
return;
}
if ($PAGE) {
// Create a reflection of $PATH so we can access protected properties
$reflection = new ReflectionClass($PAGE);
$urlProperty = $reflection->getProperty('_url');
@ -71,6 +72,7 @@ function mod_exp360_cm_info_dynamic(cm_info $cm)
if ($pathValue == '/course/modedit.php') {
return;
}
}
$renderer = $PAGE->get_renderer('mod_exp360');
$modals = $renderer->render_modals();