Hello everyone,
I just had a very nasty bug. My app needs to create some charts on the fly, so i’m using http://www.zackbloom.org/ graphing library, copied to ‘application/libraries’ folder.
I was loading library as usual ($this->load->library(‘graph’)), and creating graphs correctly, but the image output was somehow corrupt. If I saved the file to server it worked fine but when I output it to browser it was corrupt. The headers sent back by server were correct but the image had some newlines before the real content. And guess what? The extra line breaks were at the end of graph.oo.php file. It took me more than hour (I’m completely new to CI as well as graph.oo.php) to find this problem.
I was thinking, that maybe you could add additional parameter to load->library() method $dropOutput, which would drop any output by this library.
I mean something like this in your library loading routine
<?php
if ($dropOutput) ob_start();
//load library as usual, include it's files and so on
if ($dropOutput) ob_end_clean();
?>
In my case it was very easy to fix it because I had only one file. But what if a library consists of tens of files? Such unintentional output doesn’t do too much harm for apps which only output text/html but as you see it can be deadly when dealing with images.
EDIT: Sorry, this might be more appropriate in Feature requests area.
