]> granicus.if.org Git - php/commitdiff
Fixed bug #64417 (ArrayAccess::&offsetGet() in a trait causes fatal error)
authorDmitry Stogov <dmitry@zend.com>
Tue, 19 Mar 2013 08:48:23 +0000 (12:48 +0400)
committerDmitry Stogov <dmitry@zend.com>
Tue, 19 Mar 2013 08:48:23 +0000 (12:48 +0400)
NEWS
Zend/tests/bug64417.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/NEWS b/NEWS
index fd05e22e012850c6ef731ea92dfa689a44fb4bb4..75b588bfaedc17b8748d2d31801c4c24ed2c1d22 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2013, PHP 5.4.14
 - Core
+  . Fixed bug #64417 (ArrayAccess::&offsetGet() in a trait causes fatal error).
+    (Dmitry)
   . Fixed bug #64370 (microtime(true) less than $_SERVER['REQUEST_TIME_FLOAT']).
     (Anatol)
 
diff --git a/Zend/tests/bug64417.phpt b/Zend/tests/bug64417.phpt
new file mode 100644 (file)
index 0000000..f3ef740
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+Bug #64417 (BC break: ArrayAccess::&offsetGet() in a trait causes fatal error)
+--FILE--
+<?php
+trait aa {
+    private $container = array();
+    public function offsetSet($offset, $value) {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+    public function offsetExists($offset) {
+        return isset($this->container[$offset]);
+    }
+    public function offsetUnset($offset) {
+        unset($this->container[$offset]);
+    }
+    public function &offsetGet($offset) {
+       $result = null;
+        if (isset($this->container[$offset])) {
+            $result = &$this->container[$offset];
+        }
+        return $result;
+    }
+}
+
+class obj implements ArrayAccess {
+    use aa;
+}
+
+$o = new obj;
+$o['x'] = 1;
+++$o['x'];
+echo $o['x'], "\n";
+--EXPECT--
+2
+
index 0a1749dbd876bc806bc6cd628172c77c91f88252..766a2de01a3bc9a7720b5127113f7c4d97caef6b 100644 (file)
@@ -3634,7 +3634,7 @@ static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_
        zend_uint other_flags = other_fn->common.scope->ce_flags;
        
        return zend_do_perform_implementation_check(fn, other_fn TSRMLS_CC)
-               && zend_do_perform_implementation_check(other_fn, fn TSRMLS_CC)
+               && ((other_fn->common.scope->ce_flags & ZEND_ACC_INTERFACE) || zend_do_perform_implementation_check(other_fn, fn TSRMLS_CC))
                && ((fn_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC)) == 
                    (other_flags & (ZEND_ACC_FINAL|ZEND_ACC_STATIC))); /* equal final and static qualifier */
 }