Bug #52287 [Fbk->NoF]: REQUIRE_ONCE,REQUIRE,INCLUDE & INCLUDE_ONCE do not handle flock correctly
Edit report at https://bugs.php.net/bug.php?id=52287&edit=1
ID: 52287
Updated by: php-bugs@lists.php.net
Reported by: raat1979 at gmail dot com
Summary: REQUIRE_ONCE,REQUIRE,INCLUDE & INCLUDE_ONCE do not
handle flock correctly
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: *Directory/Filesystem functions
Operating System: Windows Server 2003
PHP Version: Irrelevant
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2014-11-10 23:56:23] 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-05-23 19:22:46] 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.
------------------------------------------------------------------------
[2010-07-08 11:41:06] 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)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=52287&edit=1
Thread (4 messages)