#013137: Archive failing

Description:

Hi,
I run win XP and php5.2.6 i tried to zip ez trunk and it seem to fail due an internal error of archive.

I get

Fatal error: Uncaught exception 'ezcArchiveException' with message 'Unknown type
1' in C:\php5\PEAR\ezc\Archive\zip\headers\zip_central_directory.php:272
Stack trace:
#0 C:\php5\PEAR\ezc\Archive\zip\headers\zip_central_directory.php(449): ezcArchi
veCentralDirectoryHeader->setType(1)
#1 C:\php5\PEAR\ezc\Archive\zip\zip.php(489): ezcArchiveCentralDirectoryHeader->
setHeaderFromArchiveEntry(Object(ezcArchiveEntry))
#2 C:\svn\xrow\trunk\workspace\plesk\app\build.php(18): ezcArchiveZip->appendToC
urrent(Array, 'ez.app\htdocs\')
#3 {main}
thrown in C:\php5\PEAR\ezc\Archive\zip\headers\zip_central_directory.php on li
ne 272

the var_dump in the ezc code gives


object(ezcArchiveEntry)#4 (2) {
  ["fileStructure:protected"]=>
  object(ezcArchiveFileStructure)#3 (12) {
    ["path"]=>
    string(23) "ez.app\htdocs\.htaccess"
    ["mode"]=>
    string(3) "666"
    ["uid"]=>
    int(0)
    ["gid"]=>
    int(0)
    ["mtime"]=>
    int(1202483186)
    ["atime"]=>
    int(1212547028)
    ["type"]=>
    int(0)
    ["link"]=>
    NULL
    ["size"]=>
    int(3063)
    ["ino"]=>
    int(0)
    ["major"]=>
    int(0)
    ["minor"]=>
    int(2)
  }
  ["prefix:protected"]=>
  string(14) "ez.app\htdocs\"
}
object(ezcArchiveEntry)#6 (2) {
  ["fileStructure:protected"]=>
  object(ezcArchiveFileStructure)#5 (12) {
    ["path"]=>
    string(28) "ez.app\htdocs\.htaccess_root"
    ["mode"]=>
    string(3) "666"
    ["uid"]=>
    int(0)
    ["gid"]=>
    int(0)
    ["mtime"]=>
    int(1196718596)
    ["atime"]=>
    int(1212547028)
    ["type"]=>
    int(1)
    ["link"]=>
    string(23) "ez.app\htdocs\.htaccess"
    ["size"]=>
    int(0)
    ["ino"]=>
    int(0)
    ["major"]=>
    int(0)
    ["minor"]=>
    int(2)
  }
  ["prefix:protected"]=>
  string(14) "ez.app\htdocs\"
}

Environment:

Operating System:
PHP Version: (please be specific, like '4.4.3' or '5.1.5')
Database and version:
Browser (and version):


Steps to Reproduce:

here is the scrip that is broke


<?php

require 'ezc/Base/ezc_bootstrap.php';
date_default_timezone_set( "UTC" );
unlink( 'my_archive.zip' );
$archive = ezcArchive::open( "my_archive.zip", ezcArchive::ZIP );
$archive->truncate();

$files = ezcBaseFile::findRecursive( 'ez.app' . DIRECTORY_SEPARATOR . 'htdocs', array(), array( '@.svn@' ) );

foreach ( $files as $file )
{
   echo $file."\n";

}
echo "\n\n";
$archive->appendToCurrent( $files, 'ez.app' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR );
?>

and here is one that works


<?php

require 'ezc/Base/ezc_bootstrap.php';
date_default_timezone_set( "UTC" );
unlink( 'my_archive.zip' );
$archive = ezcArchive::open( "my_archive.zip", ezcArchive::ZIP );
$archive->truncate();

$files = ezcBaseFile::findRecursive( 'ez.app' . DIRECTORY_SEPARATOR . 'htdocs', array(), array( '@.svn@' ) );

foreach ( $files as $file )
{
   echo $file."\n";
$archive->appendToCurrent( $file, 'ez.app' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR );

}
echo "\n\n";

?>


- Attachments

No attachments for this issue.


- Comments

I think the script doesn`t function properly if i add more as 2 files.

By the way the script where i said it works also doesn´t work...


<?php
try 
{
require 'ezc/Base/ezc_bootstrap.php';
date_default_timezone_set( "UTC" );
$name = 'my_archive.zip';
if ( file_exists( $name ) )
unlink( $name );
$archive = ezcArchive::open( $name, ezcArchive::ZIP );

$files = array(
 'ez.app\htdocs\index.php',
 'ez.app\htdocs\webdav.php',
 'ez.app\htdocs\soap.php',
 'ez.app\htdocs\ezpm.php'
);

$archive->append( $files,'' );
echo "\n\n";
$archive->close();
}catch ( Exception $e )
{
    echo $e->__toString();
}
sleep(100);
?>
#256930 by Derick Rethans on June 4th, 2008 [Permanent Link]

Hello Björn,

all your testscripts work for me just fine - but what I am wondering about is one specific thing in your first var_dump(). At some point it says: type: int(1), but that should not even be possible. What kind of file is ez.app\htdocs\.htaccess_root? Is it a Windows softlink or something, or a short cut? type 1 indicates that this is a hardlink, but I didn't know that Windows supported this.

As for your other scripts, please *always* provide the output as well, as you might perhaps have overseen a subtle detail. Just "it doesn't work" is often not good enough.

regards,
Derick

#256933 by Derick Rethans on June 4th, 2008 [Permanent Link]

Hi Derick,

all scripts give the same output.

.htaccess_root is a regular ( text )file.

No such things as Hardlinks or softlinks exists in windows.

Also the files is not hidden or protect in any way.

I can also reproduce this if i pick other files in my selection.

Maybe a windows only issue?

#256935 by Björn Dieding@xrow.de on June 4th, 2008 [Permanent Link]

This test case works if i add a second file to the array it crashes again.


<?php
try 
{
require 'ezc/Base/ezc_bootstrap.php';
date_default_timezone_set( "UTC" );
$name = 'my_archive.zip';
if ( file_exists( $name ) )
unlink( $name );
$archive = ezcArchive::open( $name, ezcArchive::ZIP );

$files = ezcBaseFile::findRecursive( 'ez.app' . DIRECTORY_SEPARATOR . 'htdocs', array(), array( '@\.svn@' ) );

foreach ( $files as $file )
{
   echo $file."\n";
}

$files = array(
 'ez.app\htdocs\index.php'
);
$archive->append( $files, 'ez.app' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR );

$archive->close();
}catch ( Exception $e )
{
    echo $e->__toString();
}
sleep(10);
?>
#256936 by Björn Dieding@xrow.de on June 4th, 2008 [Permanent Link]

Hey this function looks odd. Someone wrote a comment in the code.


    protected static function getLinkType( $stat )
    {
    var_dump($stat);
        switch ( $stat["mode"] & ezcArchiveStatMode::S_IFMT )
        {
            case ezcArchiveStatMode::S_IFIFO:
                return ezcArchiveEntry::IS_FIFO;

            case ezcArchiveStatMode::S_IFCHR:
                return ezcArchiveEntry::IS_CHARACTER_DEVICE;

            case ezcArchiveStatMode::S_IFDIR:
                return ezcArchiveEntry::IS_DIRECTORY;

            case ezcArchiveStatMode::S_IFBLK:
                return ezcArchiveEntry::IS_BLOCK_DEVICE;

            case ezcArchiveStatMode::S_IFREG:
                return ezcArchiveEntry::IS_FILE;

            case ezcArchiveStatMode::S_IFLNK:
                return ezcArchiveEntry::IS_SYMBOLIC_LINK;

            // Hardlinks are not resolved here. FIXME?
        }

        return false;
    }

just in case i give you a vardump of $stat so that you can simulate a win OS from
$files = array(
'ez.app\htdocs\soap.php',
'ez.app\htdocs\index.php'
);


array(26) {
  [0]=>
  int(2)
  [1]=>
  int(0)
  [2]=>
  int(33206)
  [3]=>
  int(1)
  [4]=>
  int(0)
  [5]=>
  int(0)
  [6]=>
  int(2)
  [7]=>
  int(4446)
  [8]=>
  int(1212564096)
  [9]=>
  int(1196718686)
  [10]=>
  int(1196958723)
  [11]=>
  int(-1)
  [12]=>
  int(-1)
  ["dev"]=>
  int(2)
  ["ino"]=>
  int(0)
  ["mode"]=>
  int(33206)
  ["nlink"]=>
  int(1)
  ["uid"]=>
  int(0)
  ["gid"]=>
  int(0)
  ["rdev"]=>
  int(2)
  ["size"]=>
  int(4446)
  ["atime"]=>
  int(1212564096)
  ["mtime"]=>
  int(1196718686)
  ["ctime"]=>
  int(1196958723)
  ["blksize"]=>
  int(-1)
  ["blocks"]=>
  int(-1)
}
array(26) {
  [0]=>
  int(2)
  [1]=>
  int(0)
  [2]=>
  int(33206)
  [3]=>
  int(1)
  [4]=>
  int(0)
  [5]=>
  int(0)
  [6]=>
  int(2)
  [7]=>
  int(40501)
  [8]=>
  int(1212564096)
  [9]=>
  int(1196718668)
  [10]=>
  int(1196958711)
  [11]=>
  int(-1)
  [12]=>
  int(-1)
  ["dev"]=>
  int(2)
  ["ino"]=>
  int(0)
  ["mode"]=>
  int(33206)
  ["nlink"]=>
  int(1)
  ["uid"]=>
  int(0)
  ["gid"]=>
  int(0)
  ["rdev"]=>
  int(2)
  ["size"]=>
  int(40501)
  ["atime"]=>
  int(1212564096)
  ["mtime"]=>
  int(1196718668)
  ["ctime"]=>
  int(1196958711)
  ["blksize"]=>
  int(-1)
  ["blocks"]=>
  int(-1)
}

#256937 by Björn Dieding@xrow.de on June 4th, 2008 [Permanent Link]

Fixed in rev. 8271.

#256942 by Derick Rethans on June 4th, 2008 [Permanent Link]

- History
Properties
Type Bug
Priority Medium
Components Components
Components » Archive
Affects 1.2.4 - Archive 1.2.4
Fix Version 2008.1RC1 - eZ components 2008.1RC1
Reporter Björn Dieding@xrow.de
Responsible Derick Rethans
Status 0 Closed
Resolution Fixed
Created June 4th, 2008
Updated June 4th, 2008
Resolved June 4th, 2008
 
Navigation [Permanent Link]
Previous Issue
Back to Issues List
Next Issue: #015537
  Graph shows to small and truncated rotated axis labels