google-code-export / firephp

Automatically exported from code.google.com/p/firephp
1 stars 0 forks source link

Warning raised with resource of type "Uknown type" #179

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.' **'; 

Original issue reported on code.google.com by thierry....@gmail.com on 4 Oct 2011 at 10:20

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by christ...@christophdorn.com on 8 Oct 2011 at 6:40