com php-src: fix foreach clean non persistent type info: Zend/zend_execute.h Zend/zend_execute_API.c Zend/ zend_vm_def.h
| From: | Bob Weinand | Date: | Mon, 04 Apr 2016 22:54:22 +0000 |
| Subject: | com php-src: fix foreach clean non persistent type info: Zend/zend_execute.h Zend/zend_execute_API.c Zend/ zend_vm_def.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95648@lists.php.net to get a copy of this message | ||
Commit: c6eb6d25ad2611b419a17f125a0be7259d248669
Author: Joe Watkins <krakjoe@php.net> Mon, 4 Apr 2016 23:54:22 +0100
Parents: efe506a9de5695fd684dc733b91002d6bb9cb613
Branches: typed_ref_properties
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c6eb6d25ad2611b419a17f125a0be7259d248669
Log:
fix foreach
clean non persistent type info
Changed paths:
M Zend/zend_execute.h
M Zend/zend_execute_API.c
M Zend/zend_vm_def.h
Diff:
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index 28889c3..c0ff23d 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -362,6 +362,8 @@ void zend_cleanup_unfinished_execution(zend_execute_data *execute_data, uint32_t
} \
} while (0)
+#define ZEND_CLASS_HAS_TYPE_HINTS(ce) ((ce->ce_flags & ZEND_ACC_HAS_TYPE_HINTS) ==
ZEND_ACC_HAS_TYPE_HINTS)
+
static zend_always_inline zend_bool _zend_object_has_type_hints(zval *object) {
do {
if (Z_TYPE_P(object) != IS_OBJECT) {
@@ -374,7 +376,7 @@ static zend_always_inline zend_bool _zend_object_has_type_hints(zval *object) {
}
}
- return (Z_OBJCE_P(object)->ce_flags & ZEND_ACC_HAS_TYPE_HINTS) == ZEND_ACC_HAS_TYPE_HINTS;
+ return ZEND_CLASS_HAS_TYPE_HINTS(Z_OBJCE_P(object));
} while (0);
return 0;
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index dc2ce46..99c6475 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -111,6 +111,25 @@ ZEND_API int clean_non_persistent_function_full(zval *zv) /* {{{ */
}
/* }}} */
+static int clean_non_persistent_type_info(zval *zv) /* {{{ */
+{
+ zend_class_entry *ce = Z_PTR_P(zv);
+
+ if (UNEXPECTED(ce->type == ZEND_INTERNAL_CLASS)) {
+ if (ZEND_CLASS_HAS_TYPE_HINTS(ce)) {
+ zend_property_info *prop_info;
+ ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) {
+ if (prop_info->type_ce->type == ZEND_USER_CLASS) {
+ prop_info->type_ce = NULL;
+ }
+ } ZEND_HASH_FOREACH_END();
+ }
+ return ZEND_HASH_APPLY_KEEP;
+ }
+
+ return ZEND_HASH_APPLY_STOP;
+} /* }}} */
+
static int clean_non_persistent_class(zval *zv) /* {{{ */
{
zend_class_entry *ce = Z_PTR_P(zv);
@@ -358,6 +377,9 @@ void shutdown_executor(void) /* {{{ */
zend_vm_stack_destroy();
+ /* remove non persistent type info from internal classes */
+ zend_hash_apply(EG(class_table), clean_non_persistent_type_info);
+
/* Destroy all op arrays */
if (EG(full_tables_cleanup)) {
zend_hash_reverse_apply(EG(function_table), clean_non_persistent_function_full);
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 51a1e83..e03afc1 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -6470,6 +6470,9 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH_R, VAR, ANY, JMP_ADDR)
ZSTR_VAL(prop_info->ce->name),
ZSTR_VAL(p->key));
HANDLE_EXCEPTION();
+ } else if (!zend_verify_property_type(prop_info, value, EX_USES_STRICT_TYPES())) {
+ zend_verify_property_type_error(prop_info, p->key, value);
+ HANDLE_EXCEPTION();
}
}
}