Doc #78634 [Ver]: realpath function caches results

From: Date: Fri, 04 Oct 2019 16:39:34 +0000
Subject: Doc #78634 [Ver]: realpath function caches results
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16986@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78634&edit=1 ID: 78634 Updated by: cmb@php.net Reported by: flandrestudio dot cn at gmail dot com Summary: realpath function caches results Status: Verified Type: Documentation Problem Package: *Directory/Filesystem functions Operating System: Windows 10.0.18362 PHP Version: 7.3.10 Block user comment: N Private report: N New Comment: > 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] <https://github.com/php/php-src/blob/php-7.3.10/ext/standard/file.c#L2369-L2373> Previous Comments: ------------------------------------------------------------------------ [2019-10-04 15:48:08] flandrestudio dot cn at gmail dot com 7.3.9 PHP_ZTS = 1 7.3.10 PHP_ZTS = 0 ------------------------------------------------------------------------ [2019-10-04 15:36:58] cmb@php.net Add var_dump(PHP_ZTS); to your script, and try again. ------------------------------------------------------------------------ [2019-10-04 14:55:06] requinix@php.net 此函数的结果会被缓存。参见 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 14:52:55] peehaa@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php https://www.php.net/manual/en/function.clearstatcache.php ------------------------------------------------------------------------ [2019-10-04 14:45:43] flandrestudio dot cn at gmail dot com Description: ------------ 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: --------------- <?php var_dump(phpversion()); $a = 'eee'; $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . $a; // ------------------ var_dump($path); // ------------------ mkdir($path); var_dump(realpath($path)); // ------------------ passthru('rd "' . $path . '"'); var_dump(realpath($path)); Expected result: ---------------- string(5) "7.3.9" string(24) "E:\phpProject\xlbook\eee" string(24) "E:\phpProject\xlbook\eee" bool(false) 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" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78634&edit=1

« previous php.doc.bugs (#16986) next »