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
20
lib.php
20
lib.php
|
@ -60,17 +60,19 @@ function mod_exp360_cm_info_dynamic(cm_info $cm)
|
||||||
// Get the value of _url property, which is a moodle_url object
|
// Get the value of _url property, which is a moodle_url object
|
||||||
$urlObject = $urlProperty->getValue($PAGE);
|
$urlObject = $urlProperty->getValue($PAGE);
|
||||||
|
|
||||||
// Now access the path property within the moodle_url object
|
if ($urlObject) {
|
||||||
$urlReflection = new ReflectionClass($urlObject);
|
// Now access the path property within the moodle_url object
|
||||||
$pathProperty = $urlReflection->getProperty('path');
|
$urlReflection = new ReflectionClass($urlObject);
|
||||||
$pathProperty->setAccessible(true);
|
$pathProperty = $urlReflection->getProperty('path');
|
||||||
|
$pathProperty->setAccessible(true);
|
||||||
|
|
||||||
// Get the value of the path property
|
// Get the value of the path property
|
||||||
$pathValue = $pathProperty->getValue($urlObject);
|
$pathValue = $pathProperty->getValue($urlObject);
|
||||||
|
|
||||||
// All of this only to bypass a little bug
|
// All of this only to bypass a little bug
|
||||||
if ($pathValue == '/course/modedit.php') {
|
if ($pathValue == '/course/modedit.php') {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue