ID: 28273 User updated by: mikeboulet at newfangled dot com Reported By: mikeboulet at newfangled dot com Status: Bogus Bug Type: Filesystem function related Operating System: Redhat 7.2 or Redhat AS 2.1 PHP Version: 4.3.4 New Comment:
I argue that it is a bug and that it was already addressed in a similar problem see http://bugs.php.net/bug.php?id=25939. Basically while in the while( feof() ) loop the socket goes away due to network failure and the stream is no longer there. This causes an infinite loop in 4.3.4 because feof() would not return TRUE. In 4.3.5 they changed this behavior to return TRUE on socket failure. This would be similar to saying the file handle is not valid and there is nothing there feof() thus we are at the end of nothing. I guess you could say we are at begining of nothing. I understand this is more of a symantics issue than a bug. If you google 'feof infinite php' you will see that there are a lot of people that get stung by this issue. Maybe it should be changed to get around a common problem. What do you think? Previous Comments: ------------------------------------------------------------------------ [2004-05-04 16:46:45] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. feof() does exactly what it\'s supposed to. ------------------------------------------------------------------------ [2004-05-04 15:58:52] mikeboulet at newfangled dot com Description: ------------ When a fopen() is done on a file that has permissions that are set to not allow the current process user to read it or the file doesn't exist it returns false. This is expected. The problem is when feof() is fed the invalid handle it doesn't return TRUE() thus creating an infinite loop in the following code example. Reproduce code: --------------- <?php $fp = fopen( 't.txt', 'r' ); while( !feof( $fp ) ) { print fgets( $fp ); } fclose( $fp ); ?> Expected result: ---------------- feof() would return TRUE to cancel the loop and the script would end. There would of course be warnings because of the invalid file handle, but that is expected. There should be better error handling on the developers part and catch the invalid file handle, but I would expect the file functions to handle this situation accordingly. Actual result: -------------- Inifinite loop ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28273&edit=1
