Bug #61521 [Opn->Nab]: fopen uses stale data on symlinks - opens old file instead
Edit report at https://bugs.php.net/bug.php?id=61521&edit=1
ID: 61521
Updated by: cmb@php.net
Reported by: jstephens at qualtrics dot com
Summary: fopen uses stale data on symlinks - opens old file
instead
-Status: Open
+Status: Not a bug
Type: Bug
Package: Filesystem function related
Operating System: Ubuntu
PHP Version: 5.3.10
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
That is expected behavior due to the stat cache. Use
clearstatcache() if you have to read the symlink multiple times.
Previous Comments:
------------------------------------------------------------------------
[2012-03-26 20:29:55] jstephens at qualtrics dot com
Description:
------------
After opening a symlink, PHP will always use the original link location, even if the link is
externally modified during script execution.
Test script:
---------------
<?php
file_put_contents("linkOrig", "old data");
file_put_contents("linkNew", "new data");
//create the link
symlink("linkOrig", "link");
//ln -s linkOrig link;//this also works
file_get_contents("link");//open it and read it (caches the link data)
//simulate another program altering it
ln -fs linkNew link;
echo file_get_contents("link");
Expected result:
----------------
new data
Actual result:
--------------
old data
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61521&edit=1
Thread (2 messages)