From: Zeev Suraski Date: Sun, 12 Jan 2003 12:39:06 +0000 (+0000) Subject: Implemented compatibility mode X-Git-Tag: PHP_5_0_dev_before_13561_fix~302 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=424e98f4e2f14230f8743ddad85058fe1e0ad391;p=php Implemented compatibility mode To enable - zend2.implicit_clone = on in php.ini or using ini_set() --- diff --git a/Zend/zend.c b/Zend/zend.c index 3ddb4e279e..ff9e818fab 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -69,8 +69,20 @@ static ZEND_INI_MH(OnUpdateErrorReporting) } +static ZEND_INI_MH(OnUpdateImplicitClone) +{ + if (!new_value) { + EG(implicit_clone) = 0; + } else { + EG(implicit_clone) = atoi(new_value) ? 1 : 0; + } + return SUCCESS; +} + + ZEND_INI_BEGIN() ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting) + ZEND_INI_ENTRY("zend2.implicit_clone", NULL, ZEND_INI_ALL, OnUpdateImplicitClone) ZEND_INI_END() @@ -268,7 +280,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) ZEND_PUTS(" *RECURSION*"); object->properties->nApplyCount--; return; - } + } zend_printf("%s Object (", object->ce->name); print_flat_hash(object->properties); ZEND_PUTS(")"); @@ -287,7 +299,7 @@ ZEND_API void zend_print_zval_r(zval *expr, int indent) } -ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent) +ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent) { switch (expr->type) { case IS_ARRAY: @@ -333,7 +345,7 @@ static FILE *zend_fopen_wrapper(const char *filename, char **opened_path) static void register_standard_class(void) { zend_standard_class_def = malloc(sizeof(zend_class_entry)); - + zend_standard_class_def->type = ZEND_INTERNAL_CLASS; zend_standard_class_def->name_length = sizeof("stdClass") - 1; zend_standard_class_def->name = zend_strndup("stdClass", zend_standard_class_def->name_length); @@ -730,7 +742,7 @@ void zend_deactivate_modules(TSRMLS_D) void zend_deactivate(TSRMLS_D) { /* we're no longer executing anything */ - EG(opline_ptr) = NULL; + EG(opline_ptr) = NULL; EG(active_symbol_table) = NULL; zend_try { @@ -864,7 +876,7 @@ ZEND_API void zend_error(int type, const char *format, ...) z_error_filename->value.str.val = estrndup(error_filename, z_error_filename->value.str.len); z_error_filename->type = IS_STRING; } - + z_error_lineno->value.lval = error_lineno; z_error_lineno->type = IS_LONG; @@ -944,7 +956,7 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co zend_file_handle *file_handle; zend_op_array *orig_op_array = EG(active_op_array); zval *local_retval=NULL; - + va_start(files, file_count); for (i=0; iopcodes[last_op_number]; if (last_op->opcode == ZEND_FETCH_OBJ_RW) { - switch (op) { case ZEND_ASSIGN_ADD: opline->opcode = ZEND_ASSIGN_ADD_OBJ; diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 2c0791359c..18e048ad90 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -304,6 +304,11 @@ static inline void zend_assign_to_object(znode *result, znode *op1, znode *op2, break; } + if (EG(implicit_clone)) { + SEPARATE_ZVAL_IF_NOT_REF(object_ptr); + object = *object_ptr; + } + /* here property is a string */ Z_OBJ_HT_P(object)->write_property(object, property, value TSRMLS_CC); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index ea5f8df57c..9e7f8e5c7b 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -129,6 +129,7 @@ void init_executor(TSRMLS_D) EG(symtable_cache_ptr) = EG(symtable_cache)-1; EG(symtable_cache_limit)=EG(symtable_cache)+SYMTABLE_CACHE_SIZE-1; EG(no_extensions)=0; + EG(implicit_clone)=0; EG(function_table) = CG(function_table); EG(class_table) = CG(class_table); diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index a8f4fbdf40..df8b928c6b 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -177,6 +177,7 @@ struct _zend_executor_globals { zend_bool in_execution; zend_bool bailout_set; zend_bool full_tables_cleanup; + zend_bool implicit_clone; /* for extended information support */ zend_bool no_extensions; diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index a1c81ab03f..3bc0136751 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -75,6 +75,15 @@ ZEND_API int zend_ini_startup(TSRMLS_D) ZEND_API int zend_ini_shutdown(TSRMLS_D) { zend_hash_destroy(EG(ini_directives)); + free(EG(ini_directives)); + return SUCCESS; +} + + +ZEND_API int zend_ini_global_shutdown(TSRMLS_D) +{ + zend_hash_destroy(registered_zend_ini_directives); + free(registered_zend_ini_directives); return SUCCESS; } diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h index 16d8bbd274..e6cd22a770 100644 --- a/Zend/zend_ini.h +++ b/Zend/zend_ini.h @@ -84,6 +84,7 @@ struct _zend_ini_entry { ZEND_API int zend_ini_startup(TSRMLS_D); ZEND_API int zend_ini_shutdown(TSRMLS_D); +ZEND_API int zend_ini_global_shutdown(TSRMLS_D); ZEND_API int zend_ini_deactivate(TSRMLS_D); ZEND_API int zend_copy_ini_directives(TSRMLS_D); diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c index 729d0a76b4..0943cf4873 100644 --- a/Zend/zend_variables.c +++ b/Zend/zend_variables.c @@ -126,11 +126,12 @@ ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC) case IS_OBJECT: { TSRMLS_FETCH(); -#if 0 - zvalue->value.obj = zvalue->value.obj.handlers->clone_obj(zvalue->value.obj.handle); -#else - Z_OBJ_HT_P(zvalue)->add_ref(zvalue TSRMLS_CC); -#endif + + if (EG(implicit_clone)) { + zvalue->value.obj = zvalue->value.obj.handlers->clone_obj(zvalue TSRMLS_CC); + } else { + Z_OBJ_HT_P(zvalue)->add_ref(zvalue TSRMLS_CC); + } } break; }