|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64152 php return wrong string with HEAD Request Method
Submitted: 2013-02-05 10:51 UTC Modified: 2015-04-13 15:23 UTC
Avg. Score:3.5 ± 1.7
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: mmicael at gmail dot com Assigned: mike (profile)
Status: Closed Package: Output Control
PHP Version: 5.4.11 OS: linux
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 !
Your email address:
Solve the problem:
13 - 13 = ?
Subscribe to this entry?

 [2013-02-05 10:51 UTC] mmicael at gmail dot com
When we do a HEAD Request Method in php 5.4, php continue executing script even 
if the output buffer exceed the max output_buffering.

the next ob_start, ob_get_contents always return empty string

In php 5.2 and 5.3, the script die after sending the first output buffer that 
reach  the max output_buffering.

Test script:
$string = '';
for($i=0;$i<5000;$i++) $string .= '0';

echo "test1";
$content = ob_get_contents();

echo $string;

echo "test2";
$content .= ob_get_contents();

echo $string;


Expected result:
In php 5.2 and 5.3


Actual result:
In php 5.4



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-05 11:00 UTC] mmicael at gmail dot com
Modifiying OS
 [2013-02-05 11:00 UTC] mmicael at gmail dot com
-Operating System: Any +Operating System: linux
 [2013-02-05 11:54 UTC] mmicael at gmail dot com
It seems that the behaviour have change with this commit

the ouput.c don't care anymore about headers_only
 [2013-02-05 13:16 UTC] yvan at dugwood dot com
Seems to be a duplicate of
 [2013-02-05 13:26 UTC] mmicael at gmail dot com
It's not the same bug

the other bug have already been integrated in php 5.4.11

my bug only appears with HEAD request_method
 [2013-02-07 14:54 UTC]
I cannot see a bug here, sure execution of the script continues...
 [2013-02-07 14:54 UTC]
-Status: Open +Status: Feedback
 [2013-02-07 14:59 UTC] mmicael at gmail dot com
-Status: Feedback +Status: Open
 [2013-02-07 14:59 UTC] mmicael at gmail dot com
it's only doing a HEAD request_method with curl -I for exemple

in php 5.2 and 5.3, the script is stopped after the echo $string;
in php 5.4, he continue bug the ob_get_contents after the echo $string; return 
empty response
 [2013-02-07 15:03 UTC]
-Status: Open +Status: Feedback
 [2013-02-07 15:03 UTC]
Which SAPI?
Are you sure, you don't see error_log output there?
 [2013-02-07 15:06 UTC] mmicael at gmail dot com
I am using php-fpm
 [2013-02-07 15:06 UTC] mmicael at gmail dot com
-Status: Feedback +Status: Open
 [2013-02-07 15:16 UTC]
Cannot reproduce.

I get no output with php-fpm in the response, but in the error_log.
 [2013-02-07 15:16 UTC]
-Status: Open +Status: Not a bug
 [2013-02-07 15:23 UTC] mmicael at gmail dot com
yes the script continue, but it log 


as we do a second ob_start ob_get_contents with an echo test2, after the echo 
$string, we should have in the logs

 [2013-02-07 15:45 UTC]
Ha, now I understand ;) Yes, this could be a regression.

php_output_header() checks headers_only and sets PHP_OUTPUT_DISABLED.
This leads to php_output_write() return immediately.
 [2013-02-07 15:45 UTC]
-Status: Not a bug +Status: Open -Assigned To: +Assigned To: mike
 [2013-03-27 14:04 UTC] mmicael at gmail dot com

did you find a patch to correct this bug ?

 [2015-04-13 15:23 UTC]
-Status: Assigned +Status: Closed
 [2015-04-13 15:23 UTC]
Behaviour sanitised in PHP-7. See
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 01 13:01:26 2023 UTC