From: Operating system: Windows 7 x86 PHP version: 5.3.2 Package: Filesystem function related Bug Type: Bug Bug description:fwrite returns 1 when trying to write to a locked file
Description: ------------ When I try to write any length string with fwrite using a file handle I previously locked with flock, fwrite is of course unable to write, but will return unexplicable value 1 instead of false. Test script: --------------- /* Run two instances of this script in a rapid sequence */ $fp1 = fopen("/cache/lockable.txt","w"); if(flock($fp1, LOCK_EX | LOCK_NB)){ echo "locked fp1\n"; sleep(20); }else{ $res = fwrite($fp1, "ABCDE"); if(false === $res){ echo "failed the write\n"; } echo "I managed! fwrite returned: "; print_r($res); } Expected result: ---------------- I expect to read "failed to write" when a second instance of the script is run, since fwrite should return false as documentation says when fwrite is not able to write. Actual result: -------------- fwrite returns integer 1. -- Edit bug report at http://bugs.php.net/bug.php?id=51969&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51969&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51969&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=51969&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=51969&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51969&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51969&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51969&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51969&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51969&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51969&r=support Expected behavior: http://bugs.php.net/fix.php?id=51969&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51969&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51969&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51969&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51969&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51969&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51969&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51969&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51969&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51969&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51969&r=mysqlcfg