ID:               27588
 Updated by:       [EMAIL PROTECTED]
 Reported By:      lsole at maresme dot net
-Status:           Open
+Status:           Bogus
 Bug Type:         Output Control
 Operating System: FreeBSD
 PHP Version:      4.3.4
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

When unserialize() fails (shouldn't normally) it throws 

E_NOTICE to allow you to see/log the problem. 


Previous Comments:
------------------------------------------------------------------------

[2004-03-14 08:21:39] lsole at maresme dot net

I think I've misunderstood what the error control operator was sending
to my custom error handling. I thought it was sending a zero error code
but what it does is to set error_reporting() to zero. Sorry!



Anyway, I wonder if it is not a bug that unserialize() throws an
E_NOTICE error if the input is not unserializable. The function
description says it should return FALSE but says nothing about throwing
errors. As an example, base64_decode() does not throw errors if the
input can't be decoded.

------------------------------------------------------------------------

[2004-03-13 13:42:17] lsole at maresme dot net

Description:
------------
@unserialize() throws E_NOTICE with custom handler

Reproduce code:
---------------
<?php

function myErrorHandler($errno, $errmsg, $filename, $linenum) {

        if ($errno == 0) return;

        $error_type = array(0 => 'No Error', 8 => 'Notice'); // just the ones
we need...

        echo '<b>' . $error_type[$errno] . '</b>: ' . $errmsg . ' in <b>' .
$filename . '</b> on line <b>' . $linenum . '</b><br>' . chr(10);

}

$a = 'abc123';

error_reporting(E_ALL);



$b = unserialize($a); // throws error because $a is not unserializable

if ($b === false) {echo 'failed!<br>';} else {echo $b . '<br>';}

$b = @unserialize($a); // @ suppresses error

if ($b === false) {echo 'failed!<br>';} else {echo $b . '<br>';}



set_error_handler('myErrorHandler');



$b = unserialize($a); // throws error because $a is not unserializable

if ($b === false) {echo 'failed!<br>';} else {echo $b . '<br>';}

$b = @unserialize($a); // should throw nothing but throws Notice!

if ($b === false) {echo 'failed!<br>';} else {echo $b . '<br>';}

?>

Expected result:
----------------
E_NOTICE errors should not happen when prepending @: the custom handler
should receive $errno = 0

Actual result:
--------------
E_NOTICE error


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27588&edit=1

Reply via email to