From:             
Operating system: Windows 7 Professional 32bit
PHP version:      5.3.6
Package:          PHAR related
Bug Type:         Bug
Bug description:PharData::buildFromDirectory does not seem to close the file 
after archiving

Description:
------------
While I can create a file, write to it, close it, and delete it via unlink,
I 
can't delete a file created by the buildFromDirectory function of PharData.
I 
suspect that the file has been left open.

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

$file = uniqid().".txt"; /// Demo: Script can create and delete a file (if
properly closed) normally
if( !($f = fopen($file, 'w')) ) echo "Could not open $file <br />\n";
if( !fwrite($f, 'test') )       echo "Could not write to $file <br />\n";
if( !fclose($f) )               echo "Could not close $file <br />\n";
if( !unlink($file) )            echo "Could not delete $file <br />\n";

if( !is_dir( $dir = dirname(__FILE__) . '/phartest' ) ) { /// Create test
directory for PharData
    mkdir( dirname(__FILE__) . '/phartest' );
    for($i = 0; $i < 3; $i++) { $f = fopen($dir . "/file$i.txt", 'w');
fwrite($f, $i); fclose($f); };
}

$file2 = uniqid().".zip"; /// Create test archive in the same directory as
the demo file
$phar = new PharData($file2);
if( $phar->buildFromDirectory($dir) )
    if(!unlink($file2)) /// Did phar close the file? Can we delete it?
        echo "Could not delete $file2!";
?>

Expected result:
----------------
I expect that the call to unlink($file2) will delete the newly created
archive 
(with filename $file2)

Actual result:
--------------
Warning: unlink(<$file2>): Permission denied in C:\htdocs\phartest.php on
line 17 
Could not delete <$file2>!

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

Reply via email to