Skip to content

Commit ebf8a02

Browse files
[stable9.1] Merge pull request #25636 from owncloud/fix-birthday-calendar-component (#26056)
The birthday calendar can only hold VEVENT
1 parent 058c79a commit ebf8a02

File tree

4 files changed

+77
-2
lines changed

4 files changed

+77
-2
lines changed

apps/dav/appinfo/info.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
</background-jobs>
2323
<repair-steps>
2424
<post-migration>
25-
<job>OCA\DAV\Migration\Classification</job>
25+
<step>OCA\DAV\Migration\Classification</step>
26+
<step>OCA\DAV\Migration\FixBirthdayCalendarComponent</step>
2627
</post-migration>
2728
<live-migration>
28-
<job>OCA\DAV\Migration\GenerateBirthdays</job>
29+
<step>OCA\DAV\Migration\GenerateBirthdays</step>
2930
</live-migration>
3031
</repair-steps>
3132
</info>

apps/dav/lib/CalDAV/BirthdayService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public function ensureCalendarExists($principal) {
108108
$this->calDavBackEnd->createCalendar($principal, self::BIRTHDAY_CALENDAR_URI, [
109109
'{DAV:}displayname' => 'Contact birthdays',
110110
'{http://apple.com/ns/ical/}calendar-color' => '#FFFFCA',
111+
'components' => 'VEVENT',
111112
]);
112113

113114
return $this->calDavBackEnd->getCalendarByUri($principal, self::BIRTHDAY_CALENDAR_URI);
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* @author Thomas Müller <[email protected]>
4+
*
5+
* @copyright Copyright (c) 2016, ownCloud GmbH.
6+
* @license AGPL-3.0
7+
*
8+
* This code is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License, version 3,
10+
* as published by the Free Software Foundation.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Affero General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Affero General Public License, version 3,
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>
19+
*
20+
*/
21+
22+
namespace OCA\DAV\Migration;
23+
24+
use OCA\DAV\CalDAV\BirthdayService;
25+
use OCP\IDBConnection;
26+
use OCP\Migration\IOutput;
27+
use OCP\Migration\IRepairStep;
28+
29+
class FixBirthdayCalendarComponent implements IRepairStep {
30+
31+
/** @var IDBConnection */
32+
private $connection;
33+
34+
/**
35+
* FixBirthdayCalendarComponent constructor.
36+
*
37+
* @param IDBConnection $connection
38+
*/
39+
public function __construct(IDBConnection $connection) {
40+
$this->connection = $connection;
41+
}
42+
43+
/**
44+
* @inheritdoc
45+
*/
46+
public function getName() {
47+
return 'Fix component of birthday calendars';
48+
}
49+
50+
/**
51+
* @inheritdoc
52+
*/
53+
public function run(IOutput $output) {
54+
$query = $this->connection->getQueryBuilder();
55+
$updated = $query->update('calendars')
56+
->set('components', $query->createNamedParameter('VEVENT'))
57+
->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
58+
->execute();
59+
60+
$output->info("$updated birthday calendars updated.");
61+
}
62+
}

apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,17 @@ public function testGetAllAffectedPrincipals() {
178178
], $users);
179179
}
180180

181+
public function testBirthdayCalendarHasComponentEvent() {
182+
$this->calDav->expects($this->once())
183+
->method('createCalendar')
184+
->with('principal001', 'contact_birthdays', [
185+
'{DAV:}displayname' => 'Contact birthdays',
186+
'{http://apple.com/ns/ical/}calendar-color' => '#FFFFCA',
187+
'components' => 'VEVENT',
188+
]);
189+
$this->service->ensureCalendarExists('principal001');
190+
}
191+
181192
public function providesBirthday() {
182193
return [
183194
[true,

0 commit comments

Comments
 (0)