Skip to content

Commit 3da3b4c

Browse files
committed
Merge branch 'PHP-7.4'
2 parents d00036e + 6cc5398 commit 3da3b4c

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
Behavior of static variable in private trait method
3+
--FILE--
4+
<?php
5+
6+
trait T {
7+
private static function method() {
8+
static $x;
9+
if ($x === null) $x = new stdClass;
10+
return $x;
11+
}
12+
13+
public static function method2() {
14+
return self::method();
15+
}
16+
}
17+
18+
class C {
19+
use T;
20+
}
21+
22+
var_dump(C::method2());
23+
24+
class D extends C {
25+
use T;
26+
}
27+
28+
var_dump(D::method2());
29+
30+
?>
31+
--EXPECT--
32+
object(stdClass)#1 (0) {
33+
}
34+
object(stdClass)#2 (0) {
35+
}

Zend/zend_inheritance.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,19 @@ static zend_always_inline zend_function *zend_duplicate_function(zend_function *
9595
(*func->op_array.refcount)++;
9696
}
9797
if (is_interface
98-
|| EXPECTED(!func->op_array.static_variables)
99-
|| (func->op_array.fn_flags & ZEND_ACC_PRIVATE)) {
98+
|| EXPECTED(!func->op_array.static_variables)) {
10099
/* reuse the same op_array structure */
101100
return func;
102101
}
102+
if (func->op_array.fn_flags & ZEND_ACC_PRIVATE) {
103+
/* For private methods we reuse the same op_array structure even if
104+
* static variables are used, because it will not end up being used
105+
* anyway. However we still need to addref as the dtor will delref. */
106+
if (!(GC_FLAGS(func->op_array.static_variables) & IS_ARRAY_IMMUTABLE)) {
107+
GC_ADDREF(func->op_array.static_variables);
108+
}
109+
return func;
110+
}
103111
return zend_duplicate_user_function(func);
104112
}
105113
}

ext/standard/md5.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
167167
* doesn't work.
168168
*/
169169
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
170+
typedef ZEND_SET_ALIGNED(1, uint32_t unaligned_uint32_t);
170171
# define SET(n) \
171-
(*(uint32_t *)&ptr[(n) * 4])
172+
(*(unaligned_uint32_t *)&ptr[(n) * 4])
172173
# define GET(n) \
173174
SET(n)
174175
#else

0 commit comments

Comments
 (0)