PHP 4.0 Bug #4180 Updated: is_link returns false when target doesnt exist (should return true)
| From: | Bug Database | Date: | Wed, 11 Oct 2000 15:40:51 +0000 |
| Subject: | PHP 4.0 Bug #4180 Updated: is_link returns false when target doesnt exist (should return true) | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-34679@lists.php.net to get a copy of this message | ||
ID: 4180
Updated by: zak
Reported By: dfarmer@evoke.com
Status: Closed
Bug Type: *General Issues
Assigned To:
Comments:
Olivier Cahange <olivier.cahagne@epita.fr> reports this bug as being fixed in 4.0.3RC1
Previous Comments:
---------------------------------------------------------------------------
[2000-04-18 13:26:10] dfarmer@evoke.com
It appears that is_link is incorrect when testing a symbolic link file whose target does not exist.
is_link("/absolute/path/to/my/link")
returns false when the link points to a non-existant target. I believe it should return true based
on the following C code:
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
main(int argc, char **argv)
{
struct stat buf;
char * file_name = argv[1];
lstat(file_name, &buf);
if (S_ISLNK(buf.st_mode))
{
printf("file is a linkn");
}
else
{
printf("file is not a linkn");
}
}
This prints "file is a link" even when the target doesn't exist.
This is an issue because you can't tell when the symlink already exists even if it is
incorrect. I've tried lstat (returns 0 length array), fileexists (false), etc. symlink fails
on the creation of the link because it is there. It seems like the only way to detect this
condition is to have a successful readlink call combined with a false file_exists or symlink call.
The ChangeLog for 3.0.15 and 3.0.16 doesn't address this issue as being fixed.
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=4180