php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47937 headers_sent() reports 'true' after system() call in ob_start()
Submitted: 2009-04-09 13:55 UTC Modified: 2010-12-20 12:41 UTC
From: till@php.net Assigned: iliaa (profile)
Status: Closed Package: Output Control
PHP Version: 5.2.9 OS:
Private report: No CVE-ID: None
 [2009-04-09 13:55 UTC] till@php.net
Description:
------------
This is the php -v from one of the servers:
PHP 5.2.9 with Suhosin-Patch 0.9.7 (cli) (built: Apr  9 2009 
03:31:34)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

This is another one (macosx):
PHP 5.2.9 (cli) (built: Apr  2 2009 16:07:08) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with Xdebug v2.0.4, Copyright (c) 2002-2008, by Derick Rethans

Right after my system() call, headers were send. This works 
differently in 5.2.6 and 5.2.8. I've scanned through 
UPDATING/CHANGELOG but couldn't find anything.

I've disabled APC to make sure it's not connected.

php -m:
[PHP Modules]
ctype
date
dom
filter
iconv
libxml
mbstring
mcrypt
mysqli
pcre
Reflection
session
SimpleXML
sockets
SPL
standard
tidy
xml
zlib


Also reproduced with RC1 on 5.3:

PHP 5.3.0RC1 (cli) (built: Apr  9 2009 15:45:09) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

Reproduce code:
---------------
<?php
ob_start();
system('file -i -b /path/file.txt');
$contents = ob_get_contents();
ob_end_clean();
var_dump(headers_sent($file, $line), $file, $line);

Expected result:
----------------
headers_sent() should return false.

Actual result:
--------------
headers_sent() returns true, with empty $file and $line = 0.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-13 18:01 UTC] jani@php.net
I can not reproduce this with Linux. Please try without the Suhosin 
patch.
 [2009-04-13 18:04 UTC] jani@php.net
Interesting:

# php-cgi -n  t.php
X-Powered-By: PHP/5.2.9
Content-type: text/html

bool(false)
string(0) ""
int(0)

# php-cgi -q -n  t.php
bool(true)
string(0) ""
int(0)

What SAPI are you using..?
 [2009-04-13 22:25 UTC] till@php.net
On FreeBSD with 5.2.9 the SAPI is apache2handler

The MacOSX 5.2.9 and 5.3.0RC1 is cli.

Do you still need me to try this on Linux? If so, I could compile 
5.2.9 and 5.3.0RC1 on Ubuntu tomorrow.
 [2009-04-15 11:31 UTC] lbarnaud@php.net
Verified, system() calls sapi_flush()
 [2009-04-19 15:01 UTC] iliaa@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.

FYI Jani: -q for cgi sets headers_sent setting to 1 right a way, hence the different result.
 [2009-04-19 15:18 UTC] till@php.net
Thanks, everyone. :)
 [2010-12-20 12:41 UTC] jani@php.net
-Package: Tidy +Package: Output Control -Assigned To: +Assigned To: iliaa
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC