com php-src: Add more tests for __debugInfo() and f ix leak: Zend/tests/debug_info-error-0.0.phpt Zend/tests/debug_info-error-0.phpt Zend/tests/debug
_info-error-1.0.phpt Zend/tests/debug_info-error- 1.phpt Zend/tests/debug_info-error-empty_str.phpt Zend/tests/debug_info-error-false.phpt
Zend/tests/debu g_info-error-object.phpt Zend/tests/debug_info-error-re source.phpt Zend/tests/debug_info-error-str.phpt Zend
/tests/debug_info-error-true.phpt Zend/te
| From: | Sara Golemon | Date: | Thu, 20 Feb 2014 20:10:00 +0000 |
| Subject: | com php-src: Add more tests for __debugInfo() and f ix leak: Zend/tests/debug_info-error-0.0.phpt Zend/tests/debug_info-error-0.phpt Zend/tests/debug _info-error-1.0.phpt Zend/tests/debug_info-error- 1.phpt Zend/tests/debug_info-error-empty_str.phpt Zend/tests/debug_info-error-false.phpt Zend/tests/debu g_info-error-object.phpt Zend/tests/debug_info-error-re source.phpt Zend/tests/debug_info-error-str.phpt Zend /tests/debug_info-error-true.phpt Zend/te |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76139@lists.php.net to get a copy of this message | ||
Commit: 14c08ea362e5f16527b3d9772ddc75ca49cc22d7
Author: Sara Golemon <pollita@php.net> Thu, 20 Feb 2014 11:55:27 -0800
Parents: b67c8b8603f7fa3914f51deefa5a265315179d80
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=14c08ea362e5f16527b3d9772ddc75ca49cc22d7
Log:
Add more tests for __debugInfo() and fix leak
Changed paths:
A Zend/tests/debug_info-error-0.0.phpt
A Zend/tests/debug_info-error-0.phpt
A Zend/tests/debug_info-error-1.0.phpt
A Zend/tests/debug_info-error-1.phpt
A Zend/tests/debug_info-error-empty_str.phpt
A Zend/tests/debug_info-error-false.phpt
A Zend/tests/debug_info-error-object.phpt
A Zend/tests/debug_info-error-resource.phpt
A Zend/tests/debug_info-error-str.phpt
A Zend/tests/debug_info-error-true.phpt
M Zend/tests/debug_info.phpt
M Zend/zend_object_handlers.c
Diff:
diff --git a/Zend/tests/debug_info-error-0.0.phpt b/Zend/tests/debug_info-error-0.0.phpt
new file mode 100644
index 0000000..67cbe8a
--- /dev/null
+++ b/Zend/tests/debug_info-error-0.0.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns ZERO (float)
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(0.0);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s/Zend/tests/debug_info-error-0.0.php on line
%d
diff --git a/Zend/tests/debug_info-error-0.phpt b/Zend/tests/debug_info-error-0.phpt
new file mode 100644
index 0000000..97352a8
--- /dev/null
+++ b/Zend/tests/debug_info-error-0.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns ZERO
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(0);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s/Zend/tests/debug_info-error-0.php on line %d
diff --git a/Zend/tests/debug_info-error-1.0.phpt b/Zend/tests/debug_info-error-1.0.phpt
new file mode 100644
index 0000000..e89a47c
--- /dev/null
+++ b/Zend/tests/debug_info-error-1.0.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns ONE (float)
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(1.0);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s/Zend/tests/debug_info-error-1.0.php on line
%d
diff --git a/Zend/tests/debug_info-error-1.phpt b/Zend/tests/debug_info-error-1.phpt
new file mode 100644
index 0000000..a77500d
--- /dev/null
+++ b/Zend/tests/debug_info-error-1.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns ONE
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(1);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s/Zend/tests/debug_info-error-1.php on line %d
diff --git a/Zend/tests/debug_info-error-empty_str.phpt b/Zend/tests/debug_info-error-empty_str.phpt
new file mode 100644
index 0000000..ea55b65
--- /dev/null
+++ b/Zend/tests/debug_info-error-empty_str.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns EMPTY STRING
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C("");
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s/Zend/tests/debug_info-error-empty_str.php on
line %d
diff --git a/Zend/tests/debug_info-error-false.phpt b/Zend/tests/debug_info-error-false.phpt
new file mode 100644
index 0000000..9e91113
--- /dev/null
+++ b/Zend/tests/debug_info-error-false.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns FALSE
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(false);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s/Zend/tests/debug_info-error-false.php on line
%d
diff --git a/Zend/tests/debug_info-error-object.phpt b/Zend/tests/debug_info-error-object.phpt
new file mode 100644
index 0000000..6562b5b
--- /dev/null
+++ b/Zend/tests/debug_info-error-object.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns OBJECT
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(new stdClass);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s/Zend/tests/debug_info-error-object.php on
line %d
diff --git a/Zend/tests/debug_info-error-resource.phpt b/Zend/tests/debug_info-error-resource.phpt
new file mode 100644
index 0000000..c6d7be4
--- /dev/null
+++ b/Zend/tests/debug_info-error-resource.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns RESOURCE
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(fopen("data:text/plain,Foo", 'r'));
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s/Zend/tests/debug_info-error-resource.php on
line %d
diff --git a/Zend/tests/debug_info-error-str.phpt b/Zend/tests/debug_info-error-str.phpt
new file mode 100644
index 0000000..230ad0e
--- /dev/null
+++ b/Zend/tests/debug_info-error-str.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns STRING
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C("foo");
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s/Zend/tests/debug_info-error-str.php on line
%d
diff --git a/Zend/tests/debug_info-error-true.phpt b/Zend/tests/debug_info-error-true.phpt
new file mode 100644
index 0000000..886c601
--- /dev/null
+++ b/Zend/tests/debug_info-error-true.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns TRUE
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(true);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s/Zend/tests/debug_info-error-true.php on line
%d
diff --git a/Zend/tests/debug_info.phpt b/Zend/tests/debug_info.phpt
index c7c9f23..c82ddb2 100644
--- a/Zend/tests/debug_info.phpt
+++ b/Zend/tests/debug_info.phpt
@@ -13,10 +13,21 @@ class Foo {
}
}
+class Bar {
+ public $val = 123;
+
+ public function __debugInfo() {
+ return null;
+ }
+}
+
$f = new Foo;
var_dump($f);
---EXPECT--
-object(Foo)#1 (3) {
+
+$b = new Bar;
+var_dump($b);
+--EXPECTF--
+object(Foo)#%d (3) {
["a"]=>
int(1)
["b":protected]=>
@@ -24,3 +35,5 @@ object(Foo)#1 (3) {
["c":"Foo":private]=>
int(3)
}
+object(Bar)#%d (0) {
+}
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index bc65313..2ba0539 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -164,6 +164,7 @@ ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC
zval ret;
array_init(&ret);
*is_temp = 1;
+ zval_ptr_dtor(&retval);
return Z_ARRVAL(ret);
}