MDL-70815 completion: Cast custom data to array
Since cm_info::customdata can be of any type, we need to cast it to an array first before checking for custom completion rules. Otherwise, an exception can be thrown (e.g. customdata has been set as an stdClass)
This commit is contained in:
committed by
Sara Arjona
parent
b535cf958a
commit
ad583bba25
@@ -1107,8 +1107,10 @@ class completion_info {
|
||||
|
||||
// Custom activity module completion data.
|
||||
|
||||
// Cast custom data to array before checking for custom completion rules.
|
||||
$customdata = (array)$cm->customdata;
|
||||
// Return early if the plugin does not define custom completion rules.
|
||||
if (empty($cm->customdata['customcompletionrules'])) {
|
||||
if (empty($customdata['customcompletionrules'])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -1120,7 +1122,7 @@ class completion_info {
|
||||
|
||||
/** @var activity_custom_completion $customcmcompletion */
|
||||
$customcmcompletion = new $cmcompletionclass($cm, $userid);
|
||||
foreach ($cm->customdata['customcompletionrules'] as $rule => $enabled) {
|
||||
foreach ($customdata['customcompletionrules'] as $rule => $enabled) {
|
||||
if (!$enabled) {
|
||||
// Skip inactive completion rules.
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user