From:             niraj at bhawnani dot name
Operating system: Windows Vista
PHP version:      5.3.0
PHP Bug Type:     Filesystem function related
Bug description:  cURL's CURLOPT_FILE prevents file from being deleted after 
fclose

Description:
------------
I spent hours debugging some code I'd written that wasn't working only to
find that cURL is behaving strangely. I've taken the minimal parts of that
code and put it in this bug report.

Basically, if you open a file with fopen, fclose it and then unlink it, it
works fine. But if between fopen and fclose, you give the file handle to
cURL to do some writing into the file, then the unlink fails. Why this is
happening is beyond me. I think it may be related to Bug #48676

I have not had the opportunity to test this on Linux, so I don't know if
it's Windows-only.

Reproduce code:
---------------
<?php
$filename = 'tempfile';
$fp = fopen($filename, 'w');
if (!$fp)
        exit("Failed to open file for writing");
$curl = curl_init('http://bugs.php.net/gifs/logo-bug.gif');
curl_setopt($curl, CURLOPT_FILE, $fp);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); // 10 sec
curl_setopt($curl, CURLOPT_TIMEOUT, 600); // 10 mins
curl_exec($curl);
curl_close($curl);
fclose($fp);
unlink($filename);
?>

Expected result:
----------------
No errors, file unlinks successfully.

Actual result:
--------------
Warning: unlink(tempfile) [function.unlink]: Permission denied in
C:\...\blah.php on line 14


-- 
Edit bug report at http://bugs.php.net/?id=49517&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49517&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49517&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49517&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49517&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49517&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49517&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49517&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49517&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49517&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49517&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49517&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49517&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49517&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49517&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49517&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49517&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49517&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49517&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49517&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49517&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49517&r=mysqlcfg

Reply via email to