What versions and operating system are you using?
OS: Max OS X Firefox: 7.0.1 Firebug: 1.8.3 FirePHP Server Library: 0.3.2 FirePHP Extension: 0.6.2
What is the problem?
When calling internally FirePHP->encodeObject, first parameter could be a resource of type 'Unknown type'. In this case, $Object would be considered as a string and its encoding checked. Passing it to mb_string_encoding raises a warning.
What steps will reproduce the problem?
1.
<?php
$handle = fopen( dirname( FILE) . '/test.php', 'w' );
create a resource of type "Unknown type"
fclose( $handle );
?>
2.
<?php
error_reporting( E_ALL );
function error_handler( $code, $message, $file_name, $line ) { $exception = new Exception( $message, $code );
$firephp = FirePHP::getInstance( TRUE );
$firephp->log( $exception );
}
set a custom error handler logging raised errors as exceptions
with FirePHP
set_error_handler( 'error_handler' );
?>
3.
<?php
call a constant which doesn't exists
raising a warning / logging an exception with a resource
of type "Unknown type" around
echo TEST_;
?>
What is the expected output? What do you see instead? expected > exception log actual output > warning + exception log
Warning: mb_detect_encoding() expects parameter 1 to be string, resource given in
Warning: utf8_encode() expects parameter 1 to be string, resource given
Please provide any additional information below.
To prevent the warning from being raised, I've added to encodeObject:
<?php if ( is_resource( $Object ) || ( gettype( $Object ) === 'unknown type' ) ) { return '** '.(string)$Object.' **';
Comment #1
Posted on Oct 8, 2011 by Happy Camel(No comment was entered for this change.)
Status: Accepted
Labels:
Type-Defect
Priority-Medium
Milestone-FirePHPCore-0.4.1
Code