php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81495 ibm PDO Lob stream returns empty objects
Submitted: 2021-10-01 19:19 UTC Modified: 2021-10-04 08:42 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: chofoteddy+php at gmail dot com Assigned:
Status: Open Package: PDO_IBM (PECL)
PHP Version: Irrelevant OS: Linux 5b155b44ab67 5.10.47-linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2021-10-01 19:19 UTC] chofoteddy+php at gmail dot com
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
<

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-10-04 08:42 UTC] cmb@php.net
-Package: PDO related +Package: PDO_IBM
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 10 04:05:44 2022 UTC