php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60146 Last 2 lines of page not being output
Submitted: 2011-10-26 22:43 UTC Modified: 2011-10-29 02:14 UTC
From: david dot gero at ec dot gc dot ca Assigned: laruence
Status: Closed Package: Built-in web server
PHP Version: 5.4.0beta2 OS: Windows XP
Private report: No CVE-ID:
 [2011-10-26 22:43 UTC] david dot gero at ec dot gc dot ca
Description:
------------
The test script should end with a second "Return to Menu" line.  But the built-in web server does not output the last 2 lines of the page.
If you remove the comment so that MAXROWS is 1 instead of 2, it works fine.
Turning output buffering off in php.ini has no effect

Test script:
---------------
<?php
//define("MAXROWS", 1); //Uncomment this line to see the second Return to Menu line appear in the output
if (!defined("MAXROWS")) define("MAXROWS", 2);
$results = '<table border="1">' . PHP_EOL . '<tr><th scope="col" style="text-align:center">#</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah blah</th><th scope="col" style="text-align:center">Blah&nbsp;blah&nbsp;blah&nbsp;blah&nbsp;blah&nbsp;blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah&nbsp;blah&nbsp;blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah&nbsp;blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah&nbsp;blah&nbsp;blah&nbsp;blah&nbsp;blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah&nbsp;blah&nbsp;blah&nbsp;blah&nbsp;blah</th><th scope="col" style="text-align:center">Blah</th><th scope="col" style="text-align:center">Blah&nbsp;blah&nbsp;blah&nbsp;blah&nbsp;blah</th><th scope="col" style="text-align:center">Blah</th></tr>';
for ($i = 0; $i < MAXROWS; ++$i) $results .= PHP_EOL . '<tr><td style="text-align:center">0</td><td style="text-align:center">297</td><td style="text-align:center">0</td><td style="text-align:center">4</td><td style="text-align:center">NULL</td><td style="text-align:center">9544</td><td style="text-align:center">NULL</td><td style="text-align:center">NULL</td><td style="text-align:center">15</td><td style="text-align:center">2</td><td style="text-align:center">63292518</td><td style="text-align:center">Blah Blah Blah Blah Blah Blah</td><td style="text-align:center">NULL</td><td style="text-align:center">5</td><td style="text-align:center">1</td><td style="text-align:center">3</td><td style="text-align:center">5</td><td style="text-align:center">2581</td><td style="text-align:center">8</td><td style="text-align:center">7</td><td style="text-align:center">66.726003</td><td style="text-align:center">673.373629</td><td style="text-align:center">Bla</td><td style="text-align:center">28-52-6556</td><td style="text-align:center">1</td><td style="text-align:center">0539</td><td style="text-align:center">0946-62</td><td style="text-align:center">0</td><td style="text-align:center">7</td><td style="text-align:center"></td><td style="text-align:center">9</td><td style="text-align:center">37</td><td style="text-align:center">10</td><td style="text-align:center">1</td><td style="text-align:center">6</td><td style="text-align:center">0</td><td style="text-align:center">2</td><td style="text-align:center">2</td><td style="text-align:center">6</td><td style="text-align:center">5</td><td style="text-align:center">BlahBlahBlahBlahBlahBlahBlahBlah.zip</td><td style="text-align:center">BlahBlahBlahBlahBlahBlahBlahBlah.zip</td><td style="text-align:center">BlahBlahBlahBlahBlahBlahBlahBlah.zip</td><td style="text-align:center">BlahBlahBlahBlahBlahBlahBlahBlah.zip</td><td style="text-align:center">BlahBlahBlahBlahBlahBlahBlahBlah.zip</td><td style="text-align:center">BlahBlahBlahBlahBlahBlahBlahBlah.zip</td><td style="text-align:center">BlahBlahBlahBlahBlahBlahBlahBlah.zip</td><td style="text-align:center">BlahBlahBlahBlahBlahBlahBlahBlah.zip</td><td style="text-align:center"></td><td style="text-align:center">BlahBlahBlahBlahBlahBlahBlahBlah.zip</td><td style="text-align:center"></td><td style="text-align:center">0</td><td style="text-align:center">0154-19-62 45:26:74</td><td style="text-align:center">NULL</td><td style="text-align:center">8386-95-23 46:29:47</td><td style="text-align:center">633</td><td style="text-align:center">5599-96-95 73:86:61</td><td style="text-align:center">980.050.214.923</td></tr>';
$results .= PHP_EOL . '</table>';
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>Test PHP Exit Flush</title></head>
<body bgcolor="white">
<p><a href="menu.php">Return to Menu</a></p>
<?php echo $results; //the following lines will not be in the output if MAXROWS >= 2 ?>
<p><a href="menu.php">Return to Menu</a></p>
</body></html>
<?php ob_flush(); flush(); //try to flush it out, but doesn't work ?>


Expected result:
----------------
A second "Return to Menu" line should be displayed.

Actual result:
--------------
The following two lines are never output:
<p><a href="menu.php">Return to Menu</a></p>
</body></html>

Patches

php.ini (last revision 2011-10-27 14:49 UTC) by david dot gero at ec dot gc dot ca)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-26 22:47 UTC] david dot gero at ec dot gc dot ca
Test script had lines truncated.  Will try to upload as a patch.
 [2011-10-26 22:56 UTC] david dot gero at ec dot gc dot ca
Okay, your bug system has me stumped.  Can't upload the test script, because I get the following:

Error: uploaded patch file must be text file (save as e.g. "patch.txt" or "package.diff") (detected "text/x-php")
Could not attach patch "testflush.php" to Bug #60146

Interesting bug that "text/x-php" is not considered text.
The test script is only 20 lines, but some of them are long.

Email me with a good return address and I will send the test script to you.  Or maybe you could tell me how I'm supposed to upload it.
 [2011-10-27 09:44 UTC] laruence@php.net
rename to testflush.txt, thanks
 [2011-10-27 09:50 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2011-10-27 09:50 UTC] laruence@php.net
and, I can't reproduce this in my environ with your test script pasted above.
plz check your php error log, if there is some error. thanks
 [2011-10-27 14:33 UTC] david dot gero at ec dot gc dot ca
Renaming to testflush.txt gives the following:

Error: uploaded patch file must be text file (save as e.g. "patch.txt" or "package.diff") (detected "text/x-php")
Could not attach patch "testflush.txt" to Bug #60146

Your upload system is scanning inside the file, probably using the "file" command, which indeed gives type "text/x-php", regardless of the extension.  However why this is not accepted as text by your system is a mystery, and a bug in itself.

I will email you the script, and hope you can figure out how to upload it.
 [2011-10-27 15:00 UTC] david dot gero at ec dot gc dot ca
Looks like I was wrong about the test script being truncated above.  Just didn't scroll far enough to the right.

So, if you can't reproduce, whereas it fails every time for me, I've uploaded my php.ini file.

There are no errors in php_error.log

I'm testing on Windows XP with Service Pack 3, running the following startup.cmd:

@echo off
title PHP
start "PHP" /MAX php -S 127.0.0.1:8000 -t \repos\gerod\html
exit

testflush.php is in \repos\gerod\html\admin\testflush.php

Using Internet Explorer 7 at http://localhost:8000/admin/testflush.php

Page->View Source shows that the last two lines were never output
 [2011-10-27 18:06 UTC] david dot gero at ec dot gc dot ca
Tried using curl from cygwin to access the page, and the last two lines are missing the same way, so the problem is not Internet Explorer
 [2011-10-29 02:14 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=318540
Log: Fixed bug #60146 (Last 2 lines of page not being output)
 [2011-10-29 02:14 UTC] laruence@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: laruence
 [2011-10-29 02:14 UTC] laruence@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-04-18 09:48 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=62270fef736ad8338d66be4d32dcbcf75b5e5995
Log: Fixed bug #60146 (Last 2 lines of page not being output)
 [2012-07-24 23:39 UTC] rasmus@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=62270fef736ad8338d66be4d32dcbcf75b5e5995
Log: Fixed bug #60146 (Last 2 lines of page not being output)
 [2013-11-17 09:35 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=62270fef736ad8338d66be4d32dcbcf75b5e5995
Log: Fixed bug #60146 (Last 2 lines of page not being output)
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 16:02:22 2014 UTC