Bug #77067 [NEW]: Inserting a BLOB from a stream transforms it to a string

From: Date: Fri, 26 Oct 2018 14:14:35 +0000
Subject: Bug #77067 [NEW]: Inserting a BLOB from a stream transforms it to a string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217697@lists.php.net to get a copy of this message
From:             php at bohwaz dot net
Operating system: All
PHP version:      7.3.0RC4
Package:          PDO SQLite
Bug Type:         Bug
Bug description:Inserting a BLOB from a stream transforms it to a string

Description:
------------
If passing a stream as a parameter of PDOStatement::bindParam it is
transformed to a string which contains the stream contents.

For example this prevents reusing the stream handle to close it properly
or to truncate or change the file contents.

Test script:
---------------
<?php

$pdo = new PDO('sqlite::memory:');
$pdo->exec('CREATE TABLE test (a INTEGER, b BLOB);');

$fp = tmpfile();
fwrite($fp, 'Random stuff!');
fseek($fp, 0);

$stmt = $pdo->prepare('INSERT INTO test VALUES (?, ?);');
$stmt->bindValue(1, 42);
$stmt->bindParam(2, $fp, PDO::PARAM_LOB);

$stmt->execute();

var_dump(gettype($fp));

Expected result:
----------------
resource

Actual result:
--------------
string

-- 
Edit bug report at https://bugs.php.net/bug.php?id=77067&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=77067&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=77067&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=77067&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=77067&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=77067&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=77067&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=77067&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=77067&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=77067&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=77067&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=77067&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=77067&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=77067&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77067&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=77067&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=77067&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=77067&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77067&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=77067&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=77067&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#217697) next »