Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dav): Fix atomic calendar/subscription updates #43904

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

ChristophWurst
Copy link
Member

@ChristophWurst ChristophWurst commented Feb 29, 2024

Summary

Sibiling to #43903 for CalDAV.

The transaction is needed for the database queries but Sabre calls the closure asynchronously. So the transaction span has to be moved into the callback.

This is best reviewed as https://github.com/nextcloud/server/pull/43904/files?w=1

Checklist

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
$supportedProperties = array_keys($this->propertyMap);
$supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';

$propPatch->handle($supportedProperties, function ($mutations) use ($calendarId) {

Check notice

Code scanning / Psalm

MissingClosureParamType Note

Parameter $mutations has no provided type
$supportedProperties = array_keys($this->subscriptionPropertyMap);
$supportedProperties[] = '{http://calendarserver.org/ns/}source';

$propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) {

Check notice

Code scanning / Psalm

MissingClosureParamType Note

Parameter $mutations has no provided type
return true;
});
}, $this->db);
$this->dispatcher->dispatchTyped(new CalendarUpdatedEvent($calendarId, $calendarData, $shares, $mutations));

Check notice

Code scanning / Psalm

PossiblyNullArgument Note

Argument 2 of OCA\DAV\Events\CalendarUpdatedEvent::__construct cannot be null, possibly null value provided
Copy link
Member Author

Choose a reason for hiding this comment

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

Strictly speaking this is correct. \OCA\DAV\CalDAV\CalDavBackend::getCalendarById returns array|null. But this was used without a null check before. Now the data is just wrapped/returned by the closure. Psalm reports here because the diff make the code appear "new".
I'd leave it as is.


$subscriptionRow = $this->atomic(function () use ($subscriptionId, $newValues) {

Check notice

Code scanning / Psalm

MissingClosureReturnType Note

Closure does not have a return type, expecting mixed
Copy link
Member

@st3iny st3iny left a comment

Choose a reason for hiding this comment

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

Tested and works.

I learned something new about Sabre today.

@st3iny st3iny enabled auto-merge March 5, 2024 20:44
@st3iny st3iny merged commit 00e0fa4 into master Mar 5, 2024
160 checks passed
@st3iny st3iny deleted the fix/dav/dirty-caldav-updates branch March 5, 2024 20:44
@blizzz blizzz mentioned this pull request Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug feature: caldav Related to CalDAV internals feature: dav
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants