|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 22:00:01 2025 UTC |
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.