JosephLenton / PHP-Error

Better error reporting for PHP, and prettier too!
1.35k stars 151 forks source link

My php program is wrapped in ob_* function. #76

Open kargnas opened 11 years ago

kargnas commented 11 years ago

PHP-Error using ob* function. But my site use ob*function, too.

I think many websites programmed like this, this issue is need to resolve.

reFX-Mike commented 10 years ago

Sample problem here. I use sessions and the whole website is wrapped into multiple ob_* functions that act as a quasi-macro-template engine.

<?php ob_start('ob_gzhandler'); session_start(); ob_start('ob_fancyBox'); ob_start('ob_bxSlider');

// Generate output here

?>

After the script 'ends', the ob_functions get called in reverse order, adding required javascript etc. to the headers only when they are actually needed.

If I try to use phperror in this context, all I get is a blank-page, even when no error occurs.

bitifet commented 10 years ago

Maybe you can use ob_get_level() to determine how many buffering levels you are in and deconstruct it storing contents in a array stack with ob_get_clean().

Then write whatever you want to stdout and rebuild all buffering levels again walking above mentioned stack and executing ob_start() and echoing data per each stack level.

The problem is that, if the application needs to output any http header you already have initiated the document output and end up with a warning (and no header emitted at all).

Alternatively, you may store your output in some variable and render it at the really end of the script execution by custom shutdown function...

reFX-Mike commented 10 years ago

Are you suggesting I should re-write how my entire website works to accommodate phperror? Don't you think that's a little backwards?

I just tried to provide more detailed information, so it would aid in debugging the potential problem.

In my particular case, no headers OR content are send to the output until the VERY end, after the last ob_handler (the one that gz_compresses everything) is processed.

bitifet commented 10 years ago

No. I don't suggest anything.

I'm only provided a few ideas about how to address the problem. No matter where it is implemented.

Actually, I where thinking about defining the above mentioned shutdown function within php-error itself. Why not?

And, finally: I don't know who you are. You could be a developper interested in contributing to achieve the solution or a php-error active developper (which I'm not)

If you are offended because I tryed to help, I apologize for that. But I'm not too much worried... ;-)

bullfrogchampion commented 9 years ago

I know I'm a bit late to the party, but I've just submitted a pull request for this issue. Because this is only my second ever pull request, I didn't link it to this issue properly, but I think they should at least mention each other now.