php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #57796 Close fails when using PHP input/output stream
Submitted: 2007-08-24 10:50 UTC Modified: 2007-08-24 13:55 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: twan at bitpress dot nl Assigned: pajoye (profile)
Status: Suspended Package: zip (PECL)
PHP Version: 5.2.0 OS: Debian Etch
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-08-24 10:50 UTC] twan at bitpress dot nl
Description:
------------
PHP fails to create a zip file when opening an output stream (as detailed on http://www.php.net/manual/en/wrappers.php.php ) rather than a fixed file. The object fails with a ZIPARCHIVE::ER_TMPOPEN on the close method.

I'm guessing - with my rusty C knowledge - this is due to the fact that there's no directory info passed along to create the temporary file in the following source line:

snprintf(temp, len, "%s.XXXXXX", za->zn);
(zip_close.c, 537)

However, attempts to set wide permissions on the current directory (the one the script resides in) or playing with chdir() have not solved the issue.

Reproduce code:
---------------
$sStr = "Test string";
$sFileName = "textfile.txt";

$rZip = new ZipArchive();
$rZip->open("php://temp/maxmemory:".(5 * 1024 * 1024), ZIPARCHIVE::CREATE);
//$rZip->open("/tmp/temp.zip", ZIPARCHIVE::CREATE);
$rZip->addFromString($sFileName, $sStr);
$rZip->close();

print_r($rZip);


Expected result:
----------------
When I run the script with the fixed file name ('/tmp/temp.zip') the output of the print_r is as follows:

ZipArchive Object ( [status] => 0 [statusSys] => 0 [numFiles] => 0 [filename] => [comment] => )

The file is created properly.

Actual result:
--------------
When I run the script with the stream, the stream remains empty (no file is present afterwards) and the print_r gives:

ZipArchive Object ( [status] => 12 [statusSys] => 2 [numFiles] => 1 [filename] => [comment] => )

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-24 13:55 UTC] pierre dot php at gmail dot com
Only real file system path are supported, custom streams or wrapper does not work.

However it is planed to add php stream support (read and write).
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun May 19 16:01:26 2019 UTC