[PHP-BUG] Bug #71225 [NEW]: curl_setopt() fails to set CURLOPT_POSTFIELDS with reference to CURLFile
[email protected] ("bugs dot php dot net at ss dot st dot tc")
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
From: bugs dot php dot net at ss dot st dot tc
Operating system: Linux, OS X
PHP version: 7.0.1
Package: cURL related
Bug Type: Bug
Bug description:curl_setopt() fails to set CURLOPT_POSTFIELDS with reference to CURLFile
Description:
------------
PHP 5 acts as expected, PHP 7 fails.
Test script:
---------------
<?php
$post_data_1 = [ 'file' => new CURLFile('file.txt') ];
$curl_1 = curl_init();
curl_setopt($curl_1, CURLOPT_POSTFIELDS, $post_data_1);
echo "OK\n";
// exactly the same as above + added a reference to 'file' element
$post_data_2 = [ 'file' => new CURLFile('file.txt') ];
$ref = & $post_data_2['file']; // ***
$curl_2 = curl_init();
curl_setopt($curl_2, CURLOPT_POSTFIELDS, $post_data_2);
echo "OK\n";
Expected result:
----------------
PHP 5:
OK
OK
PHP 7:
OK
OK
Actual result:
--------------
PHP 5:
OK
OK
PHP 7:
OK
Catchable fatal error: Object of class CURLFile could not be converted
to string in wtf.php on line 12
--
Edit bug report at https://bugs.php.net/bug.php?id=71225&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71225&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71225&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71225&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71225&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71225&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71225&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71225&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71225&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71225&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71225&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71225&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71225&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71225&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71225&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71225&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71225&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71225&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71225&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71225&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71225&r=mysqlcfg