Bug #79632 [Fbk]: var_dump'ed array produce sometimes error on require/include

From: Date: Mon, 25 May 2020 16:49:27 +0000
Subject: Bug #79632 [Fbk]: var_dump'ed array produce sometimes error on require/include
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227157@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79632&edit=1 ID: 79632 Updated by: nikic@php.net Reported by: cgold dot vie at gmail dot com Summary: var_dump'ed array produce sometimes error on require/include Status: Feedback Type: Bug Package: Unknown/Other Function Operating System: Debian 9 PHP Version: 7.3.18 Assigned To: cmb Block user comment: N Private report: N New Comment: Note that flocks are advisory locks, so the read operation must also acquire a shared lock. Obviously include does not do that, so it may see partially written files. What you likely want is an atomic rename. Previous Comments: ------------------------------------------------------------------------ [2020-05-25 16:24:52] cmb@php.net Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PHP. ------------------------------------------------------------------------ [2020-05-25 16:20:18] cgold dot vie at gmail dot com Description: ------------ PHP 7.3.17-1+0~20200419.57+debian9~1.gbp0fda17 Linux debian 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1 (2020-01-20) x86_64 GNU/Linux -> On VirtualBox (Host Win7) using Shared Directories. I am not 100% sure why this error happens: I use the following code to dump an array to a file (its something like a cache system): file_put_contents($_SERVER['BASE_DIR'].'website/siteconfig/'.$row['domain'].'.php', '<?php'.PHP_EOL.'$CONFIG = ' . $save . ';', LOCK_EX); the result looks like: ----------- <?php $CONFIG = array ( 'id' => '1', 'created' => '2020-05-25 00:00:41', 'lastupdate' => '2020-05-25 17:46:16', 'tmpl_id' => '1', 'showperpage' => '18', 'phrases' => '0', 'hashtags' => '1', 'maxpages' => 2, ); ----------- and the error on including using require(): Parse error: syntax error, unexpected ')', expecting end of file in /srv/myproject/website/siteconfig/testsite.local.php on line 11 Line 11 is: ); ================= This error does not appear every time when i update the testsite.local.php using var_dump. Sometimes it happens, sometimes not. If this error happens i have to delete the file manually and then execute my var_dump again. Then it is working again. If i update without to delete the old file, the same error stay. Maybe its some problem with the OPcache? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79632&edit=1

« previous php.bugs (#227157) next »