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
|
||||
$urlObject = $urlProperty->getValue($PAGE);
|
||||
|
||||
// Now access the path property within the moodle_url object
|
||||
$urlReflection = new ReflectionClass($urlObject);
|
||||
$pathProperty = $urlReflection->getProperty('path');
|
||||
$pathProperty->setAccessible(true);
|
||||
if ($urlObject) {
|
||||
// Now access the path property within the moodle_url object
|
||||
$urlReflection = new ReflectionClass($urlObject);
|
||||
$pathProperty = $urlReflection->getProperty('path');
|
||||
$pathProperty->setAccessible(true);
|
||||
|
||||
// Get the value of the path property
|
||||
$pathValue = $pathProperty->getValue($urlObject);
|
||||
// Get the value of the path property
|
||||
$pathValue = $pathProperty->getValue($urlObject);
|
||||
|
||||
// All of this only to bypass a little bug
|
||||
if ($pathValue == '/course/modedit.php') {
|
||||
return;
|
||||
// All of this only to bypass a little bug
|
||||
if ($pathValue == '/course/modedit.php') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue