Skip to content

dav: Fix fatal error when ORGANIZER is missing in CalDAV schedule#59299

Open
AlessioDiPretoroAsdea wants to merge 1 commit intonextcloud:masterfrom
AlessioDiPretoroAsdea:fix/suggestion-ticket-59266
Open

dav: Fix fatal error when ORGANIZER is missing in CalDAV schedule#59299
AlessioDiPretoroAsdea wants to merge 1 commit intonextcloud:masterfrom
AlessioDiPretoroAsdea:fix/suggestion-ticket-59266

Conversation

@AlessioDiPretoroAsdea
Copy link
Copy Markdown

Summary

This PR fixes a Fatal Error: Call to a member function getNormalizedValue() on null in the CalDAV Schedule Plugin.

The error occurs when an event (e.g., synchronized from external sources like Google Calendar) does not contain an ORGANIZER property. Using the PHP 8 null-safe operator ensures the synchronization doesn't crash with a 500 error.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits (DCO)

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Copy link
Copy Markdown
Member

@tcitworld tcitworld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@AlessioDiPretoroAsdea
Copy link
Copy Markdown
Author

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)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@kesselb
Copy link
Copy Markdown
Contributor

kesselb commented Mar 30, 2026

Block unconventional commits / Block unconventional commits

To resolve please change the ocmmit message like

fix(dav): Avoid fatal error for events without an organizer

(the current message fails, because "dav" isn't valid. It must be either fix, feat, refactor, chore, test, ci).

@AlessioDiPretoroAsdea AlessioDiPretoroAsdea force-pushed the fix/suggestion-ticket-59266 branch 2 times, most recently from 826230a to 32a9191 Compare March 30, 2026 13:00
@AlessioDiPretoroAsdea
Copy link
Copy Markdown
Author

@kesselb @tcitworld
Thanks for the feedback! I've updated the code using isset() and fixed the commit message format to follow the conventional commits standard. Re-pushed now.

Signed-off-by: AlessioDiPretoroAsdea <alessio.dipretoro@asdeahw.net>
@SebastianKrupinski SebastianKrupinski force-pushed the fix/suggestion-ticket-59266 branch from 32a9191 to 85b851a Compare March 30, 2026 18:23
@kesselb
Copy link
Copy Markdown
Contributor

kesselb commented Mar 30, 2026

/backport to stable33

@kesselb
Copy link
Copy Markdown
Contributor

kesselb commented Mar 30, 2026

/backport to stable32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Fatal Error in CalDAV Schedule Plugin: Call to a member function getNormalizedValue() on null

4 participants