]> granicus.if.org Git - php/commitdiff
Fixed confused exception message while user threw exception
authorXinchen Hui <laruence@php.net>
Sat, 9 Mar 2013 15:08:14 +0000 (23:08 +0800)
committerXinchen Hui <laruence@php.net>
Sat, 9 Mar 2013 15:08:14 +0000 (23:08 +0800)
Zend/tests/bug64354.phpt [new file with mode: 0644]
Zend/zend_interfaces.c

diff --git a/Zend/tests/bug64354.phpt b/Zend/tests/bug64354.phpt
new file mode 100644 (file)
index 0000000..03a4b80
--- /dev/null
@@ -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"
index 384b66da4b54593c81e901a09742bdaca2e22b4e..e2e81ed326ad5bedfa95317b2798014c13fec5eb 100644 (file)
@@ -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;