php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54515 Documentation claims that "zip:" wrapper allows writing
Submitted: 2011-04-12 16:45 UTC Modified: 2011-07-02 02:53 UTC
From: alvaro at demogracia dot com Assigned: frozenfire (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2011-04-12 16:45 UTC] alvaro at demogracia dot com
Description:
------------
The "Wrapper Summary" table states that all three wrappers allow writing. That does not seem to be the case for "zip:". My test code fails when trying to write and docs for ZipArchive::getStream() <http://es2.php.net/ziparchive-getstream> clearly state that the returned file handler "only supports read operations".

---
From manual page: http://www.php.net/wrappers.compression#Options
---


Test script:
---------------
<?php

// Create test archive
$zip = new ZipArchive;
$res = $zip->open('./foo.zip', ZipArchive::CREATE);
if ($res === TRUE) {
    $zip->addFromString('bar.txt', 'Lorem ipsum dolor sit amet.');
    $zip->close();
} else {
    die('Could not create ZIP archive');
}

// Read through fopen() wrapper
$fp = fopen('zip://./foo.zip#bar.txt', 'r');
if( $fp ){
	while( !feof($fp) ){
		echo fread($fp, 8192);
	}
	fclose($fp);
}

// Write through fopen() wrapper
$fp = fopen('zip://./foo.zip#bar.txt', 'w');
if( $fp ){
	fwrite($fp, 'Consectetur adipisicing elit.');
	fclose($fp);
}

?>

Expected result:
----------------
Lorem ipsum dolor sit amet.

Actual result:
--------------
Warning: fopen(zip://./foo.zip#bar.txt) [http://es.php.net/function.fopen]: failed to open stream: operation failed in C:\tmp\test.php on line 23


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-02 02:53 UTC] frozenfire@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: frozenfire
 [2011-07-02 02:53 UTC] frozenfire@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 10 09:01:31 2024 UTC