From e5469a1121e927806cabf5577f2d4d13c1f63022 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20M=C3=BCller?= Date: Mon, 14 Dec 2015 11:48:31 +0100 Subject: [PATCH] Fix Oracle insert error --- apps/dav/lib/carddav/carddavbackend.php | 5 +++-- apps/dav/tests/unit/carddav/carddavbackendtest.php | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/dav/lib/carddav/carddavbackend.php b/apps/dav/lib/carddav/carddavbackend.php index bbd76ae37ac..7f7d458d560 100644 --- a/apps/dav/lib/carddav/carddavbackend.php +++ b/apps/dav/lib/carddav/carddavbackend.php @@ -29,6 +29,7 @@ use Sabre\CardDAV\Backend\BackendInterface; use Sabre\CardDAV\Backend\SyncSupport; use Sabre\CardDAV\Plugin; use Sabre\DAV\Exception\BadRequest; +use Sabre\VObject\Component\VCard; use Sabre\VObject\Reader; class CardDavBackend implements BackendInterface, SyncSupport { @@ -431,7 +432,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { $query = $this->db->getQueryBuilder(); $query->insert('cards') ->values([ - 'carddata' => $query->createNamedParameter($cardData), + 'carddata' => $query->createNamedParameter($cardData, \PDO::PARAM_LOB), 'uri' => $query->createNamedParameter($cardUri), 'lastmodified' => $query->createNamedParameter(time()), 'addressbookid' => $query->createNamedParameter($addressBookId), @@ -688,7 +689,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { */ public function search($addressBookId, $pattern, $searchProperties) { $query = $this->db->getQueryBuilder(); - $query->selectDistinct('carddata', 'c') + $query->selectDistinct(['carddata', 'c']) ->from($this->dbCardsTable, 'c') ->leftJoin('c', $this->dbCardsPropertiesTable, 'cp', $query->expr()->eq('cp.cardid', 'c.id')); foreach ($searchProperties as $property) { diff --git a/apps/dav/tests/unit/carddav/carddavbackendtest.php b/apps/dav/tests/unit/carddav/carddavbackendtest.php index 0e17d8a40ba..8feba950b72 100644 --- a/apps/dav/tests/unit/carddav/carddavbackendtest.php +++ b/apps/dav/tests/unit/carddav/carddavbackendtest.php @@ -20,6 +20,7 @@ */ namespace OCA\DAV\Tests\Unit\CardDAV; +use InvalidArgumentException; use OCA\DAV\CardDAV\CardDavBackend; use OCA\DAV\Connector\Sabre\Principal; use OCP\IDBConnection; @@ -126,6 +127,7 @@ class CardDavBackendTest extends TestCase { public function testCardOperations() { + /** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $backend */ $backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend') ->setConstructorArgs([$this->db, $this->principal, $this->logger]) ->setMethods(['updateProperties', 'purgeProperties'])->getMock(); @@ -392,6 +394,7 @@ class CardDavBackendTest extends TestCase { * @param array $expected */ public function testSearch($pattern, $expected) { + /** @var VCard $vCards */ $vCards = []; $vCards[0] = new VCard(); $vCards[0]->add(new Text($vCards[0], 'UID', 'uid')); @@ -407,9 +410,9 @@ class CardDavBackendTest extends TestCase { ->values( [ 'addressbookid' => $query->createNamedParameter(0), - 'carddata' => $query->createNamedParameter($vCards[$i]->serialize()), + 'carddata' => $query->createNamedParameter($vCards[$i]->serialize(), \PDO::PARAM_LOB), 'uri' => $query->createNamedParameter('uri' . $i), - 'lastmodified' => $query->createNamedParameter(5489543), + 'lastmodified' => $query->createNamedParameter(time()), 'etag' => $query->createNamedParameter('etag' . $i), 'size' => $query->createNamedParameter(120), ] -- 2.39.5