> > The loop then continues forever with file_exists() returning true, but
> > unlink() returns false with the error message "Warning:
> > unlink(/config1/C) [function.unlink]: No such file or directory in
> > /www/script.php on line 10"
>
> This might be an issue with the OS or Filessystem.  The code
> works just fine for me, i dont even need the clearstatcache().

Thank you for checking on this.

I am using debain stable with a 2.6.14.3 kernel.  The filesystem in
question is ext2 on a 48 MB ramdisk.

I also did the following on another machine using ext2 on a harddisk
with command line php.

<?php
/*
-rw-r--r--  1 user user  0 Dec 21 12:41 A
-rw-r--r--  1 user user  0 Dec 21 12:41 B
lrwxr-xr-x  1 user user  1 Dec 21 12:43 C -> A
-rw-r--r--  1 user user 91 Dec 21 12:41 test.php
*/

$FILE = 'C';

while(file_exists($FILE)){
    echo "$FILE exists\n";
    echo `ls -l C`;
    if(!unlink($FILE)){
        echo "Unable to delete $FILE\n";
        echo `ls -l C`;
    }else{
        echo "Deleted $FILE\n";
    }
    echo "====\n";
}

/*
Output:
>php5 ./test.php

C exists
lrwxr-xr-x  1 user user 1 Dec 21 12:59 C -> A
Deleted C
====

C exists
ls: C: No such file or directory
Warning: unlink(C): No such file or directory in
    /home/user/x/test.php on line 14
Unable to delete C
ls: C: No such file or directory
====

C exists
ls: C: No such file or directory
Warning: unlink(C): No such file or directory in
    /home/user/x/test.php on line 14
Unable to delete C
ls: C: No such file or directory
====
 */

?>

This shows that apache is not responsible for the problem.

Note also that if I delete A and C within the loop the code works as
expected and the loop only executes once.  So file_exists() is seeing
"A" when I tell it to delete "C" and unlink is seeing "C" as it
should.

Any ideas where to start to look for the cause of the problem?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to