Bug #52287 [Com]: REQUIRE_ONCE,REQUIRE,INCLUDE & INCLUDE_ONCE do not handle flock correctly

From: Date: Fri, 23 May 2014 19:22:47 +0000
Subject: Bug #52287 [Com]: REQUIRE_ONCE,REQUIRE,INCLUDE & INCLUDE_ONCE do not handle flock correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185913@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=52287&edit=1

 ID:                 52287
 Comment by:         cmbecker69 at gmx dot de
 Reported by:        raat1979 at gmail dot com
 Summary:            REQUIRE_ONCE,REQUIRE,INCLUDE & INCLUDE_ONCE do not
                     handle flock correctly
 Status:             Open
 Type:               Bug
 Package:            *Directory/Filesystem functions
 Operating System:   Windows Server 2003
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[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)

« previous php.bugs (#185913) next »