Doc #61436 [NEW]: Missing fflush() in flock() LOCK_EX example

From: Date: Mon, 19 Mar 2012 14:41:54 +0000
Subject: Doc #61436 [NEW]: Missing fflush() in flock() LOCK_EX example
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8092@lists.php.net to get a copy of this message
From: Operating system: Windows 2008 PHP version: Irrelevant Package: *General Issues Bug Type: Documentation Problem Bug description:Missing fflush() in flock() LOCK_EX example Description: ------------ --- From manual page: http://www.php.net/function.flock#refsect1-function.flock- examples --- Example should be modified to add fflush() as below. There is no point in gaining an exclusive lock if you release it before flushing output. <?php $fp = fopen("/tmp/lock.txt", "r+"); if (flock($fp, LOCK_EX)) { // do an exclusive lock ftruncate($fp, 0); // truncate file fwrite($fp, "Write something here\n"); fflush($fp); // flush output before releasing lock flock($fp, LOCK_UN); // release the lock } else { echo "Couldn't get the lock!"; } fclose($fp); ?> Actual result: -------------- Saw a corrupted file that seems to indicate that output is not automatically flushed when an exclusive lock is released. -- Edit bug report at https://bugs.php.net/bug.php?id=61436&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=61436&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=61436&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=61436&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=61436&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=61436&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=61436&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=61436&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=61436&r=needscript Try newer version: https://bugs.php.net/fix.php?id=61436&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=61436&r=support Expected behavior: https://bugs.php.net/fix.php?id=61436&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=61436&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=61436&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=61436&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=61436&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=61436&r=dst IIS Stability: https://bugs.php.net/fix.php?id=61436&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=61436&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=61436&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=61436&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=61436&r=mysqlcfg

« previous php.doc.bugs (#8092) next »