-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -848,11 +848,10 @@ | |
* @return void | ||
*/ | ||
public function updateCalendar($calendarId, PropPatch $propPatch) { | ||
$this->atomic(function () use ($calendarId, $propPatch) { | ||
$supportedProperties = array_keys($this->propertyMap); | ||
$supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp'; | ||
|
||
$propPatch->handle($supportedProperties, function ($mutations) use ($calendarId) { | ||
$newValues = []; | ||
foreach ($mutations as $propertyName => $propertyValue) { | ||
switch ($propertyName) { | ||
|
@@ -866,6 +865,7 @@ | |
break; | ||
} | ||
} | ||
[$calendarData, $shares] = $this->atomic(function () use ($calendarId, $newValues) { | ||
$query = $this->db->getQueryBuilder(); | ||
$query->update('calendars'); | ||
foreach ($newValues as $fieldName => $value) { | ||
|
@@ -878,11 +878,13 @@ | |
|
||
$calendarData = $this->getCalendarById($calendarId); | ||
$shares = $this->getShares($calendarId); | ||
return [$calendarData, $shares]; | ||
}, $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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strictly speaking this is correct. |
||
|
||
return true; | ||
}); | ||
}, $this->db); | ||
} | ||
|
||
/** | ||
|
@@ -2570,11 +2572,10 @@ | |
* @return void | ||
*/ | ||
public function updateSubscription($subscriptionId, PropPatch $propPatch) { | ||
$this->atomic(function () use ($subscriptionId, $propPatch) { | ||
$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
|
||
$newValues = []; | ||
|
||
foreach ($mutations as $propertyName => $propertyValue) { | ||
|
@@ -2586,6 +2587,7 @@ | |
} | ||
} | ||
|
||
$subscriptionRow = $this->atomic(function () use ($subscriptionId, $newValues) { | ||
Check notice Code scanning / Psalm MissingClosureReturnType Note
Closure does not have a return type, expecting mixed
|
||
$query = $this->db->getQueryBuilder(); | ||
$query->update('calendarsubscriptions') | ||
->set('lastmodified', $query->createNamedParameter(time())); | ||
|
@@ -2595,12 +2597,13 @@ | |
$query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId))) | ||
->executeStatement(); | ||
|
||
$subscriptionRow = $this->getSubscriptionById($subscriptionId); | ||
return $this->getSubscriptionById($subscriptionId); | ||
}, $this->db); | ||
|
||
$this->dispatcher->dispatchTyped(new SubscriptionUpdatedEvent((int)$subscriptionId, $subscriptionRow, [], $mutations)); | ||
|
||
return true; | ||
}); | ||
}, $this->db); | ||
} | ||
|
||
/** | ||
|
Check notice
Code scanning / Psalm
MissingClosureParamType Note