Bug #75066 [NEW]: Result of PharData::convertData produces undeletable file

From: Date: Sat, 12 Aug 2017 11:05:53 +0000
Subject: Bug #75066 [NEW]: Result of PharData::convertData produces undeletable file
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210626@lists.php.net to get a copy of this message
From:             csongor at halmai dot hu
Operating system: Windows 7
PHP version:      7.0.22
Package:          PHAR related
Bug Type:         Bug
Bug description:Result of PharData::convertData produces undeletable file

Description:
------------
Executing the sample script on Windows 7 with php 7.0.4 (sorry, I cannot
try a newer version), produces a ZIP file that cannot be deleted by the
same script. 

The unlink() reports a "Permission denied" error message. 

If I uncomment the line of the unlinkArchive() then I get "PHP Fatal
error:  Uncaught PharException: phar archive "x.zip" has open file
handles or objects.  fclose() all file handles, and unset() all objects
prior to calling unlinkArchive() in ....php:8"

I cannot unlink the tgz either, the messages are the same. 

When the script finishes then the file can be deleted after that.

The same script on an old Linux with php 5.5.16 works well, the zip file
can be deleted without any issue. 

Test script:
---------------
<?php
	$tgzName = 'x.tgz';
	$zipName = 'x.zip';
	
	$phar    = new PharData($tgzName);
	$zip     = $phar->convertToData(Phar::ZIP);
	
	// PharData::unlinkArchive($tgzName);  // this also fails
	unlink($zipName);    // this fails.

Expected result:
----------------
The created *.zip file should be able to be deleted. 

Actual result:
--------------
"Permission denied" if only the unlink() is called.

PharException is thrown if unlinkArchive() is called before invoking
unlink().


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



Thread (4 messages)

« previous php.bugs (#210626) next »