php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70311 ZipArchive not generating output
Submitted: 2015-08-20 11:56 UTC Modified: 2015-09-28 12:41 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bergmann at berlitec dot de Assigned:
Status: Closed Package: Zip Related
PHP Version: 5.6.12 OS: Mac OS X 10.10.4
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 !
Your email address:
MUST BE VALID
Solve the problem:
29 - 5 = ?
Subscribe to this entry?

 
 [2015-08-20 11:56 UTC] bergmann at berlitec dot de
Description:
------------
ZipArchive doesn't produce the desired results on my system. I can see a temporary zipfile created but it disappears as soon as my script exits without producing the final zip.

phpinfo()
PHP Version 5.6.12
Zip 	enabled
Extension Version 	$Id: f9f12af1274212b9f22867472e4aa57eab4bb4cf $
Zip version 	1.12.5
Libzip version 	0.11.2 

I was originally executing a phing ZipTask but I made a quick test that revealed ZipArchive itself is bugged for me. Apache mod and cli both are affected.

I tested the behaviour with another 5.4.x installation on my system that ran just fine.

Test script:
---------------
<?php
        
$a = new ZipArchive;
var_dump( $a->open(__DIR__ . '/test.zip', ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) );
$a->addFromString('test.txt', 'test');
var_dump( $a->close() );

Expected result:
----------------
boolean(true)
boolean(true)

test.zip created with a single file test.txt

Actual result:
--------------
boolean(true)
boolean(true)

no zip generated, temporary zip pops up and disappears, no zip in target directory or above, no zip in the trash

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-21 13:14 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2015-08-21 13:14 UTC] cmb@php.net
AIUI, ZipArchive::close() returns TRUE even if the operation
may have failed[1]. What is the result of calling

  var_dump( $a->getStatusString () );
  
at the end of the script?

[1] <https://github.com/php/php-src/blob/php-5.6.12/ext/zip/php_zip.c#L1628-L1637>
 [2015-08-21 13:18 UTC] bergmann at berlitec dot de
@cmb:

Warning: ZipArchive::getStatusString(): Invalid or uninitialized Zip object in ...
 [2015-08-21 15:12 UTC] cmb@php.net
-Status: Feedback +Status: Open
 [2015-08-21 15:12 UTC] cmb@php.net
That had to be expected, because the internal zip_t has already
been closed. Sorry for the noise.

I found that PHP 5.6.12 with libzip 0.11.2 on Linux and Windows
silently fails (the supplied test script reports bool(true) twice)
to create archives, if there are insufficient permissions or the
folder to write to doesn't even exist. That doesn't appear to be
the problem in your case, but anyway there has to be some
indication of the failure.

For debugging purposes consider to modify the relevant code[1]:

    if (zip_close(intern)) {
printf("%s\n", zip_strerror(intern));
        zip_discard(intern);
    }

[1] <https://github.com/php/php-src/blob/php-5.6.12/ext/zip/php_zip.c#L1628-L1630>
 [2015-08-24 11:10 UTC] bergmann at berlitec dot de
@cmd: How do I build php 5.6.12 under OS X? ./configure fails on bison check
2.3 is installed at /usr/bin and 3.0.4 is installed via homebrew

Guess is could install a pre-3.0 version somewhere bot how do I tell configure that new path? --with-bison-prefix? I'm a newbie here.
 [2015-08-24 12:07 UTC] cmb@php.net
You can set the desired bison by giving the path to the executable
in the environment variable YACC. See also `./configure --help`.
bison 3.0.4 is supposed to work.
 [2015-08-24 13:30 UTC] bergmann at berlitec dot de
With that version the zip was created just as expected. I'll try to reinstall my other installation.
 [2015-08-24 14:11 UTC] bergmann at berlitec dot de
Alright, I figured it out. Call me a moron.
I've got a couple symlinks in my project. After removing them the zip is created just fine.

P.S.: Concerning zip, what changed from 5.4 to 5.6? Seems strange that it works in 5.4 but not in 5.6.

P.P.S: Thanks for your time cmb
 [2015-08-24 14:40 UTC] cmb@php.net
> I've got a couple symlinks in my project. After removing them
> the zip is created just fine.

Then the issue might be related to bug #60348.

> Concerning zip, what changed from 5.4 to 5.6? Seems strange that
> it works in 5.4 but not in 5.6.

Which version of libzip do you use for your PHP 5.4? If it's
something else than 0.11.2 that might explain the changed
behavior.
 [2015-09-05 00:55 UTC] cmb@php.net
-Assigned To: cmb +Assigned To:
 [2015-09-21 20:16 UTC] bchen at deltacontrols dot com
Although it's related to symlinks, $a->close() should return FALSE when a zip is failed to generate.

I believe that's a bug fixed in Zip 1.13.0.
https://pecl.php.net/package-changelog.php?package=zip&release=1.13.0

Waiting PHP to include 1.13.1 :)
 [2015-09-28 12:41 UTC] bergmann at berlitec dot de
-Status: Open +Status: Closed
 [2015-09-28 12:41 UTC] bergmann at berlitec dot de
I guess this can be closed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 20:01:31 2024 UTC