diff options
author | Joas Schilling <coding@schilljs.com> | 2020-11-05 10:50:53 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2020-11-10 14:18:02 +0000 |
commit | 19816fe85f0860cb62b451034b873b774be6d5b0 (patch) | |
tree | 8c9fe11afe727eddf567247898e34386e04415e6 /apps/dav | |
parent | 6a5b921284988240d1ca6cb10118cb9cfe9e4ce1 (diff) | |
download | nextcloud-server-19816fe85f0860cb62b451034b873b774be6d5b0.tar.gz nextcloud-server-19816fe85f0860cb62b451034b873b774be6d5b0.zip |
Don't leave cursors open when tests fail
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav')
6 files changed, 42 insertions, 9 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 82c14086833..3115ceea478 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -248,7 +248,10 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))); } - return (int)$query->execute()->fetchColumn(); + $result = $query->execute(); + $column = (int)$result->fetchColumn(); + $result->closeCursor(); + return $column; } /** @@ -2346,7 +2349,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $query->select('synctoken') ->from($table) ->where($query->expr()->eq('id', $query->createNamedParameter($calendarId))); - $syncToken = (int)$query->execute()->fetchColumn(); + $result = $query->execute(); + $syncToken = (int)$result->fetchColumn(); + $result->closeCursor(); $query = $this->db->getQueryBuilder(); $query->insert('calendarchanges') diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 14ade3f16e2..d517e212c3b 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -138,7 +138,10 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->from('addressbooks') ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); - return (int)$query->execute()->fetchColumn(); + $result = $query->execute(); + $column = (int) $result->fetchColumn(); + $result->closeCursor(); + return $column; } /** diff --git a/apps/dav/lib/Migration/BuildCalendarSearchIndex.php b/apps/dav/lib/Migration/BuildCalendarSearchIndex.php index d16873fee20..117cef7d7bf 100644 --- a/apps/dav/lib/Migration/BuildCalendarSearchIndex.php +++ b/apps/dav/lib/Migration/BuildCalendarSearchIndex.php @@ -75,7 +75,9 @@ class BuildCalendarSearchIndex implements IRepairStep { $query = $this->db->getQueryBuilder(); $query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')')) ->from('calendarobjects'); - $maxId = (int)$query->execute()->fetchColumn(); + $result = $query->execute(); + $maxId = (int) $result->fetchColumn(); + $result->closeCursor(); $output->info('Add background job'); $this->jobList->add(BuildCalendarSearchIndexBackgroundJob::class, [ diff --git a/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php b/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php index 2aef1617df8..58e798f42c9 100644 --- a/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php +++ b/apps/dav/lib/Migration/RegisterBuildReminderIndexBackgroundJob.php @@ -86,7 +86,9 @@ class RegisterBuildReminderIndexBackgroundJob implements IRepairStep { $query = $this->db->getQueryBuilder(); $query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')')) ->from('calendarobjects'); - $maxId = (int)$query->execute()->fetchColumn(); + $result = $query->execute(); + $maxId = (int) $result->fetchColumn(); + $result->closeCursor(); $output->info('Add background job'); $this->jobList->add(BuildReminderIndexBackgroundJob::class, [ diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php index 95617001b31..abcec14fb73 100644 --- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php +++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php @@ -549,7 +549,12 @@ class CardDavBackendTest extends TestCase { $this->invokePrivate($backend, 'updateProperties', [$bookId, $cardUri, $vCard->serialize()]); $query = $this->db->getQueryBuilder(); - $result = $query->select('*')->from('cards_properties')->execute()->fetchAll(); + $query->select('*') + ->from('cards_properties'); + + $qResult = $query->execute(); + $result = $qResult->fetchAll(); + $qResult->closeCursor(); $this->assertSame(2, count($result)); @@ -569,7 +574,12 @@ class CardDavBackendTest extends TestCase { $this->invokePrivate($backend, 'updateProperties', [$bookId, $cardUri, $vCard->serialize()]); $query = $this->db->getQueryBuilder(); - $result = $query->select('*')->from('cards_properties')->execute()->fetchAll(); + $query->select('*') + ->from('cards_properties'); + + $qResult = $query->execute(); + $result = $qResult->fetchAll(); + $qResult->closeCursor(); $this->assertSame(1, count($result)); @@ -609,7 +619,13 @@ class CardDavBackendTest extends TestCase { $this->invokePrivate($this->backend, 'purgeProperties', [1, 1]); $query = $this->db->getQueryBuilder(); - $result = $query->select('*')->from('cards_properties')->execute()->fetchAll(); + $query->select('*') + ->from('cards_properties'); + + $qResult = $query->execute(); + $result = $qResult->fetchAll(); + $qResult->closeCursor(); + $this->assertSame(1, count($result)); $this->assertSame(1 ,(int)$result[0]['addressbookid']); $this->assertSame(2 ,(int)$result[0]['cardid']); diff --git a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php index 3e22193fcbf..2633ccf544f 100644 --- a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php @@ -109,7 +109,12 @@ class CustomPropertiesBackendTest extends TestCase { ->from('properties') ->where($query->expr()->eq('userid', $query->createNamedParameter($user))) ->where($query->expr()->eq('propertypath', $query->createNamedParameter($this->formatPath($path)))); - return $query->execute()->fetchAll(\PDO::FETCH_KEY_PAIR); + + + $result = $query->execute(); + $data = $result->fetchAll(\PDO::FETCH_KEY_PAIR); + $result->closeCursor(); + return $data; } public function testPropFindNoDbCalls() { |