php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #52874
Patch refact_if revision 2010-09-18 01:27 UTC by cataphract@php.net

Patch refact_if for Scripting Engine problem Bug #52874

Patch version 2010-09-18 01:27 UTC

Return to Bug #52874 | Download this patch
Patch Revisions:

Developer: cataphract@php.net

Index: Zend/zend.h
===================================================================
--- Zend/zend.h	(revision 303334)
+++ Zend/zend.h	(working copy)
@@ -298,7 +298,7 @@
 typedef struct _zend_object {
 	zend_class_entry *ce;
 	HashTable *properties;
-	zval **properties_table;
+	zval **properties_table; /* actually stores zval** (not zval*) if properties != NULL */
 	HashTable *guards; /* protects from __get/__set ... recursion */
 } zend_object;
 
Index: Zend/zend_object_handlers.c
===================================================================
--- Zend/zend_object_handlers.c	(revision 303334)
+++ Zend/zend_object_handlers.c	(working copy)
@@ -382,7 +382,8 @@
 	zval **retval;
 	zval *rv = NULL;
 	zend_property_info *property_info;
-	int silent;
+	int silent,
+		is_defined;
 
 	silent = (type == BP_VAR_IS);
 	zobj = Z_OBJ_P(object);
@@ -404,14 +405,23 @@
 	/* make zend_get_property_info silent if we have getter - we may want to use it */
 	property_info = zend_get_property_info_quick(zobj->ce, member, (zobj->ce->__get != NULL), key TSRMLS_CC);
 
-	if (UNEXPECTED(!property_info) ||
-	    ((EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) &&
-	     property_info->offset >= 0) ?
-	        (zobj->properties ?
-	            ((retval = (zval**)zobj->properties_table[property_info->offset]) == NULL) :
-	            (*(retval = &zobj->properties_table[property_info->offset]) == NULL)) :
-	        (UNEXPECTED(!zobj->properties) ||
-	          UNEXPECTED(zend_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval) == FAILURE)))) {
+	if (EXPECTED(property_info == NULL)) {
+		is_defined = 0;
+	} else if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && property_info->offset >= 0) {
+		if (zobj->properties) {
+			retval = (zval**)zobj->properties_table[property_info->offset];
+			is_defined = (retval != NULL);
+		} else {
+			retval = &zobj->properties_table[property_info->offset];
+			is_defined = (*retval != NULL);
+		}
+	} else if (zobj->properties == NULL) {
+		is_defined = 0;
+	} else {
+		is_defined = (zend_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval) == SUCCESS);
+	}
+
+	if (!is_defined) {
 		zend_guard *guard = NULL;
 
 		if (zobj->ce->__get &&
@@ -475,6 +485,7 @@
 	zval *tmp_member = NULL;
 	zval **variable_ptr;
 	zend_property_info *property_info;
+	int is_defined;
 
 	zobj = Z_OBJ_P(object);
 
@@ -490,14 +501,23 @@
 
 	property_info = zend_get_property_info_quick(zobj->ce, member, (zobj->ce->__set != NULL), key TSRMLS_CC);
 
-	if (EXPECTED(property_info != NULL) &&
-	    ((EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) &&
-	     property_info->offset >= 0) ?
-	        (zobj->properties ?
-	            ((variable_ptr = (zval**)zobj->properties_table[property_info->offset]) != NULL) :
-	            (*(variable_ptr = &zobj->properties_table[property_info->offset]) != NULL)) :
-	        (EXPECTED(zobj->properties != NULL) &&
-	          EXPECTED(zend_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &variable_ptr) == SUCCESS)))) {
+	if (EXPECTED(property_info == NULL)) {
+		is_defined = 0;
+	} else if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) && property_info->offset >= 0) {
+		if (zobj->properties) {
+			variable_ptr = (zval**)zobj->properties_table[property_info->offset];
+			is_defined = (variable_ptr != NULL);
+		} else {
+			variable_ptr = &zobj->properties_table[property_info->offset];
+			is_defined = (*variable_ptr != NULL);
+		}
+	} else if (zobj->properties == NULL) {
+		is_defined = 0;
+	} else {
+		is_defined = (zend_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &variable_ptr) == SUCCESS);
+	}
+
+	if (is_defined) {
 		/* if we already have this value there, we don't actually need to do anything */
 		if (EXPECTED(*variable_ptr != value)) {
 			/* if we are assigning reference, we shouldn't move it, but instead assign variable
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 09:01:30 2024 UTC