Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dav/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<name>WebDAV</name>
<summary>WebDAV endpoint</summary>
<description>WebDAV endpoint</description>
<version>1.34.0</version>
<version>1.34.1</version>
<licence>agpl</licence>
<author>owncloud.org</author>
<namespace>DAV</namespace>
Expand Down
1 change: 1 addition & 0 deletions apps/dav/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
'OCA\\DAV\\Migration\\Version1029Date20231004091403' => $baseDir . '/../lib/Migration/Version1029Date20231004091403.php',
'OCA\\DAV\\Migration\\Version1030Date20240205103243' => $baseDir . '/../lib/Migration/Version1030Date20240205103243.php',
'OCA\\DAV\\Migration\\Version1031Date20240610134258' => $baseDir . '/../lib/Migration/Version1031Date20240610134258.php',
'OCA\\DAV\\Migration\\Version1034Date20250813093701' => $baseDir . '/../lib/Migration/Version1034Date20250813093701.php',
'OCA\\DAV\\Model\\ExampleEvent' => $baseDir . '/../lib/Model/ExampleEvent.php',
'OCA\\DAV\\Paginate\\LimitedCopyIterator' => $baseDir . '/../lib/Paginate/LimitedCopyIterator.php',
'OCA\\DAV\\Paginate\\PaginateCache' => $baseDir . '/../lib/Paginate/PaginateCache.php',
Expand Down
1 change: 1 addition & 0 deletions apps/dav/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ class ComposerStaticInitDAV
'OCA\\DAV\\Migration\\Version1029Date20231004091403' => __DIR__ . '/..' . '/../lib/Migration/Version1029Date20231004091403.php',
'OCA\\DAV\\Migration\\Version1030Date20240205103243' => __DIR__ . '/..' . '/../lib/Migration/Version1030Date20240205103243.php',
'OCA\\DAV\\Migration\\Version1031Date20240610134258' => __DIR__ . '/..' . '/../lib/Migration/Version1031Date20240610134258.php',
'OCA\\DAV\\Migration\\Version1034Date20250813093701' => __DIR__ . '/..' . '/../lib/Migration/Version1034Date20250813093701.php',
'OCA\\DAV\\Model\\ExampleEvent' => __DIR__ . '/..' . '/../lib/Model/ExampleEvent.php',
'OCA\\DAV\\Paginate\\LimitedCopyIterator' => __DIR__ . '/..' . '/../lib/Paginate/LimitedCopyIterator.php',
'OCA\\DAV\\Paginate\\PaginateCache' => __DIR__ . '/..' . '/../lib/Paginate/PaginateCache.php',
Expand Down
19 changes: 17 additions & 2 deletions apps/dav/lib/DAV/CustomPropertiesBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ class CustomPropertiesBackend implements BackendInterface {
'{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => Href::class,
];

/**
* Map of well-known property names to default values
*/
private const PROPERTY_DEFAULT_VALUES = [
'{http://owncloud.org/ns}calendar-enabled' => '1',
];

/**
* Properties cache
*
Expand Down Expand Up @@ -422,6 +429,14 @@ private function getUserProperties(string $path, array $requestedProperties) {
return $props;
}

private function isPropertyDefaultValue(string $name, mixed $value): bool {
if (!isset(self::PROPERTY_DEFAULT_VALUES[$name])) {
return false;
}

return self::PROPERTY_DEFAULT_VALUES[$name] === $value;
}

/**
* @throws Exception
*/
Expand All @@ -438,8 +453,8 @@ private function updateProperties(string $path, array $properties): bool {
'propertyName' => $propertyName,
];

// If it was null, we need to delete the property
if (is_null($propertyValue)) {
// If it was null or set to the default value, we need to delete the property
if (is_null($propertyValue) || $this->isPropertyDefaultValue($propertyName, $propertyValue)) {
if (array_key_exists($propertyName, $existing)) {
$deleteQuery = $deleteQuery ?? $this->createDeleteQuery();
$deleteQuery
Expand Down
53 changes: 53 additions & 0 deletions apps/dav/lib/Migration/Version1034Date20250813093701.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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 Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Override;

class Version1034Date20250813093701 extends SimpleMigrationStep {
public function __construct(
private IDBConnection $db,
) {
}

/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
*/
#[Override]
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$qb = $this->db->getQueryBuilder();
$qb->delete('properties')
->where($qb->expr()->eq(
'propertyname',
$qb->createNamedParameter(
'{http://owncloud.org/ns}calendar-enabled',
IQueryBuilder::PARAM_STR,
),
IQueryBuilder::PARAM_STR,
))
->andWhere($qb->expr()->eq(
'propertyvalue',
$qb->createNamedParameter(
'1',
IQueryBuilder::PARAM_STR,
),
IQueryBuilder::PARAM_STR,
))
->executeStatement();
}
}
Loading