|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64884 RarEntry::extract() for directories does not extract entries within directory
Submitted: 2013-05-20 20:15 UTC Modified: 2020-12-08 19:22 UTC
From: php at login dot hedim dot ch Assigned:
Status: Wont fix Package: rar (PECL)
PHP Version: Irrelevant OS:
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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
23 - 3 = ?
Subscribe to this entry?

 [2013-05-20 20:15 UTC] php at login dot hedim dot ch
When using RarEntry::extract() for an entry that is a directory, only the directory itself is extracted but not the entries within that directory. The extracted directory is empty.

It would be useful if this method extracted the directory including all entries within that directory.

Also, this would be consistent with "x" command of unrar (as in the command-line unrar).

The workaround (i.e. finding and extracting all entries within a given directory entry by name) does not promise to work reliably given that, according to the PHP manual, a RAR archive can have multiple entries with the same name.

Test script:
Assuming "archive.rar" is an archive with the following contents:


And the following code snippet:

$archive = RarArchive::open("archive.rar");
foreach ($archive as $entry) {
    if ($entry->isDirectory()) {

Expected result:
In the current directory, there is a directory called "mydirectory", and within that directory, there is the file "myfile.txt" from the archive.

Actual result:
In the current directory, there is an empty directory called "mydirectory".


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-08 19:22 UTC]
-Status: Open +Status: Wont fix
 [2020-12-08 19:22 UTC]
The change porposed is undesirable. A common scenario, where the user is iterating and extracting entries one by one, would result in this change in the files of a directory being extracted more than once.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Sep 28 22:04:50 2022 UTC