|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #78634 realpath function caches results
Submitted: 2019-10-04 14:45 UTC Modified: 2019-10-04 16:39 UTC
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: flandrestudio dot cn at gmail dot com Assigned:
Status: Verified Package: *Directory/Filesystem functions
PHP Version: 7.3.10 OS: Windows 10.0.18362
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: flandrestudio dot cn at gmail dot com
New email:
PHP Version: OS:


 [2019-10-04 14:45 UTC] flandrestudio dot cn at gmail dot com
In the case of deleting the directory without using the php function rmdir (such as using the command line to delete), using realpath again will not return false. The problem was not generated in php7.3.9.

在不使用php函数rmdir删除目录的情况下(如使用命令行删除) 再次使用realpath将不会返回false。在php7.3.9未产生该问题。

Test script:

$a = 'eee';
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . $a;

// ------------------

// ------------------

// ------------------
passthru('rd "' . $path . '"');

Expected result:
string(5) "7.3.9"
string(24) "E:\phpProject\xlbook\eee"
string(24) "E:\phpProject\xlbook\eee"

Actual result:
string(6) "7.3.10"
string(24) "E:\phpProject\xlbook\eee"
string(24) "E:\phpProject\xlbook\eee"
string(24) "E:\phpProject\xlbook\eee"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-04 14:52 UTC]
-Status: Open +Status: Not a bug
 [2019-10-04 14:52 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at
 [2019-10-04 14:55 UTC]
-Summary: realpath function does not return false +Summary: realpath function caches results -Status: Not a bug +Status: Verified -Type: Bug +Type: Documentation Problem
 [2019-10-04 14:55 UTC]
此函数的结果会被缓存。参见 clearstatcache() 以获得更多细节。

The realpath() docs don't mention that the results are cached, unlike stat() and others. Or that there is a separate realpath cache from the regular file stat cache.
 [2019-10-04 15:36 UTC]


to your script, and try again.
 [2019-10-04 15:48 UTC] flandrestudio dot cn at gmail dot com
7.3.9 PHP_ZTS = 1
7.3.10 PHP_ZTS = 0
 [2019-10-04 16:39 UTC]
> 7.3.9 PHP_ZTS = 1
> 7.3.10 PHP_ZTS = 0

I had expected that.  You're hitting one of the differences
between ZTS and NTS builds: ZTS builds do an additional access()
check[1], and return FALSE, if the file cannot be accessed.
However, there is no regression from 7.3.9 to 7.3.10.

[1] <>
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 21 16:03:36 2021 UTC