aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2025-02-28 17:17:15 +0100
committerAndy Scherzinger <info@andy-scherzinger.de>2025-03-30 14:47:22 +0200
commit6006425b5455813d567401c1f17d78cf549e9497 (patch)
treec0187cd032780d979cd90b9f1b2be03fe105446d
parent7252b6bb84163c0dfdb9e66597156786629a6ce3 (diff)
downloadnextcloud-server-backport/51144/stable30.tar.gz
nextcloud-server-backport/51144/stable30.zip
fix(dav): Create SAB at installationbackport/51144/stable30
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r--apps/dav/appinfo/info.xml3
-rw-r--r--apps/dav/composer/composer/autoload_classmap.php1
-rw-r--r--apps/dav/composer/composer/autoload_static.php1
-rw-r--r--apps/dav/lib/CardDAV/SyncService.php11
-rw-r--r--apps/dav/lib/Migration/CreateSystemAddressBookStep.php30
-rw-r--r--apps/dav/tests/unit/Migration/CreateSystemAddressBookStepTest.php47
6 files changed, 89 insertions, 4 deletions
diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml
index 173c45a7fef..392f6c7aab3 100644
--- a/apps/dav/appinfo/info.xml
+++ b/apps/dav/appinfo/info.xml
@@ -49,6 +49,9 @@
<live-migration>
<step>OCA\DAV\Migration\ChunkCleanup</step>
</live-migration>
+ <install>
+ <step>OCA\DAV\Migration\CreateSystemAddressBookStep</step>
+ </install>
</repair-steps>
<commands>
diff --git a/apps/dav/composer/composer/autoload_classmap.php b/apps/dav/composer/composer/autoload_classmap.php
index 8fcf87c6c23..324738bc45a 100644
--- a/apps/dav/composer/composer/autoload_classmap.php
+++ b/apps/dav/composer/composer/autoload_classmap.php
@@ -303,6 +303,7 @@ return array(
'OCA\\DAV\\Migration\\BuildSocialSearchIndexBackgroundJob' => $baseDir . '/../lib/Migration/BuildSocialSearchIndexBackgroundJob.php',
'OCA\\DAV\\Migration\\CalDAVRemoveEmptyValue' => $baseDir . '/../lib/Migration/CalDAVRemoveEmptyValue.php',
'OCA\\DAV\\Migration\\ChunkCleanup' => $baseDir . '/../lib/Migration/ChunkCleanup.php',
+ 'OCA\\DAV\\Migration\\CreateSystemAddressBookStep' => $baseDir . '/../lib/Migration/CreateSystemAddressBookStep.php',
'OCA\\DAV\\Migration\\DeleteSchedulingObjects' => $baseDir . '/../lib/Migration/DeleteSchedulingObjects.php',
'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => $baseDir . '/../lib/Migration/FixBirthdayCalendarComponent.php',
'OCA\\DAV\\Migration\\RefreshWebcalJobRegistrar' => $baseDir . '/../lib/Migration/RefreshWebcalJobRegistrar.php',
diff --git a/apps/dav/composer/composer/autoload_static.php b/apps/dav/composer/composer/autoload_static.php
index 43341fb1031..cd3fff1eaee 100644
--- a/apps/dav/composer/composer/autoload_static.php
+++ b/apps/dav/composer/composer/autoload_static.php
@@ -318,6 +318,7 @@ class ComposerStaticInitDAV
'OCA\\DAV\\Migration\\BuildSocialSearchIndexBackgroundJob' => __DIR__ . '/..' . '/../lib/Migration/BuildSocialSearchIndexBackgroundJob.php',
'OCA\\DAV\\Migration\\CalDAVRemoveEmptyValue' => __DIR__ . '/..' . '/../lib/Migration/CalDAVRemoveEmptyValue.php',
'OCA\\DAV\\Migration\\ChunkCleanup' => __DIR__ . '/..' . '/../lib/Migration/ChunkCleanup.php',
+ 'OCA\\DAV\\Migration\\CreateSystemAddressBookStep' => __DIR__ . '/..' . '/../lib/Migration/CreateSystemAddressBookStep.php',
'OCA\\DAV\\Migration\\DeleteSchedulingObjects' => __DIR__ . '/..' . '/../lib/Migration/DeleteSchedulingObjects.php',
'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => __DIR__ . '/..' . '/../lib/Migration/FixBirthdayCalendarComponent.php',
'OCA\\DAV\\Migration\\RefreshWebcalJobRegistrar' => __DIR__ . '/..' . '/../lib/Migration/RefreshWebcalJobRegistrar.php',
diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php
index 356903b3f69..264d34a150b 100644
--- a/apps/dav/lib/CardDAV/SyncService.php
+++ b/apps/dav/lib/CardDAV/SyncService.php
@@ -108,6 +108,12 @@ class SyncService {
}, $this->dbConnection);
}
+ public function ensureLocalSystemAddressBookExists(): ?array {
+ return $this->ensureSystemAddressBookExists('principals/system/system', 'system', [
+ '{' . Plugin::NS_CARDDAV . '}addressbook-description' => 'System addressbook which holds all users of this instance'
+ ]);
+ }
+
private function prepareUri(string $host, string $path): string {
/*
* The trailing slash is important for merging the uris together.
@@ -263,10 +269,7 @@ class SyncService {
*/
public function getLocalSystemAddressBook() {
if (is_null($this->localSystemAddressBook)) {
- $systemPrincipal = "principals/system/system";
- $this->localSystemAddressBook = $this->ensureSystemAddressBookExists($systemPrincipal, 'system', [
- '{' . Plugin::NS_CARDDAV . '}addressbook-description' => 'System addressbook which holds all users of this instance'
- ]);
+ $this->localSystemAddressBook = $this->ensureLocalSystemAddressBookExists();
}
return $this->localSystemAddressBook;
diff --git a/apps/dav/lib/Migration/CreateSystemAddressBookStep.php b/apps/dav/lib/Migration/CreateSystemAddressBookStep.php
new file mode 100644
index 00000000000..ec07c72e7a7
--- /dev/null
+++ b/apps/dav/lib/Migration/CreateSystemAddressBookStep.php
@@ -0,0 +1,30 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCA\DAV\Migration;
+
+use OCA\DAV\CardDAV\SyncService;
+use OCP\Migration\IOutput;
+use OCP\Migration\IRepairStep;
+
+class CreateSystemAddressBookStep implements IRepairStep {
+
+ public function __construct(
+ private SyncService $syncService,
+ ) {
+ }
+
+ public function getName(): string {
+ return 'Create system address book';
+ }
+
+ public function run(IOutput $output): void {
+ $this->syncService->ensureLocalSystemAddressBookExists();
+ }
+}
diff --git a/apps/dav/tests/unit/Migration/CreateSystemAddressBookStepTest.php b/apps/dav/tests/unit/Migration/CreateSystemAddressBookStepTest.php
new file mode 100644
index 00000000000..bbecd0607b4
--- /dev/null
+++ b/apps/dav/tests/unit/Migration/CreateSystemAddressBookStepTest.php
@@ -0,0 +1,47 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCA\DAV\Tests\Unit\Migration;
+
+use OCA\DAV\CardDAV\SyncService;
+use OCA\DAV\Migration\CreateSystemAddressBookStep;
+use OCP\Migration\IOutput;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class CreateSystemAddressBookStepTest extends TestCase {
+
+ private SyncService|MockObject $syncService;
+ private CreateSystemAddressBookStep $step;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->syncService = $this->createMock(SyncService::class);
+
+ $this->step = new CreateSystemAddressBookStep(
+ $this->syncService,
+ );
+ }
+
+ public function testGetName(): void {
+ $name = $this->step->getName();
+
+ self::assertEquals('Create system address book', $name);
+ }
+
+ public function testRun(): void {
+ $output = $this->createMock(IOutput::class);
+
+ $this->step->run($output);
+
+ $this->addToAssertionCount(1);
+ }
+
+}