Bug #79398 [Fbk->Asn]: 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
User updated by: praszywka dot adam at gmail dot com
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: Feedback
+Status: Assigned
Type: Bug
Package: *General Issues
Operating System: Windows 10 1909
PHP Version: 7.4.4
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
That's the way how Symfony is currently creating cache.
Topic was stared here: https://github.com/symfony/symfony/issues/36132
It's not a standard way of using flock and include so I reported it as a incompatibility
between PHP < 7.{0,1,2,3} and 7.4.
That problem should be fixed in Symfony or PHP - it should be decided where.
Previous Comments:
------------------------------------------------------------------------
[2020-03-21 15:20:48] cmb@php.net
> 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?
------------------------------------------------------------------------
[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)