php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52287 REQUIRE_ONCE,REQUIRE,INCLUDE & INCLUDE_ONCE do not handle flock correctly
Submitted: 2010-07-08 11:41 UTC Modified: 2014-12-30 10:41 UTC
Votes:4
Avg. Score:4.8 ± 0.4
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: raat1979 at gmail dot com Assigned:
Status: No Feedback Package: *Directory/Filesystem functions
PHP Version: Irrelevant OS: Windows Server 2003
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: raat1979 at gmail dot com
New email:
PHP Version: OS:

 

 [2010-07-08 11:41 UTC] raat1979 at gmail dot com
Description:
------------
When an exclusive lock is set on a file (flock) importing the file from any script (including the script itself) with require,require_once,include or .
include_once silently fails and imports nothing. 
Trying to lock the file from the same script works as expected.

Test script:
---------------
<?php //setLock.php
$theFile = fopen('thefile.html', 'rb'); //template file
flock($theFile, LOCK_EX); //accuire an exclusive lock on the file
sleep(10);
echo(require('someFile'));       <-- this silently fails
flock($theFile, LOCK_UN );//release the lock
echo(require('someFile'));       <-- this succeeds
phpinfo(); ?>
//////////////////////////////////////////////////////////////////////////////
<?php //getTheLockedFile.php
echo(require('someFile');) <-- this silently fails
?>

Expected result:
----------------
When excecuting setlock.php I expect it to succeed on both instances or die with the first require attempt

when simultaneously excecuting getTheLockedFile.php I expect excecution to be halted untill the setLock.php file completes or to die with an error.

Actual result:
--------------
When excecuting setlock.php the first require attempt fails silently (return 
value 1, no error) the seccond attempt succeeds as normal.

when simultaneously excecuting getTheLockedFile.php the require attempt fails silently (return value 1, no error)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-05-23 19:22 UTC] cmbecker69 at gmx dot de
I have slightly rewritten the test script setlock.php to make sure
that it is the file that should be locked that is require'd, and
to improve the output:

<?php

    $theFile = fopen('thefile.html', 'rb');
    flock($theFile, LOCK_EX);
    sleep(10);
    var_dump(require 'thefile.html');
    flock($theFile, LOCK_UN);
    var_dump(require 'thefile.html');

?>

For me (PHP 5.4.19, Win 7, API20100525,TS,VC9) both require
statements succeed, what is what I'd expect (as require doesn't
heed any advisory locks).

Regarding the second script see my comment on bug #52895
(<https://bugs.php.net/bug.php?id=52895#1400871924>).

IMO this is not a bug.
 [2014-11-10 23:56 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2014-11-10 23:56 UTC] requinix@php.net
In case there's still interest in this ticket,

raat1979, the script you gave needs distinct filenames in there to make sense, not just "thefile.html" and "someFile". Is what cmbecker69 posted like the code you're talking about? Or is it something else?
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC