Reply to Re: [PHP] unlink, symlink and caching

Your name:

Reply:


Posted by jgmtfia Mr on 12/21/05 22:04

> > 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?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация