|  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
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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
30 - 6 = ?
Subscribe to this entry?

 [2007-08-24 10:50 UTC] twan at bitpress dot nl
PHP fails to create a zip file when opening an output stream (as detailed on ) 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/", ZIPARCHIVE::CREATE);
$rZip->addFromString($sFileName, $sStr);


Expected result:
When I run the script with the fixed file name ('/tmp/') 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] => )


Add a Patch

Pull Requests

Add a Pull Request


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-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 24 19:03:38 2021 UTC