Edit report at https://bugs.php.net/bug.php?id=36555&edit=1
ID: 36555
Comment by: webmaster at wininup dot com
Reported by: p at damezin dot com
Summary: realpath_cache never updated with symlinks (removed
or renamed)
Status: Not a bug
Type: Bug
Package: Filesystem function related
Operating System: Linux OpenBSD
PHP Version: 5.2.0
Block user comment: N
Private report: N
New Comment:
Well, i'm afraid I can only reproduce this bug when it's used through Apache.
Testing is hard because it does not appear at the first time.
Download the file "test.php" from this URL :
http://dl.dropbox.com/u/62007491/test.php
To init the test, in the same directory that "test.php" please create a
directory "writable", writable by Apache ("mkdir writable && chmod 777
writable"
for testing should be okay).
1. Run the script with the $flag = true. This should create 2 files in the
writable directory, the "content" file, plus the symlink file.
2. Execute the script multiple times (this is important) by pressing F5. No
error should occur.
3. Now Run the same script with the $flag = false. This should delete this
"content" and "symlink" file.
4. Execute the script multiple times (this is important)
5. Then Run the same process from the step 1 to 4. Try again until you see that
the step 1 ($flag = true) fails with :
----------------------------------------
Warning: symlink(): File exists in /var/www/html/test/test.php on line 37
islink:
Warning: linkinfo(): No such file or directory in /var/www/html/test/test.php
on
line 41
linkinfo: -1
Warning: readlink(): No such file or directory in /var/www/html/test/test.php
on
line 42
readlink:
php version : 5.4.6 realpath_cache_size (if available) : 16K
Array ( [0] => /var/www/html/test/writable/content_42 )
----------------------------------------
=> As you can see in the above output, the symlink() fails with "File exists"
but the symlink actually does not exist !!
Hope this helps.
Previous Comments:
------------------------------------------------------------------------
[2012-09-07 17:16:40] [email protected]
I can not reproduce this.
could you explain your test steps?
------------------------------------------------------------------------
[2012-09-07 16:11:32] webmaster at wininup dot com
Why is this bug report not considered like a real bug ? It is because it's not
at
all the behavior expected : file_get_contents() randomly the content delivered
is
the the new symlink or from the old symlink content !!
Still occurs on PHP 5.4.6 (Linux Fedora 17).
------------------------------------------------------------------------
[2006-11-03 12:37:08] p at damezin dot com
New simplified testcase :
<?php
define('TEST_FILE1', '/tmp/testfile1');
define('TEST_LINK', '/tmp/testlink');
file_put_contents(TEST_FILE1, '42');
// create TEST_LINK pointing on TEST_FILE1 using a temporary filename (needed)
$tmp_link_name = TEST_LINK . uniqid(time());
symlink(TEST_FILE1, $tmp_link_name);
rename($tmp_link_name, TEST_LINK);
// reading this link/file
file_get_contents(TEST_LINK);
// remove the link (we have the same bug making this link pointing somewhere
else)
unlink(TEST_LINK);
$good_result = '';
// clearstatcache have no effect
clearstatcache();
// fetching result, must be empty (link does not exist)
$result = @file_get_contents(TEST_LINK);
// on bogus php it return TEST_FILE1 content
echo "TEST : " . (($result == $good_result) ?
'SUCCEED' : 'FAILED') . "\n";
echo "result : '" . $result . "' | ";
echo "expected : '" . $good_result . "'\n";
echo "php version : " . PHP_VERSION."\n";
echo "realpath_cache_size (if available) : " .
@ini_get('realpath_cache_size') . "\n";
// cleaning
@unlink(TEST_LINK);
unlink(TEST_FILE1);
?>
------------------------------------------------------------------------
[2006-11-03 12:07:58] p at damezin dot com
new summary (perhaps it would make this bug more interesting...)
Bug on 5.2.0 is verified with default configuration (without php.ini) and
sources provided from php.net (no patch from a portage).
------------------------------------------------------------------------
[2006-11-03 12:00:15] p at damezin dot com
still have this problem on 5.2.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=36555
--
Edit this bug report at https://bugs.php.net/bug.php?id=36555&edit=1