]> granicus.if.org Git - php/commitdiff
Implemented compatibility mode
authorZeev Suraski <zeev@php.net>
Sun, 12 Jan 2003 12:39:06 +0000 (12:39 +0000)
committerZeev Suraski <zeev@php.net>
Sun, 12 Jan 2003 12:39:06 +0000 (12:39 +0000)
To enable - zend2.implicit_clone = on in php.ini or using ini_set()

Zend/zend.c
Zend/zend_compile.c
Zend/zend_execute.c
Zend/zend_execute_API.c
Zend/zend_globals.h
Zend/zend_ini.c
Zend/zend_ini.h
Zend/zend_variables.c

index 3ddb4e279e8fbb4df07faca7e3f3334c8b729531..ff9e818fabfd2670ff48315f42a973b142e1e1f6 100644 (file)
@@ -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; i<file_count; i++) {
                file_handle = va_arg(files, zend_file_handle *);
index 49b8550acc7600f7526bf646ae2a5c00ce82662d..fe36b8807b6d7c3b58c328653905f088efa0681c 100644 (file)
@@ -208,7 +208,6 @@ void zend_do_binary_assign_op(zend_uchar op, znode *result, znode *op1, znode *o
        zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number];
 
        if (last_op->opcode == ZEND_FETCH_OBJ_RW) {
-               
                switch (op) {
                        case ZEND_ASSIGN_ADD:
                                opline->opcode = ZEND_ASSIGN_ADD_OBJ;
index 2c0791359c2bc307a8909df337b50b04c79318a9..18e048ad90d992c2f0451144dd3cd06153955dae 100644 (file)
@@ -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);
index ea5f8df57c4b4e28f47cdc75fceb8b1989b35729..9e7f8e5c7b56fe7ef85976a6430bc5dace808ed6 100644 (file)
@@ -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);
index a8f4fbdf40d02fd68e7201db09c89d3915c425cb..df8b928c6b7d7f3163fb18c40ae22307d9086e6a 100644 (file)
@@ -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;
index a1c81ab03fe7ffc3ed962d0a46339a73488ea119..3bc01367516f7d76e149a34f323ba70616a76f2c 100644 (file)
@@ -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;
 }
 
index 16d8bbd274b79f0c06b45ce2d966fc4397e8b1b0..e6cd22a7709d8112a3d942fed2e03bcbf6726cff 100644 (file)
@@ -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);
index 729d0a76b43b698ef860e31c3926ad61cfa2b7b5..0943cf4873421de9fa9dbec87c873e401e3d83b2 100644 (file)
@@ -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;
        }