Convert the card resource to a string if necessary

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>
This commit is contained in:
Christoph Wurst 2020-11-13 09:10:35 +01:00
parent 25f8d76f26
commit cb5bb693de
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
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\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;
}