summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-11-09 10:40:55 +0100
committerJoas Schilling <coding@schilljs.com>2020-11-10 15:35:16 +0100
commit31e243be744aa726178a5ecb15649e7675a049d4 (patch)
treea8736d2f71ab7c727109263b34ba3bbac5f135c3
parentecbb066dec9d08c371ffd85f3bd387357b1000e7 (diff)
downloadnextcloud-server-31e243be744aa726178a5ecb15649e7675a049d4.tar.gz
nextcloud-server-31e243be744aa726178a5ecb15649e7675a049d4.zip
Fix public calendars as they are stored with null on oracle
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php46
1 files changed, 34 insertions, 12 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index 4ff51a5f527..84294971b41 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -242,8 +242,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$principalUri = $this->convertPrincipal($principalUri, true);
$query = $this->db->getQueryBuilder();
$query->select($query->func()->count('*'))
- ->from('calendars')
- ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
+ ->from('calendars');
+
+ if ($principalUri === '') {
+ $query->where($query->expr()->emptyString('principaluri'));
+ } else {
+ $query->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
+ }
if ($excludeBirthday) {
$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
@@ -293,13 +298,21 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
// Making fields a comma-delimited list
$query = $this->db->getQueryBuilder();
- $query->select($fields)->from('calendars')
- ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)))
- ->orderBy('calendarorder', 'ASC');
- $stmt = $query->execute();
+ $query->select($fields)
+ ->from('calendars')
+ ->orderBy('calendarorder', 'ASC');
+
+ if ($principalUri === '') {
+ $query->where($query->expr()->emptyString('principaluri'));
+ } else {
+ $query->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
+ }
+
+ $result = $query->execute();
$calendars = [];
- while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ while ($row = $result->fetch()) {
+ $row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
@@ -326,8 +339,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$calendars[$calendar['id']] = $calendar;
}
}
-
- $stmt->closeCursor();
+ $result->closeCursor();
// query for shared calendars
$principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
@@ -347,17 +359,19 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$fields[] = 'a.transparent';
$fields[] = 's.access';
$query = $this->db->getQueryBuilder();
- $result = $query->select($fields)
+ $query->select($fields)
->from('dav_shares', 's')
->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri')))
->andWhere($query->expr()->eq('s.type', $query->createParameter('type')))
->setParameter('type', 'calendar')
- ->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
- ->execute();
+ ->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY);
+
+ $result = $query->execute();
$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
while ($row = $result->fetch()) {
+ $row['principaluri'] = (string) $row['principaluri'];
if ($row['principaluri'] === $principalUri) {
continue;
}
@@ -428,6 +442,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$stmt = $query->execute();
$calendars = [];
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ $row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
@@ -497,6 +512,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
->execute();
while ($row = $result->fetch()) {
+ $row['principaluri'] = (string) $row['principaluri'];
list(, $name) = Uri\split($row['principaluri']);
$row['displayname'] = $row['displayname'] . "($name)";
$components = [];
@@ -563,6 +579,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
throw new NotFound('Node with name \'' . $uri . '\' could not be found');
}
+ $row['principaluri'] = (string) $row['principaluri'];
list(, $name) = Uri\split($row['principaluri']);
$row['displayname'] = $row['displayname'] . ' ' . "($name)";
$components = [];
@@ -619,6 +636,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
return null;
}
+ $row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
@@ -669,6 +687,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
return null;
}
+ $row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
@@ -718,6 +737,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
return null;
}
+ $row['principaluri'] = (string) $row['principaluri'];
$subscription = [
'id' => $row['id'],
'uri' => $row['uri'],
@@ -965,6 +985,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
'classification' => (int)$row['classification']
];
}
+ $stmt->closeCursor();
return $result;
}
@@ -995,6 +1016,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType)));
$stmt = $query->execute();
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
+ $stmt->closeCursor();
if (!$row) {
return null;