Skip to content

Commit

Permalink
Prevent dynamic property access on classes for PHP 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
justusdieckmann committed Oct 12, 2023
1 parent 2a34021 commit 5d84c4e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions workflowoverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand All @@ -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;
Expand Down Expand Up @@ -159,6 +164,7 @@
}
}
$step->actionmenu = $OUTPUT->render($actionmenu);
$displaysteps[] = $step;
}

$arrayofcourses = array();
Expand All @@ -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
Expand Down

0 comments on commit 5d84c4e

Please sign in to comment.