Bug #60348 [Opn->Asn]: Unable to open new zipfile in mode OVERWRITE

From: Date: Wed, 23 Nov 2011 09:03:03 +0000
Subject: Bug #60348 [Opn->Asn]: Unable to open new zipfile in mode OVERWRITE
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-165448@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60348&edit=1 ID: 60348 Updated by: pajoye@php.net Reported by: dafish at soundtrack-board dot de Summary: Unable to open new zipfile in mode OVERWRITE -Status: Open +Status: Assigned Type: Bug Package: Zip Related Operating System: Linux Debian 2.6.32 PHP Version: 5.3.8 -Assigned To: +Assigned To: pajoye Block user comment: N Private report: N New Comment: hm, it supports symlink smoothly. Let me test again. Previous Comments: ------------------------------------------------------------------------ [2011-11-23 08:36:47] dafish at soundtrack-board dot de After some more investigation along with an colleague I've found the source of the issue: I was trying to create the archive inside an directory which is symlinked to another directory. After adding realpath() to the archivename, the file could be successfully opened and stored. I'm not sure if the error message was helpful at all and could be changed in the future. ------------------------------------------------------------------------ [2011-11-21 14:42:32] dafish at soundtrack-board dot de Here is a little self contained script producing the same error: $zip = new ZipArchive(); $archiveName = 'testtest.zip'; $error = $zip->open($archiveName, ZipArchive::OVERWRITE); echo $error . PHP_EOL; // outputs '1' $zip->addFromString('text.txt', 'Lorem Ipsum'); $zip->close(); ------------------------------------------------------------------------ [2011-11-21 14:35:07] pajoye@php.net can you create a self contained script? Use addFromString instead and drop everything not needed like exceptions and co, easier/faster for me to debug then. ------------------------------------------------------------------------ [2011-11-21 14:30:29] dafish at soundtrack-board dot de Description: ------------ I'm trying to open a zip file in mode OVERWRITE. I always end up getting error code 1, Test script: --------------- $this->archiveName = TEMP_DIR . '/archive_' . $this->tid . '_' . date('Ymd') . '.zip'; $errorCode = $this->zipArchive->open($this->archiveName, ZipArchive::CREATE); if ((integer)$errorCode > 0) { throw new RuntimeException('Unable to open archive ' . $this->archiveName . ' (Error: ' . $errorCode . ')'); } if (empty($this->files)) { throw new RuntimeException('No files available to be added to the archive.'); } foreach ($this->files as $filename => $filepath) { $this->zipArchive->addFile($filepath, $filename); } if (!$this->zipArchive->close()) { throw new RuntimeException('An error occured while trying to write the archive.'); } return $this->archiveName; ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60348&edit=1

« previous php.bugs (#165448) next »