php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53893 Wrong return value for ZipArchive::extractTo()
Submitted: 2011-01-31 17:49 UTC Modified: 2011-02-07 17:20 UTC
From: schmale at froglogic dot com Assigned: pajoye (profile)
Status: Closed Package: Zip Related
PHP Version: 5.3.5 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 + 1 = ?
Subscribe to this entry?

 
 [2011-01-31 17:49 UTC] schmale at froglogic dot com
Description:
------------
PHP version (as given in phpinfo()): PHP Version 5.3.3-1ubuntu9.3

Zip-related information:
Zip 	enabled
Extension Version 	$Id: php_zip.c 300470 2010-06-15 18:48:33Z pajoye $
Zip version 	1.9.1
Libzip version 	0.9.0 

Test script:
---------------
function testReturnValue() {
        $extractToPath = "/home/user/testDir"; /* existing dir with NO write privileges */
        $zipPath = "path/to/zipFile"; // has to be valid zip file

        $zip = new ZipArchive();
        $open = $zip->open($zipPath);
        if ($open === true) {
           $extracting = $zip->extractTo($extractToPath);
           $zip->close();
           return $extracting;
        } else {
           return false;
        }
}

Expected result:
----------------
Return value of testReturnValue() should be FALSE, as long as the php user has no write access to the directory into which we extract the zip (because if that's the case, nothing will happen).

Actual result:
--------------
Return value is TRUE, even if no extracting happened due to lacking privileges.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-31 21:36 UTC] felipe@php.net
-Status: Open +Status: Feedback
 [2011-01-31 21:36 UTC] felipe@php.net
Hello, I've a doubt about the test case. $zipPath points to an empty zip file?
 [2011-02-01 08:57 UTC] schmale at froglogic dot com
-Status: Feedback +Status: Open
 [2011-02-01 08:57 UTC] schmale at froglogic dot com
No, it's just an arbitrary zip file. Not empty, of course. In my case, it was a zip file of approx. 50kb size.

If I deleted the existing directory, the zip file was extracted perfectly. However, extracting the zip file into a directory with no write privileges did nothing at all. This is desired behaviour, of course, if it wasn't for the return value: The ZipArchive::extractTo's return value was TRUE either way, which lead to some confusion.
 [2011-02-07 17:20 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=308107
Log: - Fixed bug #53893 (Wrong return value for ZipArchive::extractTo())
 [2011-02-07 17:20 UTC] pajoye@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: pajoye
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 20:01:30 2024 UTC