]> granicus.if.org Git - php/commitdiff
Fixed bug #70208 (Assert breaking access on objects)
authorBob Weinand <bobwei9@hotmail.com>
Fri, 7 Aug 2015 22:02:49 +0000 (00:02 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Fri, 7 Aug 2015 22:02:49 +0000 (00:02 +0200)
NEWS
Zend/tests/assert/bug70208.phpt [new file with mode: 0644]
ext/standard/assert.c

diff --git a/NEWS b/NEWS
index 0908a2db95817cb6bde7220b9e454bae2f47afba..22371a511db9406bf9961d05b8f68b175f000cf5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,8 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 20 Aug 2015, PHP 7.0.0 RC 1
 
-
+- Standard:
+  . Fixed bug #70208 (Assert breaking access on objects). (Bob)
 
 06 Aug 2015, PHP 7.0.0 Beta 3
 
diff --git a/Zend/tests/assert/bug70208.phpt b/Zend/tests/assert/bug70208.phpt
new file mode 100644 (file)
index 0000000..ec93253
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Bug #70208 (scope information must be preserved with assert())
+--FILE--
+<?php
+
+function non_class_scope() {
+       return true;
+}
+
+class test {
+       protected $prop = 1;
+
+       public function __construct() {
+               assert('non_class_scope();');
+               var_dump($this->prop);
+       }
+}
+
+new test;
+
+?>
+--EXPECT--
+int(1)
index 61dd286d6d6dacd2b753fef12b4a253e6fed420e..545c0998776a31c4a33b63a590f6fb8fb4f9fe8e 100644 (file)
@@ -164,6 +164,7 @@ PHP_FUNCTION(assert)
        if (Z_TYPE_P(assertion) == IS_STRING) {
                zval retval;
                int old_error_reporting = 0; /* shut up gcc! */
+               zend_class_entry *orig_scope = EG(scope);
 
                myeval = Z_STRVAL_P(assertion);
 
@@ -193,6 +194,8 @@ PHP_FUNCTION(assert)
                        EG(error_reporting) = old_error_reporting;
                }
 
+               EG(scope) = orig_scope;
+
                convert_to_boolean(&retval);
                val = Z_TYPE(retval) == IS_TRUE;
        } else {