|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68621 ZipArchive::open(): support stream wrappers
Submitted: 2014-12-18 13:56 UTC Modified: 2015-06-04 13:22 UTC
Avg. Score:3.6 ± 1.5
Reproduced:5 of 5 (100.0%)
Same Version:3 (60.0%)
Same OS:2 (40.0%)
From: your dot brother dot t at hotmail dot com Assigned:
Status: Open Package: Zip Related
PHP Version: all OS: Cross OS
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-12-18 13:56 UTC] your dot brother dot t at hotmail dot com
From manual page:
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)))
$zip->addFromString("test.txt", "sample text");

Expected result:
  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:
  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)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-07 09:06 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: neeke
 [2015-03-07 09:09 UTC]
-PHP Version: 5.6.3 +PHP Version: all
 [2015-04-06 13:30 UTC]
-Assigned To: neeke +Assigned To:
 [2015-04-06 13:33 UTC]
-Assigned To: +Assigned To: neeke
 [2015-04-16 13:11 UTC]
-Package: zip +Package: Zip Related
 [2015-04-16 13:11 UTC]
What's the status here? It seems the PR has been closed on 9 Mar
without having been merged into upstream.
 [2015-06-04 13:22 UTC]
-Summary: Filename appends the base url. +Summary: ZipArchive::open(): support stream wrappers -Status: Assigned +Status: Open -Type: Bug +Type: Feature/Change Request
 [2015-06-04 13:22 UTC]
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

So, actually, this is not a bug, not even a documentation bug in
the strict sense. Therefore I'm changing to feature request.

[1] <>
 [2015-06-04 13:22 UTC]
-Assigned To: neeke +Assigned To:
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 14 06:01:33 2024 UTC