Bug #81495 [NEW]: ibm PDO Lob stream returns empty objects
| From: | chofoteddy+php at gmail dot com | Date: | Fri, 01 Oct 2021 19:19:23 +0000 |
| Subject: | Bug #81495 [NEW]: ibm PDO Lob stream returns empty objects | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-236981@lists.php.net to get a copy of this message | ||
From: chofoteddy+php at gmail dot com
Operating system: Linux 5b155b44ab67 5.10.47-linux
PHP version: Irrelevant
Package: PDO related
Bug Type: Bug
Bug description:ibm PDO Lob stream returns empty objects
Description:
------------
I'm connecting DB2 using PDO IBM library, the main idea is to make a
HTTP request to a download-file URI and download the file offer by
endpoint.
At these moments we are getting an empty result, a 0 length value, we
tried with different PHP versions (7.3, 7.4, 8.0) and the results didn't
change, also we tried using old versions of PDO_IBM library (1.3.5 and
1.3.6).
Test script:
---------------
// PDO IBM 1.4.1
$db = new PDO(
'ibm:DRIVER={IBM DB2 ODBC DRIVER};DATABASE=mydb;' .
'HOSTNAME=db2.host.url;PORT=50000;UID=user;PWD=pass',
);
$sth = $db->query('SELECT id, attachment FROM my.attachment WITH UR');
$row = $sth->fetch(PDO::FETCH_ASSOC);
$blob = $row['ATTACHMENT'];
$stat = fstat($blob);
$content = stream_get_contents($blob);
if ($stat !== false && !empty($content)) {
header('Content-Length: ' . $stat['size']);
fpassthru($blob);
}
Expected result:
----------------
As a developer I want once the file is obtained from db it must be
returned to HTTP body response, so that I can be able to save the file
in my PC.
> GET / HTTP/1.1
> Host: localhost:8080/download-file
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 01 Oct 2021 18:23:29 GMT
< Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1g
PHP/7.4.6
< X-Powered-By: PHP/7.4.6
< Content-Length: 1024
< Content-Type: text/html; charset=UTF-8
< â¦
<
Actual result:
--------------
Empty results.
> GET / HTTP/1.1
> Host: localhost:8080/download-file
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 01 Oct 2021 18:23:29 GMT
< Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1g
PHP/7.4.6
< X-Powered-By: PHP/7.4.6
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
<
--
Edit bug report at https://bugs.php.net/bug.php?id=81495&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81495&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81495&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81495&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81495&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81495&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81495&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81495&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81495&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81495&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81495&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81495&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81495&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81495&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81495&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81495&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81495&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81495&r=mysqlcfg