|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52911 fwrite doesn't write long strings to a php stream
Submitted: 2010-09-23 13:18 UTC Modified: 2017-10-24 07:35 UTC
Avg. Score:4.3 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:4 (66.7%)
From: mz dot evgeny at gmail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: 5.3.3 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
13 + 41 = ?
Subscribe to this entry?
Further comment on this bug is unnecessary.
 [2010-09-23 13:18 UTC] mz dot evgeny at gmail dot com
fwrite doesn't write long strings to a stream.

When i try to open a php process and write a long-script to it, i get a parse error.

Test script:
 $descriptorSpec = array(
      0 => array('pipe', 'r'),
      1 => array('pipe', 'w'),
      2 => array('pipe', 'w')
 $process = proc_open("php.exe", $descriptorSpec, $pipes); 
 var_dump(fwrite($pipes[0], "<?php  '" . str_repeat("1", 8500) . "'; ?>"));

 $stdout = stream_get_contents($pipes[1]);

Expected result:
int 8513
No error.

Actual result:
int 8513
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in - on line 1 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-23 13:36 UTC] mz dot evgeny at gmail dot com
-Summary: fwrite doesn't write long strings to a stream +Summary: fwrite doesn't write long strings to a php stream -Package: Streams related +Package: *General Issues
 [2010-09-23 13:36 UTC] mz dot evgeny at gmail dot com
It will be more correct to say that it does write the whole string, but php.exe doesn't get the complete string for some reason.
 [2010-09-24 04:45 UTC]
Strangely, it works if you sleep(1) after proc_open.
 [2010-10-01 03:18 UTC]
-Status: Open +Status: Verified
 [2010-10-17 10:49 UTC] bouke at webatoom dot nl
I ran into the same problem, but sleep(1) didn't work. I had to use sleep(2) 
on my machine (Win7 x64 on C2Q9450).
 [2011-02-09 10:26 UTC] tyra3l at gmail dot com
any update on this?

 [2011-02-09 10:30 UTC]
If there is no further comment, no, no news.

Also there is a limit in the size of the command line arguments (platform-version 
dependent), so using very long cmd line is a bad idea, pipes or file based 
argument is a way better way to do such things.
 [2011-03-03 15:23 UTC] tyra3l at gmail dot com
so are we waiting for a patch, or is this a won'tfix?

 [2011-03-03 19:08 UTC]
-Block user comment: N +Block user comment: Y
 [2011-03-03 19:08 UTC]
This is a "do not know yet if it is fixable at all" use the alternative methods I 
mentioned in my other comment as work around, in the meantime.
 [2011-03-03 19:12 UTC]
-Status: Verified +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2011-12-22 13:02 UTC]
Probable duplicate of bug #60535.
 [2017-10-24 07:35 UTC]
-Status: Assigned +Status: Open -Assigned To: pajoye +Assigned To:
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Oct 20 14:03:39 2021 UTC