From: staf w. <sta...@be...> - 2004-03-13 10:27:12
|
On Fri, Mar 12, 2004 at 07:31:27PM +0100, Thijs Kinkhorst wrote: > > if ( @fwrite($file, $Key . '=' . $Value . "\n") === FALSE ) { > > > > If no data is written fwrite returns (int) 0 and isn't (boolean) FALSE > > if "===" is used and the zero sized .tmp gets copied over the user's > > preference file. > > If I understand correctly, this could also be solved by just 'downgrading' > the ===FALSE suffix to a ! prefix. That will match both FALSE and 0. A > regular write will never return 0 since it will contain at least the "=", > "\n" and the value of $Key... > Well, I'm not a "php expert". Just a guy that is maintaining squirrelmail on a system and had this problem. After searching the internet I found a similar problem on the squirrelmail user mailinglist: http://www.geocrawler.com/mail/msg.php3?msg_id=8775935&list=17796 Using "if ( ! @fwrite" or "==" instead of "===" will IMHO resolve the problem only if no bytes are written. But theoretically it is possible that not enough bytes are written to the file. If want to be really wan to be sure that fwrite succeed without a problem you have to compare return value of fwrite with the number of byte that are actually written to the file. Please not that the sample code on http://www.php.net/fwrite has the same bug with the same remark in the user's comment. Anyway I've submitted the bug ( id = 915527 ) to the bug tracker on sf.net kind regards, -- staf |