diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-11-10 15:15:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 15:15:03 +0100 |
commit | f23c2162ad2d2883f08cc88c600a7d2ed4bd8a93 (patch) | |
tree | d8bcdf4ad04525f62f8ad5a43d5b9ba6cc698a08 /apps/dav | |
parent | 10aa22dd45c10b7d7729f648dc8e65efb0d937ec (diff) | |
parent | 8027dcbc6f6b1653f5ebcf04b1862ac1e1f51d32 (diff) | |
download | nextcloud-server-f23c2162ad2d2883f08cc88c600a7d2ed4bd8a93.tar.gz nextcloud-server-f23c2162ad2d2883f08cc88c600a7d2ed4bd8a93.zip |
Merge pull request #23993 from nextcloud/bugfix/noid/close-cursors
Don't leave cursors open
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 8b66420560d..4ff51a5f527 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -249,7 +249,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; } /** @@ -2347,7 +2350,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 b9aecbd1c36..bd881eb06c2 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 fe83a41038c..a8c7a781724 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() { |