File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -553,7 +553,7 @@ public static function changes_collected_action(
553553 $ taskdata = [
554554 'teacherchanges ' => $ changes ["mod_booking \\option \\fields \\teachers " ],
555555 'namechanges ' => $ changes ["mod_booking \\option \\fields \\text " ],
556- 'relevantchanges ' => isset ( $ changes ["bookingextension_evasys \\option \\fields \\evasys " ]['changes ' ]) ?? [],
556+ 'relevantchanges ' => $ changes ["bookingextension_evasys \\option \\fields \\evasys " ]['changes ' ] ?? [],
557557 'newoption ' => $ relevantoptiondata ,
558558 'relevantkeyssurvey ' => self ::$ relevantkeyssurvey ,
559559 'relevantkeyscourse ' => self ::$ relevantkeyscourse ,
Original file line number Diff line number Diff line change @@ -95,6 +95,13 @@ public function execute() {
9595 mtrace ($ this ->get_name () . ': Skipping task - no teachers assigned. ' );
9696 return ;
9797 }
98+ // Normalize changed keys so update checks work with array or object payloads.
99+ $ changedkeys = [];
100+ if (is_array ($ relevantchanges )) {
101+ $ changedkeys = array_keys ($ relevantchanges );
102+ } else if (is_object ($ relevantchanges )) {
103+ $ changedkeys = array_keys ((array )$ relevantchanges );
104+ }
98105 // If by any chance the option is a selflearningcourse and slips through validation, we skip the task.
99106 if (!empty ($ newoption ->selflearningcourse )) {
100107 mtrace ($ this ->get_name () . ': Skipping task - option is a self-learning course. ' );
@@ -144,15 +151,16 @@ public function execute() {
144151 }
145152 // Checks if the survey and therefore the course needs to be updated.
146153 if (!$ updatesurvey ) {
147- foreach ($ relevantchanges as $ key => $ value ) {
154+ foreach ($ changedkeys as $ key ) {
148155 if (in_array ($ key , $ relevantkeyssurvey , true )) {
149156 $ updatesurvey = true ;
157+ break ;
150158 }
151159 }
152160 // Checks for the only key where just the course needs to be updated.
153161 if (
154162 !$ updatesurvey
155- && isset ( $ courserelevantchanges -> $ relevankeyscourse )
163+ && ! empty ( array_intersect ( $ changedkeys , $ relevankeyscourse) )
156164 ) {
157165 $ updatecourse = true ;
158166 }
You can’t perform that action at this time.
0 commit comments