Merge pull request #24115 from nextcloud/backport/24096/stable19

[stable19] Convert the card resource to a string if necessary
This commit is contained in:
Roeland Jago Douma 2020-11-16 12:15:15 +01:00 committed by GitHub
commit 20b3025022
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

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