@@ -242,8 +242,13 @@ public function getCalendarsForUserCount($principalUri, $excludeBirthday = true)
242242 $ principalUri = $ this ->convertPrincipal ($ principalUri , true );
243243 $ query = $ this ->db ->getQueryBuilder ();
244244 $ query ->select ($ query ->func ()->count ('* ' ))
245- ->from ('calendars ' )
246- ->where ($ query ->expr ()->eq ('principaluri ' , $ query ->createNamedParameter ($ principalUri )));
245+ ->from ('calendars ' );
246+
247+ if ($ principalUri === '' ) {
248+ $ query ->where ($ query ->expr ()->emptyString ('principaluri ' ));
249+ } else {
250+ $ query ->where ($ query ->expr ()->eq ('principaluri ' , $ query ->createNamedParameter ($ principalUri )));
251+ }
247252
248253 if ($ excludeBirthday ) {
249254 $ query ->andWhere ($ query ->expr ()->neq ('uri ' , $ query ->createNamedParameter (BirthdayService::BIRTHDAY_CALENDAR_URI )));
@@ -293,13 +298,21 @@ public function getCalendarsForUser($principalUri) {
293298
294299 // Making fields a comma-delimited list
295300 $ query = $ this ->db ->getQueryBuilder ();
296- $ query ->select ($ fields )->from ('calendars ' )
297- ->where ($ query ->expr ()->eq ('principaluri ' , $ query ->createNamedParameter ($ principalUri )))
298- ->orderBy ('calendarorder ' , 'ASC ' );
299- $ stmt = $ query ->execute ();
301+ $ query ->select ($ fields )
302+ ->from ('calendars ' )
303+ ->orderBy ('calendarorder ' , 'ASC ' );
304+
305+ if ($ principalUri === '' ) {
306+ $ query ->where ($ query ->expr ()->emptyString ('principaluri ' ));
307+ } else {
308+ $ query ->where ($ query ->expr ()->eq ('principaluri ' , $ query ->createNamedParameter ($ principalUri )));
309+ }
310+
311+ $ result = $ query ->execute ();
300312
301313 $ calendars = [];
302- while ($ row = $ stmt ->fetch (\PDO ::FETCH_ASSOC )) {
314+ while ($ row = $ result ->fetch ()) {
315+ $ row ['principaluri ' ] = (string ) $ row ['principaluri ' ];
303316 $ components = [];
304317 if ($ row ['components ' ]) {
305318 $ components = explode (', ' ,$ row ['components ' ]);
@@ -326,8 +339,7 @@ public function getCalendarsForUser($principalUri) {
326339 $ calendars [$ calendar ['id ' ]] = $ calendar ;
327340 }
328341 }
329-
330- $ stmt ->closeCursor ();
342+ $ result ->closeCursor ();
331343
332344 // query for shared calendars
333345 $ principals = $ this ->principalBackend ->getGroupMembership ($ principalUriOriginal , true );
@@ -347,17 +359,19 @@ public function getCalendarsForUser($principalUri) {
347359 $ fields [] = 'a.transparent ' ;
348360 $ fields [] = 's.access ' ;
349361 $ query = $ this ->db ->getQueryBuilder ();
350- $ result = $ query ->select ($ fields )
362+ $ query ->select ($ fields )
351363 ->from ('dav_shares ' , 's ' )
352364 ->join ('s ' , 'calendars ' , 'a ' , $ query ->expr ()->eq ('s.resourceid ' , 'a.id ' ))
353365 ->where ($ query ->expr ()->in ('s.principaluri ' , $ query ->createParameter ('principaluri ' )))
354366 ->andWhere ($ query ->expr ()->eq ('s.type ' , $ query ->createParameter ('type ' )))
355367 ->setParameter ('type ' , 'calendar ' )
356- ->setParameter ('principaluri ' , $ principals , \Doctrine \DBAL \Connection::PARAM_STR_ARRAY )
357- ->execute ();
368+ ->setParameter ('principaluri ' , $ principals , \Doctrine \DBAL \Connection::PARAM_STR_ARRAY );
369+
370+ $ result = $ query ->execute ();
358371
359372 $ readOnlyPropertyName = '{ ' . \OCA \DAV \DAV \Sharing \Plugin::NS_OWNCLOUD . '}read-only ' ;
360373 while ($ row = $ result ->fetch ()) {
374+ $ row ['principaluri ' ] = (string ) $ row ['principaluri ' ];
361375 if ($ row ['principaluri ' ] === $ principalUri ) {
362376 continue ;
363377 }
@@ -428,6 +442,7 @@ public function getUsersOwnCalendars($principalUri) {
428442 $ stmt = $ query ->execute ();
429443 $ calendars = [];
430444 while ($ row = $ stmt ->fetch (\PDO ::FETCH_ASSOC )) {
445+ $ row ['principaluri ' ] = (string ) $ row ['principaluri ' ];
431446 $ components = [];
432447 if ($ row ['components ' ]) {
433448 $ components = explode (', ' ,$ row ['components ' ]);
@@ -497,6 +512,7 @@ public function getPublicCalendars() {
497512 ->execute ();
498513
499514 while ($ row = $ result ->fetch ()) {
515+ $ row ['principaluri ' ] = (string ) $ row ['principaluri ' ];
500516 list (, $ name ) = Uri \split ($ row ['principaluri ' ]);
501517 $ row ['displayname ' ] = $ row ['displayname ' ] . "( $ name) " ;
502518 $ components = [];
@@ -563,6 +579,7 @@ public function getPublicCalendar($uri) {
563579 throw new NotFound ('Node with name \'' . $ uri . '\' could not be found ' );
564580 }
565581
582+ $ row ['principaluri ' ] = (string ) $ row ['principaluri ' ];
566583 list (, $ name ) = Uri \split ($ row ['principaluri ' ]);
567584 $ row ['displayname ' ] = $ row ['displayname ' ] . ' ' . "( $ name) " ;
568585 $ components = [];
@@ -619,6 +636,7 @@ public function getCalendarByUri($principal, $uri) {
619636 return null ;
620637 }
621638
639+ $ row ['principaluri ' ] = (string ) $ row ['principaluri ' ];
622640 $ components = [];
623641 if ($ row ['components ' ]) {
624642 $ components = explode (', ' ,$ row ['components ' ]);
@@ -669,6 +687,7 @@ public function getCalendarById($calendarId) {
669687 return null ;
670688 }
671689
690+ $ row ['principaluri ' ] = (string ) $ row ['principaluri ' ];
672691 $ components = [];
673692 if ($ row ['components ' ]) {
674693 $ components = explode (', ' ,$ row ['components ' ]);
@@ -718,6 +737,7 @@ public function getSubscriptionById($subscriptionId) {
718737 return null ;
719738 }
720739
740+ $ row ['principaluri ' ] = (string ) $ row ['principaluri ' ];
721741 $ subscription = [
722742 'id ' => $ row ['id ' ],
723743 'uri ' => $ row ['uri ' ],
@@ -965,6 +985,7 @@ public function getCalendarObjects($calendarId, $calendarType = self::CALENDAR_T
965985 'classification ' => (int )$ row ['classification ' ]
966986 ];
967987 }
988+ $ stmt ->closeCursor ();
968989
969990 return $ result ;
970991 }
@@ -995,6 +1016,7 @@ public function getCalendarObject($calendarId, $objectUri, $calendarType = self:
9951016 ->andWhere ($ query ->expr ()->eq ('calendartype ' , $ query ->createNamedParameter ($ calendarType )));
9961017 $ stmt = $ query ->execute ();
9971018 $ row = $ stmt ->fetch (\PDO ::FETCH_ASSOC );
1019+ $ stmt ->closeCursor ();
9981020
9991021 if (!$ row ) {
10001022 return null ;
0 commit comments