'Function file() reads only part of contents in PHP 7.4.27

We have a complex web interface on our dedicated server (Windows Server) which has few console processes with PHP applications running in background and doing various data processing. Some of them write to log files

@ file_put_contents( $logsFileNamePath, $fileContents, FILE_APPEND | LOCK_EX );

and there is one console process that analyzes these log files and seeks potential problems, it executes the code below (it can happen in the same time when other console processes write to the log file):

$logContent = file( $filePath );
$logContent = array_reverse( $logContent );
//... analyze the content

and this has been working fine for years untill recent PHP upgrade from 7.4.20 to 7.4.27 and suddenly sometimes the process that analyzes log files gets contents from a log file which is truncated in the middle of some line. My suspicion is that there is some internal error in this newer version of PHP that causes this... maybe locking of a file no longer works ? It looks like! Has anyone of you seen similar problem recently? Do you have any ideas what to do with this? Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source