Skip to content

Commit 56b9052

Browse files
committed
fixup! Add Typed Events for CalDAV- and CardDAV-related Events
1 parent a666af7 commit 56b9052

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

apps/dav/lib/CalDAV/CalDavBackend.php

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ public function createCalendar($principalUri, $calendarUri, array $properties) {
787787
$calendarId = $query->getLastInsertId();
788788

789789
$calendarData = $this->getCalendarById($calendarId);
790-
$this->dispatcher->dispatchTyped(new CalendarCreatedEvent($calendarId, $calendarData));
790+
$this->dispatcher->dispatchTyped(new CalendarCreatedEvent((int)$calendarId, $calendarData));
791791
$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', new GenericEvent(
792792
'\OCA\DAV\CalDAV\CalDavBackend::createCalendar',
793793
[
@@ -847,7 +847,7 @@ public function updateCalendar($calendarId, PropPatch $propPatch) {
847847

848848
$calendarData = $this->getCalendarById($calendarId);
849849
$shares = $this->getShares($calendarId);
850-
$this->dispatcher->dispatchTyped(new CalendarUpdatedEvent($calendarId, $calendarData, $shares, $mutations));
850+
$this->dispatcher->dispatchTyped(new CalendarUpdatedEvent((int)$calendarId, $calendarData, $shares, $mutations));
851851
$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', new GenericEvent(
852852
'\OCA\DAV\CalDAV\CalDavBackend::updateCalendar',
853853
[
@@ -896,7 +896,9 @@ public function deleteCalendar($calendarId) {
896896
->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)))
897897
->execute();
898898

899-
$this->dispatcher->dispatchTyped(new CalendarDeletedEvent($calendarId, $calendarData, $shares));
899+
if ($calendarData) {
900+
$this->dispatcher->dispatchTyped(new CalendarDeletedEvent((int)$calendarId, $calendarData, $shares));
901+
}
900902
}
901903

902904
/**
@@ -1124,7 +1126,7 @@ public function createCalendarObject($calendarId, $objectUri, $calendarData, $ca
11241126
$calendarRow = $this->getCalendarById($calendarId);
11251127
$shares = $this->getShares($calendarId);
11261128

1127-
$this->dispatcher->dispatchTyped(new CalendarObjectCreatedEvent($calendarId, $calendarRow, $shares, $objectRow));
1129+
$this->dispatcher->dispatchTyped(new CalendarObjectCreatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow));
11281130
$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', new GenericEvent(
11291131
'\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject',
11301132
[
@@ -1137,7 +1139,7 @@ public function createCalendarObject($calendarId, $objectUri, $calendarData, $ca
11371139
} else {
11381140
$subscriptionRow = $this->getSubscriptionById($calendarId);
11391141

1140-
$this->dispatcher->dispatchTyped(new CachedCalendarObjectCreatedEvent($calendarId, $subscriptionRow, [], $objectRow));
1142+
$this->dispatcher->dispatchTyped(new CachedCalendarObjectCreatedEvent((int)$calendarId, $subscriptionRow, [], $objectRow));
11411143
$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCachedCalendarObject', new GenericEvent(
11421144
'\OCA\DAV\CalDAV\CalDavBackend::createCachedCalendarObject',
11431145
[
@@ -1198,7 +1200,7 @@ public function updateCalendarObject($calendarId, $objectUri, $calendarData, $ca
11981200
$calendarRow = $this->getCalendarById($calendarId);
11991201
$shares = $this->getShares($calendarId);
12001202

1201-
$this->dispatcher->dispatchTyped(new CalendarObjectUpdatedEvent($calendarId, $calendarRow, $shares, $objectRow));
1203+
$this->dispatcher->dispatchTyped(new CalendarObjectUpdatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow));
12021204
$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', new GenericEvent(
12031205
'\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject',
12041206
[
@@ -1211,7 +1213,7 @@ public function updateCalendarObject($calendarId, $objectUri, $calendarData, $ca
12111213
} else {
12121214
$subscriptionRow = $this->getSubscriptionById($calendarId);
12131215

1214-
$this->dispatcher->dispatchTyped(new CachedCalendarObjectUpdatedEvent($calendarId, $subscriptionRow, [], $objectRow));
1216+
$this->dispatcher->dispatchTyped(new CachedCalendarObjectUpdatedEvent((int)$calendarId, $subscriptionRow, [], $objectRow));
12151217
$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCachedCalendarObject', new GenericEvent(
12161218
'\OCA\DAV\CalDAV\CalDavBackend::updateCachedCalendarObject',
12171219
[
@@ -1261,7 +1263,7 @@ public function deleteCalendarObject($calendarId, $objectUri, $calendarType=self
12611263
$calendarRow = $this->getCalendarById($calendarId);
12621264
$shares = $this->getShares($calendarId);
12631265

1264-
$this->dispatcher->dispatchTyped(new CalendarObjectDeletedEvent($calendarId, $calendarRow, $shares, $data));
1266+
$this->dispatcher->dispatchTyped(new CalendarObjectDeletedEvent((int)$calendarId, $calendarRow, $shares, $data));
12651267
$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', new GenericEvent(
12661268
'\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject',
12671269
[
@@ -1274,7 +1276,7 @@ public function deleteCalendarObject($calendarId, $objectUri, $calendarType=self
12741276
} else {
12751277
$subscriptionRow = $this->getSubscriptionById($calendarId);
12761278

1277-
$this->dispatcher->dispatchTyped(new CachedCalendarObjectDeletedEvent($calendarId, $subscriptionRow, [], $data));
1279+
$this->dispatcher->dispatchTyped(new CachedCalendarObjectDeletedEvent((int)$calendarId, $subscriptionRow, [], $data));
12781280
$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCachedCalendarObject', new GenericEvent(
12791281
'\OCA\DAV\CalDAV\CalDavBackend::deleteCachedCalendarObject',
12801282
[
@@ -2116,7 +2118,7 @@ public function createSubscription($principalUri, $uri, array $properties) {
21162118
$subscriptionId = $this->db->lastInsertId('*PREFIX*calendarsubscriptions');
21172119

21182120
$subscriptionRow = $this->getSubscriptionById($subscriptionId);
2119-
$this->dispatcher->dispatchTyped(new SubscriptionCreatedEvent($subscriptionId, $subscriptionRow));
2121+
$this->dispatcher->dispatchTyped(new SubscriptionCreatedEvent((int)$subscriptionId, $subscriptionRow));
21202122
$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createSubscription', new GenericEvent(
21212123
'\OCA\DAV\CalDAV\CalDavBackend::createSubscription',
21222124
[
@@ -2172,7 +2174,7 @@ public function updateSubscription($subscriptionId, PropPatch $propPatch) {
21722174
->execute();
21732175

21742176
$subscriptionRow = $this->getSubscriptionById($subscriptionId);
2175-
$this->dispatcher->dispatchTyped(new SubscriptionUpdatedEvent($subscriptionId, $subscriptionRow, [], $mutations));
2177+
$this->dispatcher->dispatchTyped(new SubscriptionUpdatedEvent((int)$subscriptionId, $subscriptionRow, [], $mutations));
21762178
$this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateSubscription', new GenericEvent(
21772179
'\OCA\DAV\CalDAV\CalDavBackend::updateSubscription',
21782180
[
@@ -2222,7 +2224,9 @@ public function deleteSubscription($subscriptionId) {
22222224
->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
22232225
->execute();
22242226

2225-
$this->dispatcher->dispatchTyped(new SubscriptionDeletedEvent($subscriptionId, $subscriptionRow, []));
2227+
if ($subscriptionRow) {
2228+
$this->dispatcher->dispatchTyped(new SubscriptionDeletedEvent((int)$subscriptionId, $subscriptionRow, []));
2229+
}
22262230
}
22272231

22282232
/**
@@ -2489,7 +2493,7 @@ public function updateShares($shareable, $add, $remove) {
24892493
]));
24902494
$this->calendarSharingBackend->updateShares($shareable, $add, $remove);
24912495

2492-
$this->dispatcher->dispatchTyped(new CalendarShareUpdatedEvent($calendarId, $calendarRow, $oldShares, $add, $remove));
2496+
$this->dispatcher->dispatchTyped(new CalendarShareUpdatedEvent((int)$calendarId, $calendarRow, $oldShares, $add, $remove));
24932497
}
24942498

24952499
/**
@@ -2530,15 +2534,15 @@ public function setPublishStatus($value, $calendar) {
25302534
]);
25312535
$query->execute();
25322536

2533-
$this->dispatcher->dispatchTyped(new CalendarPublishedEvent($calendarId, $calendarData, $publicUri));
2537+
$this->dispatcher->dispatchTyped(new CalendarPublishedEvent((int)$calendarId, $calendarData, $publicUri));
25342538
return $publicUri;
25352539
}
25362540
$query->delete('dav_shares')
25372541
->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
25382542
->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)));
25392543
$query->execute();
25402544

2541-
$this->dispatcher->dispatchTyped(new CalendarUnpublishedEvent($calendarId, $calendarData));
2545+
$this->dispatcher->dispatchTyped(new CalendarUnpublishedEvent((int)$calendarId, $calendarData));
25422546
return null;
25432547
}
25442548

apps/dav/lib/CardDAV/CardDavBackend.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ public function createAddressBook($principalUri, $url, array $properties) {
461461

462462
$addressBookId = $query->getLastInsertId();
463463
$addressBookRow = $this->getAddressBookById($addressBookId);
464-
$this->dispatcher->dispatchTyped(new AddressBookCreatedEvent($addressBookId, $addressBookRow));
464+
$this->dispatcher->dispatchTyped(new AddressBookCreatedEvent((int)$addressBookId, $addressBookRow));
465465

466466
return $addressBookId;
467467
}
@@ -498,7 +498,9 @@ public function deleteAddressBook($addressBookId) {
498498
->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
499499
->execute();
500500

501-
$this->dispatcher->dispatchTyped(new AddressBookDeletedEvent((int) $addressBookId, $addressBookData, $shares));
501+
if ($addressBookData) {
502+
$this->dispatcher->dispatchTyped(new AddressBookDeletedEvent((int) $addressBookId, $addressBookData, $shares));
503+
}
502504
}
503505

504506
/**
@@ -691,7 +693,7 @@ public function createCard($addressBookId, $cardUri, $cardData) {
691693
$addressBookData = $this->getAddressBookById($addressBookId);
692694
$shares = $this->getShares($addressBookId);
693695
$objectRow = $this->getCard($addressBookId, $cardUri);
694-
$this->dispatcher->dispatchTyped(new CardCreatedEvent($addressBookId, $addressBookData, $shares, $objectRow));
696+
$this->dispatcher->dispatchTyped(new CardCreatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
695697
$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::createCard',
696698
new GenericEvent(null, [
697699
'addressBookId' => $addressBookId,
@@ -755,7 +757,7 @@ public function updateCard($addressBookId, $cardUri, $cardData) {
755757
$addressBookData = $this->getAddressBookById($addressBookId);
756758
$shares = $this->getShares($addressBookId);
757759
$objectRow = $this->getCard($addressBookId, $cardUri);
758-
$this->dispatcher->dispatchTyped(new CardUpdatedEvent($addressBookId, $addressBookData, $shares, $objectRow));
760+
$this->dispatcher->dispatchTyped(new CardUpdatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
759761
$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::updateCard',
760762
new GenericEvent(null, [
761763
'addressBookId' => $addressBookId,
@@ -790,14 +792,14 @@ public function deleteCard($addressBookId, $cardUri) {
790792

791793
$this->addChange($addressBookId, $cardUri, 3);
792794

793-
$this->dispatcher->dispatchTyped(new CardDeletedEvent($addressBookId, $addressBookData, $shares, $objectRow));
794-
$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::deleteCard',
795-
new GenericEvent(null, [
796-
'addressBookId' => $addressBookId,
797-
'cardUri' => $cardUri]));
798-
799795
if ($ret === 1) {
800796
if ($cardId !== null) {
797+
$this->dispatcher->dispatchTyped(new CardDeletedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
798+
$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::deleteCard',
799+
new GenericEvent(null, [
800+
'addressBookId' => $addressBookId,
801+
'cardUri' => $cardUri]));
802+
801803
$this->purgeProperties($addressBookId, $cardId);
802804
}
803805
return true;

0 commit comments

Comments
 (0)