Home » HTML » HTML_Progress » Bug #28
Small Errorhandling fix
Details
| Submitted | 2003-09-22 14:42 UTC |
|---|---|
| From | info at rhalff dot com |
| Assigned | farell |
| Status | Closed |
| Package | HTML_Progress |
| PHP Version | Irrelevant |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2003-09-22 14:42 UTC] info at rhalff dot com
Description:
------------
When using strict errorhandling HTML_Progress fails on line 500. Because ob_end_clean want to clean a still empty buffer.
This is solved by using a @ in front of ob_end_clean, but it still throws a E_NOTICE. Developers enabling this error level will not be able to run HTML_Progress.
From the php manual about the function ob_end_clean :
If the function fails it generates an E_NOTICE
fix: use ob_get_clean() instead of ob_get_contents.
old:
$bar = ob_get_contents();
$bar .= $this->_lineEnd;
@ob_end_clean();
new:
$bar = ob_get_clean();
$bar .= $this->_lineEnd;
Reproduce code:
---------------
error_reporting(E_ALL);
function php_error_handler($errno, $errstr, $errfile, $errline)
{
die("$errstr in $errfile at line $errline: $errstr");
}
set_error_handler('php_error_handler');
require_once ('HTML/Progress/BarHorizontal.php');
$pkg = array('PEAR', 'Config');
$bar = new HTML_Progress_Bar_Horizontal();
for ($i=0; $i<2; $i++) {
$bar->display(50);
echo "installing package ... : ". $pkg[$i] ."<br /> \n";
}
Expected result:
----------------
Cool progressing bar..
Actual result:
--------------
ob_end_clean() [ref.outcontrol]: failed to delete buffer. No buffer to delete. in /usr/lib/php/HTML/Progress.php at line 590: ob_end_clean() [ref.outcontrol]: failed to delete buffer. No buffer to delete.