On Tue, Apr 24, 2001 at 10:50:36AM +0200, Andi Gutmans wrote:
> It definitely seems as if the logic in the code (filestat.c) is kind of 
> screwed up.
> If no one has time to look at it I can try and take a look at it later on.
> 
> Andi
> 
> At 01:35 AM 4/24/2001 -0500, J. Jones wrote:
> >Forgive me for my ignorance, but I've noticed some unwanted behavior
> >(IMO, at least) with the is_link() function.  Given the simple code..
> >
> >         if ( is_link ("/tmp/this_is_a_symlink") )
> >                 print ("Success\n");
> >
> >and the file..
> >         lrwxrwxrwx 1 root root 5 Apr 23 21:19 /tmp/this_is_a_symlink -> /bin/
> >the above obviously prints 'Success\n'.
> >
> >However, if I BREAK the symlink, with something like the following..
> >         lrwxrwxrwx 1 root root 4 Apr 23 21:21 /tmp/this_is_a_symlink -> foo
> >the script fails with..
> >
> >Warning: stat failed for /tmp/this_is_a_symlink (errno=2 - No such file or
> >directory) in ./test.php on line 3.
> >
> >The file /tmp/this_is_a_symlink is still a symlink, so it seems to me that
> >the is_link() function should still return true, whether or not the symlink's
> >target exists.  Is there perhaps a function I have yet to discover that
> >provides that behavior, without verifying the link's target?
> >

I grew impatient, and devised a simple (2 line) workaround in filestat.c.
Basically it just required NOT doing a stat() if is_link() was calling
php_stat().  This probably isn't 'the' fix, but it works great for me, and
I know you guys are pretty busy.  Attached is my diff against
php-4.0.4pl1's ext/standard/filestat.c.

Thanks for the great language! Keep it up!

J. Jones
--- php-4.0.4pl1/ext/standard/filestat.c        Thu Dec  7 13:15:02 2000
+++ php-4.0.4pl1/ext/standard/filestat.c        Tue Apr 24 16:43:06 2001
@@ -467,6 +467,7 @@
 #if HAVE_SYMLINK
                BG(lsb).st_mode = 0; /* mark lstat buf invalid */
 #endif
+               if (type != 14) {
                if (V_STAT(BG(CurrentStatFile),&BG(sb))==-1) {
                        if (type != 15 || errno != ENOENT) { /* fileexists() test must 
print no error */
                                php_error(E_NOTICE,"stat failed for %s (errno=%d - 
%s)",BG(CurrentStatFile),errno,strerror(errno));
@@ -474,6 +475,7 @@
                        efree(BG(CurrentStatFile));
                        BG(CurrentStatFile)=NULL;
                        RETURN_FALSE;
+               }
                }
        }
 

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to