From 25c5d185fcece7620f4b1790fd705999757f3b2f Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 30 Nov 2015 16:52:57 +0300 Subject: Fixed bug #70997 (When using parentClass:: instead of parent::, static context changed) --- NEWS | 2 ++ Zend/tests/bug70997.phpt | 26 ++++++++++++++++++++++++++ Zend/zend_vm_def.h | 4 ++-- Zend/zend_vm_execute.h | 32 ++++++++++++++++---------------- 4 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 Zend/tests/bug70997.phpt diff --git a/NEWS b/NEWS index c5aa1f30fd..e74a35181b 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ PHP NEWS ?? ??? 2015, PHP 7.0.1 - Core: + . Fixed bug #70997 (When using parentClass:: instead of parent::, static + context changed). (Dmitry) . Fixed bug #70970 (Segfault when combining error handler with output buffering). (Laruence) . Fixed bug #70967 (Weird error handling for __toString when Error is diff --git a/Zend/tests/bug70997.phpt b/Zend/tests/bug70997.phpt new file mode 100644 index 0000000000..bdb3377c74 --- /dev/null +++ b/Zend/tests/bug70997.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #70997 (When using parentClass:: instead of parent::, static context changed) +--FILE-- +test(); +--EXPECT-- +bool(true) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 8fae72b2f6..bc41a0bacf 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3102,8 +3102,8 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMPVAR|UNUSE if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) { if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) { object = Z_OBJ(EX(This)); - } - if (!object) { + ce = object->ce; + } else { if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* Allowed for PHP 4 compatibility. */ zend_error( diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 5f02d4357e..74adfe4da0 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -5692,8 +5692,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) { if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) { object = Z_OBJ(EX(This)); - } - if (!object) { + ce = object->ce; + } else { if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* Allowed for PHP 4 compatibility. */ zend_error( @@ -7667,8 +7667,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) { if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) { object = Z_OBJ(EX(This)); - } - if (!object) { + ce = object->ce; + } else { if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* Allowed for PHP 4 compatibility. */ zend_error( @@ -9410,8 +9410,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) { if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) { object = Z_OBJ(EX(This)); - } - if (!object) { + ce = object->ce; + } else { if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* Allowed for PHP 4 compatibility. */ zend_error( @@ -11218,8 +11218,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) { if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) { object = Z_OBJ(EX(This)); - } - if (!object) { + ce = object->ce; + } else { if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* Allowed for PHP 4 compatibility. */ zend_error( @@ -17547,8 +17547,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) { if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) { object = Z_OBJ(EX(This)); - } - if (!object) { + ce = object->ce; + } else { if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* Allowed for PHP 4 compatibility. */ zend_error( @@ -19175,8 +19175,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) { if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) { object = Z_OBJ(EX(This)); - } - if (!object) { + ce = object->ce; + } else { if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* Allowed for PHP 4 compatibility. */ zend_error( @@ -20796,8 +20796,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) { if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) { object = Z_OBJ(EX(This)); - } - if (!object) { + ce = object->ce; + } else { if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* Allowed for PHP 4 compatibility. */ zend_error( @@ -22366,8 +22366,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) { if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) { object = Z_OBJ(EX(This)); - } - if (!object) { + ce = object->ce; + } else { if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { /* Allowed for PHP 4 compatibility. */ zend_error( -- cgit v1.2.1