From:
Operating system: CentOS 5.5 Linux
PHP version: Irrelevant
Package: cURL related
Bug Type: Bug
Bug description:fopen(..., 'xb') and CURLOPT_FILE make cURL fail with:
fopencookie failed
Description:
------------
If I call:
$fh = fopen('/tmp/yahoo.html', 'xb');
$ch = curl_init('http://www.yahoo.com/');
curl_setopt($ch, CURLOPT_FILE, $fh);
then the last line will fail with the misleading fopencookie-message.
I need to use 'xb' and not 'wb', to ensure that just 1 script instance
writes into that file - please see more info here:
http://stackoverflow.com/questions/4096470/php-curl-curl-setopt-fopencookie-failed
Test script:
---------------
<?php
#phpinfo();
$fh = fopen('/tmp/yahoo.html', 'xb');
if ($fh) {
$ch = curl_init('http://www.yahoo.com/');
curl_setopt($ch, CURLOPT_FILE, $fh); # XXX the line 6
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
#curl_setopt($ch, CURLOPT_COOKIEJAR, '/dev/null');
#curl_setopt($ch, CURLOPT_COOKIEFILE, '/dev/null');
#curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
#curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
curl_exec($ch);
if(!curl_errno($ch)) {
$info = curl_getinfo($ch);
echo 'Took '.$info['total_time'] .
's to send a request to '.$info['url'];
}
curl_close($ch);
fclose($fh);
} else {
echo 'Can not open /tmp/yahoo.html';
}
?>
Expected result:
----------------
I expect the script create the file /tmp/yahoo.html on the 1st run and put
the downloaded content into it.
Actual result:
--------------
Nov 4 12:55:19 centos httpd: PHP Fatal error: curl_setopt() [<a
href='function.curl-setopt'>function.curl-setopt</a>]: fopencookie failed
in /var/www/html/proxy3.php on line 6
And the file is sero-sized:
afar...@centos:html> ls -alZ /tmp/yahoo.html
-rw-r--r-- apache apache user_u:object_r:httpd_tmp_t /tmp/yahoo.html
--
Edit bug report at http://bugs.php.net/bug.php?id=53241&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53241&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53241&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53241&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53241&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53241&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53241&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53241&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53241&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53241&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53241&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53241&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53241&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53241&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53241&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53241&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53241&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53241&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53241&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53241&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53241&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53241&r=mysqlcfg