PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject » Bug #8627

debug mode breaks next header() calls

Details

Submitted2006-09-03 20:31 UTC
Fromstephane dot gully at gmail dot com
Assignedalan_k
StatusClosed
PackageDB_DataObject
PHP Version4.4.2
OSLinux debian
Roadmaps(Not assigned)

Comments

[2006-09-03 20:31 UTC] stephane dot gully at gmail dot com

Description:
------------
DataObject::debug(...) methode uses flush().

When debug is turned on, it makes impossible to call header("...") next to the first dataobject request (for example ->get(...)).

Somebody else noticed this php behavior before me, look at this comment on the phpmanual:
http://www.php.net/manual/en/function.flush.php#69056

I personnaly think this is a bug or a strange behaviour in PHP itself. However, I think it whould be a great idea to unactivate these flush() calls in DataObject::debug() as long as the php bug is not fixed.

It takes me 4 hours to find why my programme didn't work ... I hope my bug report will help others.

Test script:
---------------
ob_start(); // should avoid outputs durring the dataobject requests

require_once('PEAR.php');
$options =& PEAR::getStaticProperty('DB_DataObject','options');
$options['debug'] = 1;
$dobj = new MyDataObject;
$dobj->get(50);

// now send a header (in my case it comes from an external library)
header("Content-Type: text/html;charset=utf-8");

ob_end_flush(); // only now, I display the dataobject debug

Expected result:
----------------
dataobjects_mydataobject: QUERY: SELECT * FROM mydataobject WHERE mydataobject.id = 50

Actual result:
--------------
[WARNING] Cannot modify header information - headers already sent error in line xxx of file xxx