Bug #79398 [Opn->Fbk]: Different behavior of flock and include on PHP 7.3 and PHP 7.4
Edit report at https://bugs.php.net/bug.php?id=79398&edit=1
ID: 79398
Updated by: cmb@php.net
Reported by: praszywka dot adam at gmail dot com
Summary: Different behavior of flock and include on PHP 7.3
and PHP 7.4
-Status: Open
+Status: Feedback
Type: Bug
Package: *General Issues
Operating System: Windows 10 1909
PHP Version: 7.4.4
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> PHP 7.3 allows to include previously locked file.
I'm confused, since opening the file in 'w' mode immediately
truncates it. Why would you include an empty file in the first
place?
Previous Comments:
------------------------------------------------------------------------
[2020-03-20 13:59:06] praszywka dot adam at gmail dot com
Description:
------------
PHP 7.3 allows to include previously locked file. PHP 7.4 throws Notice.
Test script:
---------------
<?php
$cachePath = 'file.php';
$lock = fopen($cachePath, 'w');
chmod($cachePath, 0666 & ~umask());
$res = flock($lock, LOCK_EX | LOCK_NB, $wouldBlock);
include $cachePath;
echo 'OK';
Expected result:
----------------
$ C:/Program\ Files/php-7.3.5-nts-Win32-VC15-x64/php.exe test2.php
OK
Actual result:
--------------
$ C:/Program\ Files/php-7.4.4-nts-Win32-VC15-x64/php.exe test2.php
PHP Notice: include(): read of 4096 bytes failed with errno=13 Permission denied in
C:\Users\praszywa\Downloads\test\test2.php on line 10
PHP Stack trace:
PHP 1. {main}() C:\Users\praszywa\Downloads\test\test2.php:0
Notice: include(): read of 4096 bytes failed with errno=13 Permission denied in
C:\Users\praszywa\Downloads\test\test2.php on line 10
Call Stack:
0.0002 393720 1. {main}() C:\Users\praszywa\Downloads\test\test2.php:0
PHP Warning: include(): Failed opening 'file.php' for inclusion
(include_path='.;C:\php\pear') in C:\Users\praszywa\Downloads\test\test2.php on line 10
PHP Stack trace:
PHP 1. {main}() C:\Users\praszywa\Downloads\test\test2.php:0
Warning: include(): Failed opening 'file.php' for inclusion
(include_path='.;C:\php\pear') in C:\Users\praszywa\Downloads\test\test2.php on line 10
Call Stack:
0.0002 393720 1. {main}() C:\Users\praszywa\Downloads\test\test2.php:0
OK
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79398&edit=1
Thread (8 messages)