php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79632 var_dump'ed array produce sometimes error on require/include
Submitted: 2020-05-25 16:20 UTC Modified: 2020-06-07 04:22 UTC
From: cgold dot vie at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: Unknown/Other Function
PHP Version: 7.3.18 OS: Debian 9
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cgold dot vie at gmail dot com
New email:
PHP Version: OS:

 

 [2020-05-25 16:20 UTC] 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?


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-05-25 16:24 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-05-25 16:24 UTC] 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:49 UTC] nikic@php.net
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.
 [2020-06-07 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 16:01:28 2024 UTC