Hi again,
Thanks for your reply. I think perhaps I've not been totally clear on my
last e-mail. The directory does exist. If this dir or symlink would not
exist, the code would have outputted "Couldn't create the link". The
fact that is goes well right after the symlink is just created, is
indeed the cause of the stat cache.
But the actual problem is that the symlink is not recognized as a
symlink. It seems to be dereferenced by functions like 'lstat',
'is_link' and 'filetype'. And that isn't supposed to happen.
The problem has probably something to do with my system in combination
with apache/php. So I guess reporting it as a bug won't do, because it
will simply be filed under 'works here'. If anybody has any clue what is
going on here, please let me know. For the record I've updated to CVS
snapshot of May 10, 2007 14:30 GMT, but it didn't work with older
version as well.
Let me give another example, with which I hope I can make the problem
clearer.
------------
Script:
<?
$symlink = '/tmp/link-test';
$target = '/tmp/pear';
if (!file_exists($target)) trigger_error("Target '$target' does not
exist", E_USER_ERROR);
if (file_exists($symlink) && !unlink($symlink)) trigger_error("Could
not delete '$symlink'", E_USER_ERROR);
symlink($target, $symlink);
clearstatcache();
/* This should output 'link' */
echo filetype($symlink), "\n";
/* This should output 'link' */
echo is_link($symlink) ? 'link' : 'not a link', "\n";
/* This should output 'differ' */
echo lstat($symlink) === stat($target) ? 'same' : 'differ';
?>
Expected:
link
link
differ
Actual:
dir
not a link
same
------------
Thanks for any help,
Arnold
Tijnema ! wrote:
On 5/2/07, Arnold Daniels <[EMAIL PROTECTED]> wrote:
Hi,
I've got a bug with is_link and lstats. Any symlinks not created in the
current session, will not be read. This only occurs in the Apache 2 SAPI
version, not in the CLI version.
Script:
<?
$symlink = '/tmp/link-test';
if (file_exists($symlink)) unlink($symlink);
symlink('/tmp/pear', $symlink);
echo (file_exists($symlink) ? is_link($symlink) ? "Correct" :
"ERROR" :
"Couldn't create the link"), "<br/>\n";
$symlink = '/tmp/link-persist';
if (!file_exists($symlink)) symlink('/tmp/pear', $symlink);
echo (file_exists($symlink) ? is_link($symlink) ? "Correct" :
"ERROR" :
"Couldn't create the link"), "<br/>\n";
?>
First run:
Correct
Correct
Second run:
Correct
ERROR
Next runs:
Correct
ERROR
I've recently start using the daily snapshots op PHP, but I also
tried it on
version 5.2.1, which shows the same result. It used to work just
fine, so
I'm sure this isn't the expected result. I've recently upgraded from
Ubuntu
Edgy (6.10) to Feisty (7.04), with kernel and apache update, so I
believe
that the problem is related to that.
I've straced the process (see attachment), but I can't pinpoint the
problem.
This is a big issue for me, can anyone point me in the right
direction to
find the source of this problem.
Thanks,
Arnold
<snip>
Well, I've also tested this code, and it does work fine. BUT if
/tmp/pear doesn't exists, what i had at first, then file_exists
returns false, because file_exists follows symlinks, and the symlink
pointed to nothing. So if you're sure that $symlink is a link, then it
might be better to check it with is_link.
Also, the is_link function is cached, so you might want to add one or
more clearstatcache() in your script.
I checked your strace also, but it doesn't look like there's a bug.
But I've never studied on the PHP core so....
Well, if above doesn't help you, then one of the "real experts" needs
to look at it :)
Tijnema
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php