Edit report at http://bugs.php.net/bug.php?id=53854&edit=1
ID: 53854
Updated by: pajoye@php.net
Reported by: rquadling@php.net
Summary: Missing constants for compression type.
Status: Assigned
Type: Bug
Package: Zip Related
Operating System: n/a
PHP Version: 5.3SVN-2011-01-27 (SVN)
Assigned To: aharvey
Block user comment: N
Private report: N
New Comment:
Let try to keep this discussion sane...:
We can keep them only if it is supported at least to read the
information about
an entry. For example, if an entry uses LZ77, then doing a stat/reading
the info
MUST return CW_LZ77.
If that's not the case, then we must remove them as it makes no sense to
expose
them to the user.
Is it more clear now? :)
Previous Comments:
------------------------------------------------------------------------
[2011-01-28 12:11:02] rquadling@php.net
Just as an aside, the error constants that ARE documented ... I can see
no way to
generate them. None of the methods or functions in php_zip return an
error
constant. Should these be removed?
------------------------------------------------------------------------
[2011-01-28 12:06:05] pajoye@php.net
That's what I asked. We can keep them only and only if libzip detects
AND uses
these compression types correctly. It seems to be the case. Can you
confirm it and
maybe add a test per compression method?
------------------------------------------------------------------------
[2011-01-28 12:03:35] rquadling@php.net
I took a file (an uncompressed WAV file) and compressed it using WinZip
V15 using different algorithms.
Using the following code ...
<?php
$zip = new ZipArchive;
$zip->open('wav.zipx');
foreach(range(0, $zip->numFiles - 1) as $index) {
print_r($stat = $zip->statIndex($index));
$zip->extractTo('.', array($stat['name']));
echo $zip->getStatusString(), PHP_EOL;
}
$zip->close();
Outputs ...
Array
(
[name] => WavPack.wav
[index] => 0
[crc] => 1384274557
[size] => 154826
[mtime] => 1296208410
[comp_size] => 45366
[comp_method] => 97
)
Compression method not supported
Array
(
[name] => PPMD.wav
[index] => 1
[crc] => 1384274557
[size] => 154826
[mtime] => 1296208410
[comp_size] => 100729
[comp_method] => 98
)
Compression method not supported
Array
(
[name] => LZMA.wav
[index] => 2
[crc] => 1384274557
[size] => 154826
[mtime] => 1296208410
[comp_size] => 68162
[comp_method] => 14
)
Compression method not supported
Array
(
[name] => BZIP2.wav
[index] => 3
[crc] => 1384274557
[size] => 154826
[mtime] => 1296208410
[comp_size] => 104633
[comp_method] => 12
)
Compression method not supported
As you can see, 98, 97, 14 and 12 are all identified as the comp_method
(correctly). None of these compression methods are supported by php_zip,
but the constants should be present to allow determination of the method
used.
Interestingly WavPack was the best algorithm to use on uncompressed
audio (which WinZip performed when I asked it to "compress to the
smallest size").
I can send the zip file if needed (300K).
I think it is important to remember that the zip files being accessed by
php_zip may not have been produced by php_zip.
------------------------------------------------------------------------
[2011-01-28 11:34:43] pajoye@php.net
If they are not implemented, no, it does not make sense to have them
exposed. If
one uses them he will then expect the compression mode to be set and
used
accordingly.
However for reading archive and get information about a given
compression mode,
yes. But only if they are actually used and set by libzip. If not,
please revert
this change.
------------------------------------------------------------------------
[2011-01-28 11:22:37] rquadling@php.net
As the compression mechanisms are stored within the zip file itself, it
isn't
necessarily a requirement for php_zip to support
compression/decompression of these
types, just identification.
Using WinZip V15.0, I've created an archive with CM_PPMD, CM_LZMA,
CM_BZIP and
CM_WAVPACK compressions.
Still looking for LZ77 and Terse.
The compression types are correctly identified by php_zip, so having the
constants
makes sense to me.
I'll update the documentation to say that whilst identification of these
types is
performed, compression and decompression of these types is not currently
supported.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=53854
--
Edit this bug report at http://bugs.php.net/bug.php?id=53854&edit=1