Changeset 158

Show
Ignore:
Timestamp:
02/15/06 12:24:51 (2 years ago)
Author:
hrak
Message:

* PHP_5_1: Fixes for five failing tests found using the test suite created by Bart

Tests that failed where:

  • ctor_dtor_inheritance (failed because construct, destruct and clone were not properly set)
  • destructor_and_exceptions (failed because inheritance of parent methods was broken, fixed by making sure ea_store doesn't store methods outside scope)
  • inheritance_002 (failed because construct, destruct and clone were not properly set)
  • private_members (failed because construct, destruct and clone were not properly set)
  • type_hinting_003 (failed because array_type_hint introduced in zend_arg_info in PHP-5.1 was ignored)
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • eaccelerator/branches/PHP_5_1/ChangeLog

    r157 r158  
     12006-02-15  Hans Rakers <hans at parse dot nl> 
     2 
     3        * PHP_5_1: Fixes for five failing tests found using the test suite created by Bart 
     4          Tests that failed where: 
     5          -ctor_dtor_inheritance (failed because __construct, __destruct and __clone were not properly set) 
     6          -destructor_and_exceptions (failed because inheritance of parent methods was broken, fixed by making sure ea_store doesn't store methods outside scope) 
     7          -inheritance_002 (failed because __construct, __destruct and __clone were not properly set) 
     8          -private_members (failed because __construct, __destruct and __clone were not properly set) 
     9          -type_hinting_003 (failed because array_type_hint introduced in zend_arg_info in PHP-5.1 was ignored) 
     10 
    1112006-02-14  Bart Vanbrabant <bart.vanbrabant at zoeloelip dot be> 
    212 
    3     * PHP_5_1: Changed cflags to -O2 from -O3 
     13       * PHP_5_1: Changed cflags to -O2 from -O3 
    414 
    5152006-02-07  Hans Rakers <hans at parse dot nl> 
  • eaccelerator/branches/PHP_5_1/ea_restore.c

    r149 r158  
    478478 
    479479        ea_debug_pad(EA_DEBUG TSRMLS_CC); 
    480         ea_debug_printf(EA_DEBUG, "[%d] restore_op_array: %s\n", getpid(), 
    481                                         from->function_name ? from->function_name : "(top)"); 
     480        ea_debug_printf(EA_DEBUG, "[%d] restore_op_array: %s type=%x\n", getpid(), 
     481                                        from->function_name ? from->function_name : "(top)", from->type); 
    482482 
    483483        if (from->type == ZEND_INTERNAL_FUNCTION) { 
     
    599599                        ea_debug_printf(EA_DEBUG, "[%d]                                       can't find\n", getpid()); 
    600600                }                
     601#ifdef ZEND_ENGINE_2 
     602                /* hrak: slight memleak here. dont forget to free the lowercase function name! */ 
     603                if (fname_lc != NULL) { 
     604                        efree(fname_lc); 
     605                } 
     606                /* zend_internal_function also contains return_reference in ZE2 */ 
     607                to->return_reference = from->return_reference; 
     608                /* this gets set by zend_do_inheritance */ 
     609                to->prototype = NULL; 
     610#endif 
    601611                return to; 
    602612        } 
     
    726736                /* inherit parent methods */ 
    727737                to->parent = *parent_ptr; 
     738                to->parent->refcount++; 
    728739                ea_debug_printf(EA_DEBUG, "restore_class_parent: found parent %s..\n", to->parent->name); 
    729740                ea_debug_printf(EA_DEBUG, "restore_class_parent: parent type=%d child type=%d\n", to->parent->type, to->type); 
    730                 zend_do_inheritance(to, to->parent TSRMLS_CC); 
    731                 to->parent->refcount++; 
    732 /*              to->constructor = to->parent->constructor; 
     741                to->constructor = to->parent->constructor; 
    733742                to->destructor = to->parent->destructor; 
    734743                to->clone = to->parent->clone; 
    735               to->__get = to->parent->__get; 
     744/*            to->__get = to->parent->__get; 
    736745                to->__set = to->parent->__set; 
    737746#  ifdef ZEND_ENGINE_2_1 
     
    929938        } 
    930939#endif 
    931         restore_hash(&to->function_table, &from->function_table, 
    932                                  (restore_bucket_t) restore_op_array_ptr TSRMLS_CC); 
    933         to->function_table.pDestructor = ZEND_FUNCTION_DTOR; 
    934  
    935940        if (from->parent != NULL) { 
    936941                restore_class_parent(from->parent, strlen(from->parent), to TSRMLS_CC); 
     
    941946        } 
    942947 
     948        restore_hash(&to->function_table, &from->function_table, 
     949                                 (restore_bucket_t) restore_op_array_ptr TSRMLS_CC); 
     950        to->function_table.pDestructor = ZEND_FUNCTION_DTOR; 
     951 
    943952#ifdef ZEND_ENGINE_2 
    944953        restore_class_methods(to TSRMLS_CC); 
    945954#endif 
     955        if (to->parent) 
     956                zend_do_inheritance(to, to->parent TSRMLS_CC); 
    946957        EAG(class_entry) = old; 
    947958 
  • eaccelerator/branches/PHP_5_1/ea_store.c

    r149 r158  
    541541 
    542542        ea_debug_pad(EA_DEBUG TSRMLS_CC); 
    543         ea_debug_printf(EA_DEBUG, "[%d] store_op_array: %s [scope=%s]\n",  
     543        ea_debug_printf(EA_DEBUG, "[%d] store_op_array: %s [scope=%s type=%x]\n",  
    544544            getpid(), from->function_name ? from->function_name : "(top)", 
    545545#ifdef ZEND_ENGINE_2 
     
    548548                        "NULL" 
    549549#endif 
     550                        , from->type 
    550551                ); 
    551552 
     
    580581                                to->arg_info[i].class_name_len = from->arg_info[i].class_name_len; 
    581582                        } 
     583#  ifdef ZEND_ENGINE_2_1 
     584                        /* php 5.1 introduces this in zend_arg_info for array type hinting */ 
     585                        to->arg_info[i].array_type_hint = from->arg_info[i].array_type_hint; 
     586#  endif 
    582587                        to->arg_info[i].allow_null = from->arg_info[i].allow_null; 
    583588                        to->arg_info[i].pass_by_reference = from->arg_info[i].pass_by_reference; 
     
    620625#endif 
    621626 
    622         if (from->type == ZEND_INTERNAL_FUNCTION) 
    623         return to; 
     627        if (from->type == ZEND_INTERNAL_FUNCTION) { 
     628#ifdef ZEND_ENGINE_2 
     629                /* zend_internal_function also contains return_reference in ZE2 */ 
     630                to->return_reference = from->return_reference; 
     631#endif           
     632                return to; 
     633        } 
    624634     
    625635        to->opcodes = from->opcodes; 
     
    811821        return ZEND_HASH_APPLY_KEEP; 
    812822} 
    813  
    814 #endif 
     823#endif 
     824 
     825/* 
     826 * This function makes sure that functions/methods that are not in the scope of the current 
     827 * class being stored, do not get copied to the function_table hash. This makes sure they 
     828 * get properly inherited on restore by zend_do_inheritance 
     829 * 
     830 * If we dont do this, it will result in broken inheritance, problems with final methods 
     831 * (e.g. "Cannot override final method") and the like. 
     832 */ 
     833static int store_function_inheritance_check(Bucket * p, va_list args) 
     834
     835        zend_class_entry *from = va_arg(args, zend_class_entry*); 
     836        zend_function *zf = p->pData; 
     837         
     838        if (zf->common.scope == from) { 
     839                return ZEND_HASH_APPLY_KEEP; 
     840        } 
     841        return ZEND_HASH_APPLY_REMOVE; 
     842
    815843 
    816844eaccelerator_class_entry *store_class_entry(zend_class_entry * from TSRMLS_DC) 
     
    866894        store_hash(&to->properties_info, &from->properties_info, (store_bucket_t) store_property_info, (check_bucket_t) store_property_access_check, from); 
    867895#  ifdef ZEND_ENGINE_2_1 
     896        ea_debug_printf(EA_DEBUG, "[%d] store_class_entry: from->static_members(%x), from->default_static_members(%x)\n", getpid(), from->static_members, &from->default_static_members); 
    868897        if((from->static_members != NULL) && (from->static_members != &from->default_static_members)) { 
    869898                store_zval_hash(&to->default_static_members, &from->default_static_members); 
     
    891920        store_zval_hash(&to->default_properties, &from->default_properties); 
    892921#endif 
    893         store_hash(&to->function_table, &from->function_table, (store_bucket_t) store_op_array, NULL, NULL); 
     922        store_hash(&to->function_table, &from->function_table, (store_bucket_t) store_op_array, (check_bucket_t) store_function_inheritance_check, from); 
    894923 
    895924#ifdef DEBUG