From 5d84c4e907838c93e54d8f3dff7d103c27fa96bf Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Tue, 10 Oct 2023 09:07:32 +0200 Subject: [PATCH] Prevent dynamic property access on classes for PHP 8.2 --- workflowoverview.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/workflowoverview.php b/workflowoverview.php index f89e0afd..16a4d09a 100644 --- a/workflowoverview.php +++ b/workflowoverview.php @@ -97,11 +97,14 @@ $displaytotaltriggered = !empty($triggers); } +$displaytriggers = []; +$displaysteps = []; + foreach ($triggers as $trigger) { // The array from the DB Function uses ids as keys. // Mustache cannot handle arrays which have other keys therefore a new array is build. // FUTURE: Nice to have Icon for each subplugin. - + $trigger = (object)(array) $trigger; // Cast to normal object to be able to set dynamic properties. $actionmenu = new action_menu([ new action_menu_link_secondary( new moodle_url(urls::EDIT_ELEMENT, ['type' => settings_type::TRIGGER, 'elementid' => $trigger->id]), @@ -123,9 +126,11 @@ $trigger->excludedcourses = $amounts[$trigger->sortindex]->excluded; } } + $displaytriggers[] = $trigger; } foreach ($steps as $step) { + $step = (object)(array) $step; // Cast to normal object to be able to set dynamic properties. $ncourses = $DB->count_records('tool_lifecycle_process', array('stepindex' => $step->sortindex, 'workflowid' => $workflowid)); $step->numberofcourses = $ncourses; @@ -159,6 +164,7 @@ } } $step->actionmenu = $OUTPUT->render($actionmenu); + $displaysteps[] = $step; } $arrayofcourses = array(); @@ -184,9 +190,9 @@ 'rollbackdelay' => format_time($workflow->rollbackdelay), 'finishdelay' => format_time($workflow->finishdelay), 'delayglobally' => $workflow->delayforallworkflows, - 'trigger' => array_values($triggers), + 'trigger' => $displaytriggers, 'showcoursecounts' => $showcoursecounts, - 'steps' => array_values($steps), + 'steps' => $displaysteps, 'listofcourses' => $arrayofcourses, 'nosteplink' => $nosteplink, 'table' => $out