php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37072 Empty file when copying to flocked destination
Submitted: 2006-04-13 14:49 UTC Modified: 2006-04-18 14:15 UTC
From: wulff at ratatosk dot net Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.1.2 OS: win32 only
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wulff at ratatosk dot net
New email:
PHP Version: OS:

 

 [2006-04-13 14:49 UTC] wulff at ratatosk dot net
Description:
------------
On Windows, when the destination file in copy() is flocked, the destination ends up as an empty file.

On linux, the example code works as expected.

Reproduce code:
---------------
// echo foo > foo.txt
// echo bar > bar.txt
$fp = fopen('foo.txt', 'r');
@flock($fp, LOCK_EX);
copy('bar.txt', 'foo.txt');
fclose($fp);

Expected result:
----------------
c:\cat foo.txt bar.txt
foo
bar

Actual result:
--------------
c:\cat foo.txt bar.txt
bar

(File foo.txt is empty.)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-18 14:15 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

#1 you are trying to copy over a locked file #2 you are trying 
to overwrite a currently open file. Win32 will reject this 
combinatioln on the OS level, not a PHP bug.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 16:01:36 2025 UTC