Search code examples
phpbuffersuphp

suPHP using unbuffered output?


I have a script on a shared host that uses suPHP. I need unbuffered output (so I can flush before starting a lengthy subroutine) but can't find anyway to get it working, so my flush calls basically just get ignored. I have tried tweaking the .htaccess (which results in a 500 internal error), I've tried modifying a php.ini at the account level and in the folder level for the specific script (both of which seem to be completely ignored, I can't for example disable the php engine with engine = Off or suphp_engine = Off).

How can I get buffering disabled (might have to ask my hosting provider, but what do I ask them to change specifically)? Is it even possible with suPHP?


Solution

  • After talking with my hosting support some more I finally got php.ini to get recognized, but dissabling or altering the buffer size there has no effect. It's fairly poorly documented (one comment on the php official docs as far as I can tell) but it seems suPHP buffers ALL output AFTER the internal php buffers. So flush is working... but all the output is getting buffered again by suPHP and there's no way around it. So if you're using suPHP you're stuck behind a second buffer that can't be turned off, and the end result is flushes will have no effect. You can use the other buffer commands, such as buffering so you can send headers further through a script, to control flow, but the total output behind suPHP goes through a buffer before going out.