Skip to content

Commit 9c7cb2c

Browse files
committed
Merge branch 'PHP-7.0' of git.php.net:/php-src into PHP-7.0
* 'PHP-7.0' of git.php.net:/php-src: Add NEWS Resolve bug #74188 (undefined statics raising with ?? operator) Fixed bug #72071: Prevent Max-Age from being negative Update NEWS with OpenSSL 1.1.0 support info Add OpenSSL 1.1.0 support to PHP 7.0
2 parents 341ff71 + 75b83ec commit 9c7cb2c

File tree

15 files changed

+789
-288
lines changed

15 files changed

+789
-288
lines changed

Zend/tests/bug74188.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Fixes bug 74188 (undeclared static variables emit a warning with ?? operator)
3+
--FILE--
4+
<?php
5+
abstract class Test
6+
{
7+
public static function get()
8+
{
9+
static::$a ?? true;
10+
}
11+
}
12+
Test::get();
13+
?>
14+
--EXPECT--

Zend/zend_vm_def.h

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,9 +1515,13 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMPVAR|CV, UNUSED|CONST|V
15151515

15161516
/* check if static properties were destoyed */
15171517
if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
1518-
zend_throw_error(NULL, "Access to undeclared static property: %s::$%s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
1519-
FREE_OP1();
1520-
HANDLE_EXCEPTION();
1518+
if (type == BP_VAR_IS) {
1519+
retval = &EG(uninitialized_zval);
1520+
} else {
1521+
zend_throw_error(NULL, "Access to undeclared static property: %s::$%s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
1522+
FREE_OP1();
1523+
HANDLE_EXCEPTION();
1524+
}
15211525
}
15221526

15231527
ZEND_VM_C_GOTO(fetch_var_return);
@@ -1539,24 +1543,32 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMPVAR|CV, UNUSED|CONST|V
15391543

15401544
/* check if static properties were destoyed */
15411545
if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
1542-
zend_throw_error(NULL, "Access to undeclared static property: %s::$%s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
1543-
FREE_OP1();
1544-
HANDLE_EXCEPTION();
1546+
if (type == BP_VAR_IS) {
1547+
retval = &EG(uninitialized_zval);
1548+
} else {
1549+
zend_throw_error(NULL, "Access to undeclared static property: %s::$%s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
1550+
FREE_OP1();
1551+
HANDLE_EXCEPTION();
1552+
}
15451553
}
15461554

15471555
ZEND_VM_C_GOTO(fetch_var_return);
15481556
}
15491557
}
1550-
retval = zend_std_get_static_property(ce, name, 0);
1558+
retval = zend_std_get_static_property(ce, name, type == BP_VAR_IS);
15511559
if (UNEXPECTED(EG(exception))) {
15521560
if (OP1_TYPE != IS_CONST) {
15531561
zend_string_release(name);
15541562
}
15551563
FREE_OP1();
15561564
HANDLE_EXCEPTION();
15571565
}
1558-
if (OP1_TYPE == IS_CONST && retval) {
1559-
CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce, retval);
1566+
if (EXPECTED(retval)) {
1567+
if (OP1_TYPE == IS_CONST) {
1568+
CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce, retval);
1569+
}
1570+
} else {
1571+
retval = &EG(uninitialized_zval);
15601572
}
15611573

15621574
FREE_OP1();

0 commit comments

Comments
 (0)