ID:               27588
 User updated by:  lsole at maresme dot net
-Summary:          @unserialize() throws E_NOTICE with custom handler
 Reported By:      lsole at maresme dot net
 Status:           Open
 Bug Type:         Output Control
 Operating System: FreeBSD
 PHP Version:      4.3.4
 New Comment:

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.


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

[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