php.net |  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
Votes:1
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-09-21 11:54 UTC] sjorsvanleeuwen at gmail dot com
Description:
------------
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/..

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

[1] <https://www.php.net/supported-versions.php>
 [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