Bug #75066 [Csd->Nab]: Result of PharData::convertData produces undeletable file
| From: | requinix@php.net | Date: | Sat, 12 Aug 2017 13:53:55 +0000 |
| Subject: | Bug #75066 [Csd->Nab]: Result of PharData::convertData produces undeletable file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210630@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75066&edit=1
ID: 75066
Updated by: requinix@php.net
Reported by: csongor at halmai dot hu
Summary: Result of PharData::convertData produces undeletable
file
-Status: Closed
+Status: Not a bug
Type: Bug
Package: PHAR related
Operating System: Windows 7
PHP Version: 7.0.22
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2017-08-12 11:44:45] csongor at halmai dot hu
Oh, sorry, I think I misunderstood how it is supposed to work. It's OK now. Thanks.
------------------------------------------------------------------------
[2017-08-12 11:16:21] requinix@php.net
You posted the error message so you must now be aware that you cannot unlink an archive if it has an
open file handle or Phar object. That means you can't remove x.tgz because of $phar, or x.zip
because of $zip.
So why do you think either should be deleteable?
------------------------------------------------------------------------
[2017-08-12 11:05:44] csongor at halmai dot hu
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 this bug report at https://bugs.php.net/bug.php?id=75066&edit=1