summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2013-03-09 23:08:14 +0800
committerXinchen Hui <laruence@php.net>2013-03-09 23:08:14 +0800
commit7197f0ffccea7f195bc28571e30c389eadda874b (patch)
treeaaf1095aed2900460c5aa0eaced3b4ede26bec69
parentf52b2e6a6572018eb61ad830206ed172b033232a (diff)
downloadphp-git-7197f0ffccea7f195bc28571e30c389eadda874b.tar.gz
Fixed confused exception message while user threw exception
-rw-r--r--Zend/tests/bug64354.phpt24
-rw-r--r--Zend/zend_interfaces.c2
2 files changed, 25 insertions, 1 deletions
diff --git a/Zend/tests/bug64354.phpt b/Zend/tests/bug64354.phpt
new file mode 100644
index 0000000000..03a4b80b4b
--- /dev/null
+++ b/Zend/tests/bug64354.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #64354 (Unserialize array of objects whose class can't be autoloaded fail)
+--FILE--
+<?php
+class B implements Serializable {
+ public function serialize() {
+ throw new Exception("serialize");
+ return NULL;
+ }
+
+ public function unserialize($data) {
+ }
+}
+
+$data = array(new B);
+
+try {
+ serialize($data);
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+?>
+--EXPECTF--
+string(9) "serialize"
diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c
index 384b66da4b..e2e81ed326 100644
--- a/Zend/zend_interfaces.c
+++ b/Zend/zend_interfaces.c
@@ -452,7 +452,7 @@ ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, zend_uint
zval_ptr_dtor(&retval);
}
- if (result == FAILURE) {
+ if (result == FAILURE && !EG(exception)) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "%s::serialize() must return a string or NULL", ce->name);
}
return result;