@@ -243,46 +243,54 @@ public function handleIMip(
243243 array $ options = [],
244244 ): bool {
245245
246+ $ logContext = [
247+ 'userId ' => $ userId ,
248+ 'options ' => $ options ,
249+ ];
250+
246251 $ userUri = 'principals/users/ ' . $ userId ;
247252
248253 $ userCalendars = $ this ->getCalendarsForPrincipal ($ userUri );
249254 if (empty ($ userCalendars )) {
250- $ this ->logger ->warning ('iMip message could not be processed because user has no calendars ' );
255+ $ this ->logger ->warning ('iMip message could not be processed because user has no calendars ' , $ logContext );
251256 return false ;
252257 }
253258
254259 try {
255260 /** @var VCalendar $vObject|null */
256261 $ vObject = Reader::read ($ message );
257262 } catch (ParseException $ e ) {
258- $ this ->logger ->error ('iMip message could not be processed because an error occurred while parsing the iMip message ' , ['exception ' => $ e ]);
263+ $ logContext ['exception ' ] = $ e ;
264+ $ this ->logger ->error ('iMip message could not be processed because an error occurred while parsing the iMip message ' , $ logContext );
259265 return false ;
260266 }
261267
262268 if (!isset ($ vObject ->VEVENT )) {
263- $ this ->logger ->warning ('iMip message does not contain any event(s) ' );
269+ $ this ->logger ->warning ('iMip message does not contain any event(s) ' , $ logContext );
264270 return false ;
265271 }
266272 /** @var VEvent $vEvent */
267273 $ vEvent = $ vObject ->VEVENT ;
268274
269275 if (!isset ($ vEvent ->UID )) {
270- $ this ->logger ->warning ('iMip message event dose not contains a UID ' );
276+ $ this ->logger ->warning ('iMip message event dose not contains a UID ' , $ logContext );
271277 return false ;
272278 }
273279
280+ $ logContext ['eventUid ' ] = $ vEvent ->UID ->getValue ();
281+
274282 if (!isset ($ vEvent ->ORGANIZER )) {
275283 // quirks mode: for Microsoft Exchange Servers use recipient as organizer if no organizer is set
276284 if (isset ($ options ['recipient ' ]) && $ options ['recipient ' ] !== '' ) {
277285 $ vEvent ->add ('ORGANIZER ' , 'mailto: ' . $ options ['recipient ' ]);
278286 } else {
279- $ this ->logger ->warning ('iMip message event does not contain an organizer and no recipient was provided ' );
287+ $ this ->logger ->warning ('iMip message event does not contain an organizer and no recipient was provided ' , $ logContext );
280288 return false ;
281289 }
282290 }
283291
284292 if (!isset ($ vEvent ->ATTENDEE )) {
285- $ this ->logger ->warning ('iMip message event dose not contains any attendees ' );
293+ $ this ->logger ->warning ('iMip message event dose not contains any attendees ' , $ logContext );
286294 return false ;
287295 }
288296
@@ -300,7 +308,8 @@ public function handleIMip(
300308 }
301309 return true ;
302310 } catch (CalendarException $ e ) {
303- $ this ->logger ->error ('iMip message could not be processed because an error occurred ' , ['exception ' => $ e ]);
311+ $ logContext ['exception ' ] = $ e ;
312+ $ this ->logger ->error ('iMip message could not be processed because an error occurred ' , $ logContext );
304313 return false ;
305314 }
306315 }
@@ -324,14 +333,14 @@ public function handleIMip(
324333 }
325334 }
326335 if ($ calendar === null ) {
327- $ this ->logger ->warning ('iMip message could not be processed because no writable calendar was found ' );
336+ $ this ->logger ->warning ('iMip message could not be processed because no writable calendar was found ' , $ logContext );
328337 return false ;
329338 }
330339 if (!empty ($ options ['absentCreateStatus ' ])) {
331340 $ status = strtoupper ($ options ['absentCreateStatus ' ]);
332341
333342 if (in_array ($ status , ['TENTATIVE ' , 'CONFIRMED ' , 'CANCELLED ' ], true ) === false ) {
334- $ this ->logger ->warning ('iMip message could not be processed because an invalid status was provided for the event ' );
343+ $ this ->logger ->warning ('iMip message could not be processed because an invalid status was provided for the event ' , $ logContext );
335344 return false ;
336345 }
337346
@@ -345,14 +354,15 @@ public function handleIMip(
345354 try {
346355 $ calendar ->handleIMipMessage ($ userId , $ vObject ->serialize ());
347356 } catch (CalendarException $ e ) {
348- $ this ->logger ->error ('iMip message could not be processed because an error occurred ' , ['exception ' => $ e ]);
357+ $ logContext ['exception ' ] = $ e ;
358+ $ this ->logger ->error ('iMip message could not be processed because an error occurred ' , $ logContext );
349359 return false ;
350360 }
351361
352362 return true ;
353363 }
354364
355- $ this ->logger ->warning ('iMip message could not be processed because no corresponding event was found in any calendar ' );
365+ $ this ->logger ->warning ('iMip message could not be processed because no corresponding event was found in any calendar ' , $ logContext );
356366
357367 return false ;
358368 }
0 commit comments