|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68067 DirectoryIterator magically adds .. to path
Submitted: 2014-09-21 11:54 UTC Modified: 2020-12-27 04:22 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sjorsvanleeuwen at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: SPL related
PHP Version: 5.5.17 OS: Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: sjorsvanleeuwen at gmail dot com
New email:
PHP Version: OS:


 [2014-09-21 11:54 UTC] sjorsvanleeuwen at gmail dot com
WHen i want to iterate a specific folder in my project it ends up using the parent directory.

This happens only on the path used in the test script. Other paths are fine.

Test script:
* Document root in my case is /home/www/dev/my_project/public

$system = new \DirectoryIterator($_SERVER["DOCUMENT_ROOT"] .  "/../system");
echo $system->getRealPath();
echo $system->getPath();

Expected result:
Expected result would be with the given case:
Realpath: /home/www/dev/my_project/system
Path: /home/www/dev/my_project/public/../system

Actual result:
Actual result with the given case:
Realpath: /home/www/dev/my_project
Path: /home/www/dev/my_project/public/../system/..


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-29 23:22 UTC]
-Package: Directory function related +Package: SPL related
 [2020-12-14 12:06 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-12-14 12:06 UTC]
Does this still happen to you with any of the actively supported
PHP versions[1]?

[1] <>
 [2020-12-27 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 10 04:05:44 2022 UTC