@@ -232,46 +232,54 @@ public function handleIMip(
232232 array $ options = [],
233233 ): bool {
234234
235+ $ logContext = [
236+ 'userId ' => $ userId ,
237+ 'options ' => $ options ,
238+ ];
239+
235240 $ userUri = 'principals/users/ ' . $ userId ;
236241
237242 $ userCalendars = $ this ->getCalendarsForPrincipal ($ userUri );
238243 if (empty ($ userCalendars )) {
239- $ this ->logger ->warning ('iMip message could not be processed because user has no calendars ' );
244+ $ this ->logger ->warning ('iMip message could not be processed because user has no calendars ' , $ logContext );
240245 return false ;
241246 }
242247
243248 try {
244249 /** @var VCalendar $vObject|null */
245250 $ vObject = Reader::read ($ message );
246251 } catch (ParseException $ e ) {
247- $ this ->logger ->error ('iMip message could not be processed because an error occurred while parsing the iMip message ' , ['exception ' => $ e ]);
252+ $ logContext ['exception ' ] = $ e ;
253+ $ this ->logger ->error ('iMip message could not be processed because an error occurred while parsing the iMip message ' , $ logContext );
248254 return false ;
249255 }
250256
251257 if (!isset ($ vObject ->VEVENT )) {
252- $ this ->logger ->warning ('iMip message does not contain any event(s) ' );
258+ $ this ->logger ->warning ('iMip message does not contain any event(s) ' , $ logContext );
253259 return false ;
254260 }
255261 /** @var VEvent $vEvent */
256262 $ vEvent = $ vObject ->VEVENT ;
257263
258264 if (!isset ($ vEvent ->UID )) {
259- $ this ->logger ->warning ('iMip message event dose not contains a UID ' );
265+ $ this ->logger ->warning ('iMip message event dose not contains a UID ' , $ logContext );
260266 return false ;
261267 }
262268
269+ $ logContext ['eventUid ' ] = $ vEvent ->UID ->getValue ();
270+
263271 if (!isset ($ vEvent ->ORGANIZER )) {
264272 // quirks mode: for Microsoft Exchange Servers use recipient as organizer if no organizer is set
265273 if (isset ($ options ['recipient ' ]) && $ options ['recipient ' ] !== '' ) {
266274 $ vEvent ->add ('ORGANIZER ' , 'mailto: ' . $ options ['recipient ' ]);
267275 } else {
268- $ this ->logger ->warning ('iMip message event does not contain an organizer and no recipient was provided ' );
276+ $ this ->logger ->warning ('iMip message event does not contain an organizer and no recipient was provided ' , $ logContext );
269277 return false ;
270278 }
271279 }
272280
273281 if (!isset ($ vEvent ->ATTENDEE )) {
274- $ this ->logger ->warning ('iMip message event dose not contains any attendees ' );
282+ $ this ->logger ->warning ('iMip message event dose not contains any attendees ' , $ logContext );
275283 return false ;
276284 }
277285
@@ -289,7 +297,8 @@ public function handleIMip(
289297 }
290298 return true ;
291299 } catch (CalendarException $ e ) {
292- $ this ->logger ->error ('iMip message could not be processed because an error occurred ' , ['exception ' => $ e ]);
300+ $ logContext ['exception ' ] = $ e ;
301+ $ this ->logger ->error ('iMip message could not be processed because an error occurred ' , $ logContext );
293302 return false ;
294303 }
295304 }
@@ -313,14 +322,14 @@ public function handleIMip(
313322 }
314323 }
315324 if ($ calendar === null ) {
316- $ this ->logger ->warning ('iMip message could not be processed because no writable calendar was found ' );
325+ $ this ->logger ->warning ('iMip message could not be processed because no writable calendar was found ' , $ logContext );
317326 return false ;
318327 }
319328 if (!empty ($ options ['absentCreateStatus ' ])) {
320329 $ status = strtoupper ($ options ['absentCreateStatus ' ]);
321330
322331 if (in_array ($ status , ['TENTATIVE ' , 'CONFIRMED ' , 'CANCELLED ' ], true ) === false ) {
323- $ this ->logger ->warning ('iMip message could not be processed because an invalid status was provided for the event ' );
332+ $ this ->logger ->warning ('iMip message could not be processed because an invalid status was provided for the event ' , $ logContext );
324333 return false ;
325334 }
326335
@@ -334,14 +343,15 @@ public function handleIMip(
334343 try {
335344 $ calendar ->handleIMipMessage ($ userId , $ vObject ->serialize ());
336345 } catch (CalendarException $ e ) {
337- $ this ->logger ->error ('iMip message could not be processed because an error occurred ' , ['exception ' => $ e ]);
346+ $ logContext ['exception ' ] = $ e ;
347+ $ this ->logger ->error ('iMip message could not be processed because an error occurred ' , $ logContext );
338348 return false ;
339349 }
340350
341351 return true ;
342352 }
343353
344- $ this ->logger ->warning ('iMip message could not be processed because no corresponding event was found in any calendar ' );
354+ $ this ->logger ->warning ('iMip message could not be processed because no corresponding event was found in any calendar ' , $ logContext );
345355
346356 return false ;
347357 }
0 commit comments