]> source.dussan.org Git - nextcloud-server.git/commitdiff
Convert the card resource to a string if necessary 24114/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Fri, 13 Nov 2020 08:10:35 +0000 (09:10 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Fri, 13 Nov 2020 18:18:24 +0000 (18:18 +0000)
Apparently the fetched column can be a string or resource. Hence we have
to catch the resource type and convert it to a string.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
apps/contactsinteraction/lib/Db/CardSearchDao.php

index 391dca60fabc55ab7acd0bddc754f1743516c804..0636829272b94ad9166c198e29ba618f89c70dc6 100644 (file)
@@ -28,6 +28,8 @@ namespace OCA\ContactsInteraction\Db;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\IDBConnection;
 use OCP\IUser;
+use function is_resource;
+use function stream_get_contents;
 
 class CardSearchDao {
 
@@ -79,12 +81,15 @@ class CardSearchDao {
                        ->andWhere($cardQuery->expr()->in('addressbookid', $cardQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
                        ->setMaxResults(1);
                $result = $cardQuery->execute();
-               /** @var string|false $card */
+               /** @var string|resource|false $card */
                $card = $result->fetchColumn(0);
 
                if ($card === false) {
                        return null;
                }
+               if (is_resource($card)) {
+                       return stream_get_contents($card);
+               }
 
                return $card;
        }