Merge branch 'master' into phpng

* master:
  Removed second zval_copy_ctor()
  Fixed crash on self-referencing constant expression (part of a constant AST)
  Fixed support for constant arrays in context of "const" statement (Zend/tests/constant_expressions_arrays.phpt failed when opcache.protect_memort was set)

Conflicts:
	Zend/zend_ast.c
	Zend/zend_vm_def.h
	Zend/zend_vm_execute.h
	ext/reflection/php_reflection.c
This commit is contained in:
Dmitry Stogov 2014-07-24 01:54:21 +04:00
commit 7c6477ce37
3 changed files with 22 additions and 7 deletions

View File

@ -1,7 +1,5 @@
--TEST--
Self-referencing constant expression (part of a constant AST)
--XFAIL--
Not yet fixed, to be fixed for PHP 5.6
--FILE--
<?php
class A {

View File

@ -282,9 +282,17 @@ ZEND_API void zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *s
zval_dtor(&op2);
break;
case ZEND_CONST:
ZVAL_DUP(result, &ast->u.val);
if (Z_OPT_CONSTANT_P(result)) {
zval_update_constant_ex(result, 1, scope TSRMLS_CC);
/* class constants may be updated in-place */
if (scope) {
if (Z_OPT_CONSTANT(ast->u.val)) {
zval_update_constant_ex(&ast->u.val, 1, scope TSRMLS_CC);
}
ZVAL_DUP(result, &ast->u.val);
} else {
ZVAL_DUP(result, &ast->u.val);
if (Z_OPT_CONSTANT_P(result)) {
zval_update_constant_ex(result, 1, scope TSRMLS_CC);
}
}
break;
case ZEND_BOOL_AND:

View File

@ -722,9 +722,14 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset);
if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) {
zval zv;
zend_class_entry *old_scope;
string_write(str, " = ", sizeof(" = ")-1);
ZVAL_DUP(&zv, precv->op2.zv);
zval_update_constant_ex(&zv, 1, fptr->common.scope TSRMLS_CC);
old_scope = EG(scope);
EG(scope) = fptr->common.scope;
zval_update_constant_ex(&zv, 1, NULL TSRMLS_CC);
EG(scope) = old_scope;
if (Z_TYPE(zv) == IS_TRUE) {
string_write(str, "true", sizeof("true")-1);
} else if (Z_TYPE(zv) == IS_FALSE) {
@ -2578,7 +2583,11 @@ ZEND_METHOD(reflection_parameter, getDefaultValue)
ZVAL_COPY_VALUE(return_value, precv->op2.zv);
if (Z_CONSTANT_P(return_value)) {
zval_update_constant_ex(return_value, 0, param->fptr->common.scope TSRMLS_CC);
zend_class_entry *old_scope = EG(scope);
EG(scope) = param->fptr->common.scope;
zval_update_constant_ex(return_value, 0, NULL TSRMLS_CC);
EG(scope) = old_scope;
} else {
zval_copy_ctor(return_value);
}