dav: Fix fatal error when ORGANIZER is missing in CalDAV schedule#59299
dav: Fix fatal error when ORGANIZER is missing in CalDAV schedule#59299AlessioDiPretoroAsdea wants to merge 1 commit intonextcloud:masterfrom
Conversation
tcitworld
left a comment
There was a problem hiding this comment.
Fix looks good enough, I just wonder if there's a way that $adresses could contain the null value. In that case we better check that $vevent->ORGANIZER?->getNormalizedValue() isn't null outside the in_array condition first.
|
Thanks for the review! I encountered this bug while syncing Google Calendar events to Nextcloud using vdirsyncer. Some events from Google don't seem to have a technical 'Organizer' field, which leads to the fatal error. Since I'm not a PHP expert, I'm not sure if $addresses could ever contain a null value in this context. If you think an explicit check for null is safer, please let me know and I'll try to update the code accordingly! |
| $addresses = $this->getAddressesForPrincipal($calendarNode->getOwner()); | ||
| foreach ($vCal->VEVENT as $vevent) { | ||
| if (in_array($vevent->ORGANIZER->getNormalizedValue(), $addresses, true)) { | ||
| if (in_array($vevent->ORGANIZER?->getNormalizedValue(), $addresses, true)) { |
There was a problem hiding this comment.
| if (in_array($vevent->ORGANIZER?->getNormalizedValue(), $addresses, true)) { | |
| if (isset($vevent->ORGANIZER) && in_array($vevent->ORGANIZER->getNormalizedValue(), $addresses, true)) { |
I didn't test it, however checking for existence would make the intent clearer. The current patch just uses null to search for in addresses.
To resolve please change the ocmmit message like
(the current message fails, because "dav" isn't valid. It must be either fix, feat, refactor, chore, test, ci). |
826230a to
32a9191
Compare
|
@kesselb @tcitworld |
Signed-off-by: AlessioDiPretoroAsdea <alessio.dipretoro@asdeahw.net>
32a9191 to
85b851a
Compare
|
/backport to stable33 |
|
/backport to stable32 |
Summary
This PR fixes a
Fatal Error: Call to a member function getNormalizedValue() on nullin the CalDAV Schedule Plugin.The error occurs when an event (e.g., synchronized from external sources like Google Calendar) does not contain an
ORGANIZERproperty. Using the PHP 8 null-safe operator ensures the synchronization doesn't crash with a 500 error.Checklist
AI (if applicable)