Skip to content

Commit 7197f0f

Browse files
committed
Fixed confused exception message while user threw exception
1 parent f52b2e6 commit 7197f0f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Zend/tests/bug64354.phpt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #64354 (Unserialize array of objects whose class can't be autoloaded fail)
3+
--FILE--
4+
<?php
5+
class B implements Serializable {
6+
public function serialize() {
7+
throw new Exception("serialize");
8+
return NULL;
9+
}
10+
11+
public function unserialize($data) {
12+
}
13+
}
14+
15+
$data = array(new B);
16+
17+
try {
18+
serialize($data);
19+
} catch (Exception $e) {
20+
var_dump($e->getMessage());
21+
}
22+
?>
23+
--EXPECTF--
24+
string(9) "serialize"

Zend/zend_interfaces.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint
452452
zval_ptr_dtor(&retval);
453453
}
454454

455-
if (result == FAILURE) {
455+
if (result == FAILURE && !EG(exception)) {
456456
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "%s::serialize() must return a string or NULL", ce->name);
457457
}
458458
return result;

0 commit comments

Comments
 (0)