From c5e8ffb53d3aaa59542a517fb44b4f3c12fd4035 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 6 Jul 2022 09:53:59 +0200 Subject: [PATCH] Fix reading blob data as resource PostgreSQL returns data as resource when using IQueryBuilder::PARAM_LOB (which is used for QBMapper). Previously we just converted this resource using settype, which produced things like "Resource id #14" instead of the actual resource data. Now we read the stream correctly if the returned data is a resource See context at #22472 Fixes #22439 Signed-off-by: Thomas Citharel --- lib/public/AppFramework/Db/Entity.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/public/AppFramework/Db/Entity.php b/lib/public/AppFramework/Db/Entity.php index a059e3a27b0cb..dcd1c77c042cf 100644 --- a/lib/public/AppFramework/Db/Entity.php +++ b/lib/public/AppFramework/Db/Entity.php @@ -113,6 +113,9 @@ protected function setter($name, $args) { $type = $this->_fieldTypes[$name]; if ($type === 'blob') { // (B)LOB is treated as string when we read from the DB + if (is_resource($args[0])) { + $args[0] = stream_get_contents($args[0]); + } $type = 'string'; }