Bug->Req #68621 [Asn->Opn]: ZipArchive::open(): support stream wrappers

From: Date: Thu, 04 Jun 2015 13:22:14 +0000
Subject: Bug->Req #68621 [Asn->Opn]: ZipArchive::open(): support stream wrappers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193116@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68621&edit=1 ID: 68621 Updated by: cmb@php.net Reported by: your dot brother dot t at hotmail dot com -Summary: Filename appends the base url. +Summary: ZipArchive::open(): support stream wrappers -Status: Assigned +Status: Open -Type: Bug +Type: Feature/Change Request Package: Zip Related Operating System: Cross OS PHP Version: all Assigned To: neeke Block user comment: N Private report: N New Comment: I had a closer look at the issue. PR #1159 caters only to the very special use case of php://memory, but not to general stream wrappers. However, it doesn't make sense to create a zip archive in php://memory, because the file would only be created there after calling ZipArchive::close() (normal behavior of ZipArchive), but then the created archive couldn't be accessed anymore. It might make sense to allow for other stream wrappers such as ftp://, though. Anyhow, ZipArchive::open() is not supposed to accept any stream wrapper URLs, but only real file paths. Its documentation doesn't tell otherwise, and neither does the man page on "Supported Protocols and Wrappers"[1]: | PHP comes with many built-in wrappers for various URL-style | protocols for use with the filesystem functions [...] However, ZipArchive::open() is not a filesystem function for that matter. So, actually, this is not a bug, not even a documentation bug in the strict sense. Therefore I'm changing to feature request. [1] <http://php.net/manual/en/wrappers.php> Previous Comments: ------------------------------------------------------------------------ [2015-04-16 13:11:22] cmb@php.net What's the status here? It seems the PR has been closed on 9 Mar without having been merged into upstream. ------------------------------------------------------------------------ [2015-04-06 13:33:21] neeke@php.net https://github.com/php/php-src/pull/1159 ------------------------------------------------------------------------ [2014-12-18 13:56:22] your dot brother dot t at hotmail dot com Description: ------------ --- From manual page: http://www.php.net/ziparchive.open --- The ZipArchive::open treats the filename not as defined per php manual on valid file wrappers. It appends the filename to the base url. Hence, creating/manipulating a zip file in memory space would be impossible. Test script: --------------- $zip = new \ZipArchive(); if (!($err = $zip->open("php://memory", \ZipArchive::CREATE))) { die(var_dump($err)); } $zip->addFromString("test.txt", "sample text"); die(var_dump($zip)); Expected result: ---------------- object(ZipArchive)[206] public 'status' => int 0 public 'statusSys' => int 0 public 'numFiles' => int 1 public 'filename' => string 'php://memory' (length=54) public 'comment' => string '' (length=0) Actual result: -------------- object(ZipArchive)[206] public 'status' => int 0 public 'statusSys' => int 0 public 'numFiles' => int 1 public 'filename' => string 'D:\servers\www\html\Laravel\sandbox\public\php:\memory' (length=54) public 'comment' => string '' (length=0) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68621&edit=1

« previous php.bugs (#193116) next »