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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 17:01:28 2024 UTC