From:             
Operating system: Linux 2.6.9,2.6.18, WinXP
PHP version:      5.2.14
Package:          Streams related
Bug Type:         Bug
Bug description:require()/include()[once] ignores advisory file locking

Description:
------------
Require/include processes an input file immediatelly even it is locked with


flock($file, LOCK_EX). This is causing problems when the target script
generated 

dynamically by multiple concurrent threads.



Tested on PHP 5.2.12, 5.2.14.



Most likely this is a result of this bug fixation:
http://bugs.php.net/bug.php?

id=52287 .

Test script:
---------------
Create three files in the same dir.



1. locker.php:

<?php

    $includand = dirname(__FILE__).'/includand.php';

    $hfile = fopen($includand, 'r');

    flock($hfile, LOCK_EX);

    sleep(20);

    flock(LOCK_UN);

    fclose($hfile);

?>



2. includer.php:

<?php

    $includand = dirname(__FILE__).'/includand.php';

    include($includand);

?>



3. includant.php

<?php

    echo "HELLO";

?>



Launch locker.php in browser, then launch includer.php

Expected result:
----------------
'HELLO' as output of includer.php AFTER 20-seconds waiting.

Actual result:
--------------
'HELLO' as output of includer.php IMMEDIATELY after run.

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52895&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52895&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52895&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52895&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52895&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52895&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52895&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52895&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52895&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52895&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52895&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52895&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52895&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52895&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52895&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52895&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52895&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52895&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52895&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52895&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52895&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52895&r=mysqlcfg

Reply via email to