Diff for /embedaddon/php/Zend/zend_API.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:47:52 version 1.1.1.2, 2012/05/29 12:34:35
Line 33 Line 33
 #endif  #endif
   
 /* these variables are true statics/globals, and have to be mutex'ed on every access */  /* these variables are true statics/globals, and have to be mutex'ed on every access */
 static int module_count=0;  
 ZEND_API HashTable module_registry;  ZEND_API HashTable module_registry;
   
   static zend_module_entry **module_request_startup_handlers;
   static zend_module_entry **module_request_shutdown_handlers;
   static zend_module_entry **module_post_deactivate_handlers;
   
   static zend_class_entry  **class_cleanup_handlers;
   
 /* this function doesn't check for too many parameters */  /* this function doesn't check for too many parameters */
 ZEND_API int zend_get_parameters(int ht, int param_count, ...) /* {{{ */  ZEND_API int zend_get_parameters(int ht, int param_count, ...) /* {{{ */
 {  {
Line 186  ZEND_API int zend_copy_parameters_array(int param_coun Line 191  ZEND_API int zend_copy_parameters_array(int param_coun
   
 ZEND_API void zend_wrong_param_count(TSRMLS_D) /* {{{ */  ZEND_API void zend_wrong_param_count(TSRMLS_D) /* {{{ */
 {  {
        char *space;        const char *space;
        char *class_name = get_active_class_name(&space TSRMLS_CC);        const char *class_name = get_active_class_name(&space TSRMLS_CC);
   
         zend_error(E_WARNING, "Wrong parameter count for %s%s%s()", class_name, space, get_active_function_name(TSRMLS_C));          zend_error(E_WARNING, "Wrong parameter count for %s%s%s()", class_name, space, get_active_function_name(TSRMLS_C));
 }  }
Line 211  ZEND_API char *zend_get_type_by_const(int type) /* {{{ Line 216  ZEND_API char *zend_get_type_by_const(int type) /* {{{
                         return "resource";                          return "resource";
                 case IS_NULL:                  case IS_NULL:
                         return "null";                          return "null";
                   case IS_CALLABLE:
                           return "callable";
                 case IS_ARRAY:                  case IS_ARRAY:
                         return "array";                          return "array";
                 default:                  default:
Line 237  ZEND_API zend_class_entry *zend_get_class_entry(const  Line 244  ZEND_API zend_class_entry *zend_get_class_entry(const 
 /* }}} */  /* }}} */
   
 /* returns 1 if you need to copy result, 0 if it's already a copy */  /* returns 1 if you need to copy result, 0 if it's already a copy */
ZEND_API int zend_get_object_classname(const zval *object, char **class_name, zend_uint *class_name_len TSRMLS_DC) /* {{{ */ZEND_API int zend_get_object_classname(const zval *object, const char **class_name, zend_uint *class_name_len TSRMLS_DC) /* {{{ */
 {  {
         if (Z_OBJ_HT_P(object)->get_class_name == NULL ||          if (Z_OBJ_HT_P(object)->get_class_name == NULL ||
                 Z_OBJ_HT_P(object)->get_class_name(object, class_name, class_name_len, 0 TSRMLS_CC) != SUCCESS) {                  Z_OBJ_HT_P(object)->get_class_name(object, class_name, class_name_len, 0 TSRMLS_CC) != SUCCESS) {
Line 251  ZEND_API int zend_get_object_classname(const zval *obj Line 258  ZEND_API int zend_get_object_classname(const zval *obj
 }  }
 /* }}} */  /* }}} */
   
static int parse_arg_object_to_string(zval **arg TSRMLS_DC) /* {{{ */static int parse_arg_object_to_string(zval **arg, char **p, int *pl, int type TSRMLS_DC) /* {{{ */
 {  {
         if (Z_OBJ_HANDLER_PP(arg, cast_object)) {          if (Z_OBJ_HANDLER_PP(arg, cast_object)) {
                SEPARATE_ZVAL_IF_NOT_REF(arg);                zval *obj;
                if (Z_OBJ_HANDLER_PP(arg, cast_object)(*arg, *arg, IS_STRING TSRMLS_CC) == SUCCESS) {                MAKE_STD_ZVAL(obj);
                 if (Z_OBJ_HANDLER_P(*arg, cast_object)(*arg, obj, type TSRMLS_CC) == SUCCESS) {
                         zval_ptr_dtor(arg);
                         *arg = obj;
                         *pl = Z_STRLEN_PP(arg);
                         *p = Z_STRVAL_PP(arg);
                         return SUCCESS;                          return SUCCESS;
                 }                  }
                   efree(obj);
         }          }
         /* Standard PHP objects */          /* Standard PHP objects */
         if (Z_OBJ_HT_PP(arg) == &std_object_handlers || !Z_OBJ_HANDLER_PP(arg, cast_object)) {          if (Z_OBJ_HT_PP(arg) == &std_object_handlers || !Z_OBJ_HANDLER_PP(arg, cast_object)) {
                 SEPARATE_ZVAL_IF_NOT_REF(arg);                  SEPARATE_ZVAL_IF_NOT_REF(arg);
                if (zend_std_cast_object_tostring(*arg, *arg, IS_STRING TSRMLS_CC) == SUCCESS) {                if (zend_std_cast_object_tostring(*arg, *arg, type TSRMLS_CC) == SUCCESS) {
                         *pl = Z_STRLEN_PP(arg);
                         *p = Z_STRVAL_PP(arg);
                         return SUCCESS;                          return SUCCESS;
                 }                  }
         }          }
Line 277  static int parse_arg_object_to_string(zval **arg TSRML Line 292  static int parse_arg_object_to_string(zval **arg TSRML
                         if (!use_copy) {                          if (!use_copy) {
                                 ZVAL_ZVAL(*arg, z, 1, 1);                                  ZVAL_ZVAL(*arg, z, 1, 1);
                         }                          }
                           *pl = Z_STRLEN_PP(arg);
                           *p = Z_STRVAL_PP(arg);
                         return SUCCESS;                          return SUCCESS;
                 }                  }
                 zval_ptr_dtor(&z);                  zval_ptr_dtor(&z);
Line 285  static int parse_arg_object_to_string(zval **arg TSRML Line 302  static int parse_arg_object_to_string(zval **arg TSRML
 }  }
 /* }}} */  /* }}} */
   
static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **spec, char **error, int *severity TSRMLS_DC) /* {{{ */static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, const char **spec, char **error, int *severity TSRMLS_DC) /* {{{ */
 {  {
        char *spec_walk = *spec;        const char *spec_walk = *spec;
         char c = *spec_walk++;          char c = *spec_walk++;
         int return_null = 0;          int return_null = 0;
   
Line 394  static char *zend_parse_arg_impl(int arg_num, zval **a Line 411  static char *zend_parse_arg_impl(int arg_num, zval **a
                         }                          }
                         break;                          break;
   
                   case 'p':
                 case 's':                  case 's':
                         {                          {
                                 char **p = va_arg(*va, char **);                                  char **p = va_arg(*va, char **);
Line 420  static char *zend_parse_arg_impl(int arg_num, zval **a Line 438  static char *zend_parse_arg_impl(int arg_num, zval **a
                                                 }                                                  }
                                                 *p = Z_STRVAL_PP(arg);                                                  *p = Z_STRVAL_PP(arg);
                                                 *pl = Z_STRLEN_PP(arg);                                                  *pl = Z_STRLEN_PP(arg);
                                                   if (c == 'p' && CHECK_ZVAL_NULL_PATH(*arg)) {
                                                           return "a valid path";
                                                   }
                                                 break;                                                  break;
   
                                         case IS_OBJECT:                                          case IS_OBJECT:
                                                   if (parse_arg_object_to_string(arg, p, pl, IS_STRING TSRMLS_CC) == SUCCESS) {
                                                           if (c == 'p' && CHECK_ZVAL_NULL_PATH(*arg)) {
                                                                   return "a valid path";
                                                           }
                                                           break;
                                                   }
   
                                         case IS_ARRAY:                                          case IS_ARRAY:
                                         case IS_RESOURCE:                                          case IS_RESOURCE:
                                         default:                                          default:
                                                return "string";                                                return c == 's' ? "string" : "a valid path";
                                 }                                  }
                         }                          }
                         break;                          break;
Line 638  static char *zend_parse_arg_impl(int arg_num, zval **a Line 666  static char *zend_parse_arg_impl(int arg_num, zval **a
 }  }
 /* }}} */  /* }}} */
   
static int zend_parse_arg(int arg_num, zval **arg, va_list *va, char **spec, int quiet TSRMLS_DC) /* {{{ */static int zend_parse_arg(int arg_num, zval **arg, va_list *va, const char **spec, int quiet TSRMLS_DC) /* {{{ */
 {  {
        char *expected_type = NULL, *error = NULL;        const char *expected_type = NULL;
         char *error = NULL;
         int severity = E_WARNING;          int severity = E_WARNING;
   
         expected_type = zend_parse_arg_impl(arg_num, arg, va, spec, &error, &severity TSRMLS_CC);          expected_type = zend_parse_arg_impl(arg_num, arg, va, spec, &error, &severity TSRMLS_CC);
         if (expected_type) {          if (expected_type) {
                 if (!quiet && (*expected_type || error)) {                  if (!quiet && (*expected_type || error)) {
                        char *space;                        const char *space;
                        char *class_name = get_active_class_name(&space TSRMLS_CC);                        const char *class_name = get_active_class_name(&space TSRMLS_CC);
   
                         if (error) {                          if (error) {
                                 zend_error(severity, "%s%s%s() expects parameter %d %s",                                  zend_error(severity, "%s%s%s() expects parameter %d %s",
Line 668  static int zend_parse_arg(int arg_num, zval **arg, va_ Line 697  static int zend_parse_arg(int arg_num, zval **arg, va_
 }  }
 /* }}} */  /* }}} */
   
static int zend_parse_va_args(int num_args, char *type_spec, va_list *va, int flags TSRMLS_DC) /* {{{ */static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va, int flags TSRMLS_DC) /* {{{ */
 {  {
        char *spec_walk;        const  char *spec_walk;
         int c, i;          int c, i;
         int min_num_args = -1;          int min_num_args = -1;
         int max_num_args = 0;          int max_num_args = 0;
         int post_varargs = 0;          int post_varargs = 0;
         zval **arg;          zval **arg;
        int arg_count = (int)(zend_uintptr_t) *(zend_vm_stack_top(TSRMLS_C) - 1);        int arg_count;
         int quiet = flags & ZEND_PARSE_PARAMS_QUIET;          int quiet = flags & ZEND_PARSE_PARAMS_QUIET;
         zend_bool have_varargs = 0;          zend_bool have_varargs = 0;
         zval ****varargs = NULL;          zval ****varargs = NULL;
Line 685  static int zend_parse_va_args(int num_args, char *type Line 714  static int zend_parse_va_args(int num_args, char *type
         for (spec_walk = type_spec; *spec_walk; spec_walk++) {          for (spec_walk = type_spec; *spec_walk; spec_walk++) {
                 c = *spec_walk;                  c = *spec_walk;
                 switch (c) {                  switch (c) {
                         case 's':  
                                 if (max_num_args < arg_count) {  
                                         arg = (zval **) (zend_vm_stack_top(TSRMLS_C) - 1 - (arg_count - max_num_args));  
                                         if (Z_TYPE_PP(arg) == IS_OBJECT) {  
                                                 parse_arg_object_to_string(arg TSRMLS_CC);  
                                         }  
                                 }  
                                 /* break missing intentionally */  
                         case 'l': case 'd':                          case 'l': case 'd':
                        case 'H': case 'b':                        case 's': case 'b':
                         case 'r': case 'a':                          case 'r': case 'a':
                         case 'o': case 'O':                          case 'o': case 'O':
                         case 'z': case 'Z':                          case 'z': case 'Z':
                         case 'C': case 'h':                          case 'C': case 'h':
                         case 'f': case 'A':                          case 'f': case 'A':
                           case 'H': case 'p':
                                 max_num_args++;                                  max_num_args++;
                                 break;                                  break;
   
Line 717  static int zend_parse_va_args(int num_args, char *type Line 739  static int zend_parse_va_args(int num_args, char *type
                                 if (have_varargs) {                                  if (have_varargs) {
                                         if (!quiet) {                                          if (!quiet) {
                                                 zend_function *active_function = EG(current_execute_data)->function_state.function;                                                  zend_function *active_function = EG(current_execute_data)->function_state.function;
                                                char *class_name = active_function->common.scope ? active_function->common.scope->name : "";                                                const char *class_name = active_function->common.scope ? active_function->common.scope->name : "";
                                                 zend_error(E_WARNING, "%s%s%s(): only one varargs specifier (* or +) is permitted",                                                  zend_error(E_WARNING, "%s%s%s(): only one varargs specifier (* or +) is permitted",
                                                                 class_name,                                                                  class_name,
                                                                 class_name[0] ? "::" : "",                                                                  class_name[0] ? "::" : "",
Line 737  static int zend_parse_va_args(int num_args, char *type Line 759  static int zend_parse_va_args(int num_args, char *type
                         default:                          default:
                                 if (!quiet) {                                  if (!quiet) {
                                         zend_function *active_function = EG(current_execute_data)->function_state.function;                                          zend_function *active_function = EG(current_execute_data)->function_state.function;
                                        char *class_name = active_function->common.scope ? active_function->common.scope->name : "";                                        const char *class_name = active_function->common.scope ? active_function->common.scope->name : "";
                                         zend_error(E_WARNING, "%s%s%s(): bad type specifier while parsing parameters",                                          zend_error(E_WARNING, "%s%s%s(): bad type specifier while parsing parameters",
                                                         class_name,                                                          class_name,
                                                         class_name[0] ? "::" : "",                                                          class_name[0] ? "::" : "",
Line 760  static int zend_parse_va_args(int num_args, char *type Line 782  static int zend_parse_va_args(int num_args, char *type
         if (num_args < min_num_args || (num_args > max_num_args && max_num_args > 0)) {          if (num_args < min_num_args || (num_args > max_num_args && max_num_args > 0)) {
                 if (!quiet) {                  if (!quiet) {
                         zend_function *active_function = EG(current_execute_data)->function_state.function;                          zend_function *active_function = EG(current_execute_data)->function_state.function;
                        char *class_name = active_function->common.scope ? active_function->common.scope->name : "";                        const char *class_name = active_function->common.scope ? active_function->common.scope->name : "";
                         zend_error(E_WARNING, "%s%s%s() expects %s %d parameter%s, %d given",                          zend_error(E_WARNING, "%s%s%s() expects %s %d parameter%s, %d given",
                                         class_name,                                          class_name,
                                         class_name[0] ? "::" : "",                                          class_name[0] ? "::" : "",
Line 773  static int zend_parse_va_args(int num_args, char *type Line 795  static int zend_parse_va_args(int num_args, char *type
                 return FAILURE;                  return FAILURE;
         }          }
   
           arg_count = (int)(zend_uintptr_t) *(zend_vm_stack_top(TSRMLS_C) - 1);
   
         if (num_args > arg_count) {          if (num_args > arg_count) {
                 zend_error(E_WARNING, "%s(): could not obtain parameters for parsing",                  zend_error(E_WARNING, "%s(): could not obtain parameters for parsing",
                         get_active_function_name(TSRMLS_C));                          get_active_function_name(TSRMLS_C));
Line 836  static int zend_parse_va_args(int num_args, char *type Line 860  static int zend_parse_va_args(int num_args, char *type
         int __num_args = (num_args); \          int __num_args = (num_args); \
         \          \
         if (0 == (type_spec)[0] && 0 != __num_args && !(quiet)) { \          if (0 == (type_spec)[0] && 0 != __num_args && !(quiet)) { \
                char *__space; \                const char *__space; \
                char * __class_name = get_active_class_name(&__space TSRMLS_CC); \                const char * __class_name = get_active_class_name(&__space TSRMLS_CC); \
                 zend_error(E_WARNING, "%s%s%s() expects exactly 0 parameters, %d given", \                  zend_error(E_WARNING, "%s%s%s() expects exactly 0 parameters, %d given", \
                         __class_name, __space, \                          __class_name, __space, \
                         get_active_function_name(TSRMLS_C), __num_args); \                          get_active_function_name(TSRMLS_C), __num_args); \
Line 845  static int zend_parse_va_args(int num_args, char *type Line 869  static int zend_parse_va_args(int num_args, char *type
         }\          }\
 }  }
   
ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char *type_spec, ...) /* {{{ */ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, const char *type_spec, ...) /* {{{ */
 {  {
         va_list va;          va_list va;
         int retval;          int retval;
Line 860  ZEND_API int zend_parse_parameters_ex(int flags, int n Line 884  ZEND_API int zend_parse_parameters_ex(int flags, int n
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, char *type_spec, ...) /* {{{ */ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, const char *type_spec, ...) /* {{{ */
 {  {
         va_list va;          va_list va;
         int retval;          int retval;
Line 875  ZEND_API int zend_parse_parameters(int num_args TSRMLS Line 899  ZEND_API int zend_parse_parameters(int num_args TSRMLS
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...) /* {{{ */ZEND_API int zend_parse_method_parameters(int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...) /* {{{ */
 {  {
         va_list va;          va_list va;
         int retval;          int retval;
        char *p = type_spec;        const char *p = type_spec;
         zval **object;          zval **object;
         zend_class_entry *ce;          zend_class_entry *ce;
   
Line 911  ZEND_API int zend_parse_method_parameters(int num_args Line 935  ZEND_API int zend_parse_method_parameters(int num_args
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, char *type_spec, ...) /* {{{ */ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args TSRMLS_DC, zval *this_ptr, const char *type_spec, ...) /* {{{ */
 {  {
         va_list va;          va_list va;
         int retval;          int retval;
        char *p = type_spec;        const char *p = type_spec;
         zval **object;          zval **object;
         zend_class_entry *ce;          zend_class_entry *ce;
         int quiet = flags & ZEND_PARSE_PARAMS_QUIET;          int quiet = flags & ZEND_PARSE_PARAMS_QUIET;
Line 973  static int zend_merge_property(zval **value TSRMLS_DC, Line 997  static int zend_merge_property(zval **value TSRMLS_DC,
   
                 MAKE_STD_ZVAL(member);                  MAKE_STD_ZVAL(member);
                 ZVAL_STRINGL(member, hash_key->arKey, hash_key->nKeyLength-1, 1);                  ZVAL_STRINGL(member, hash_key->arKey, hash_key->nKeyLength-1, 1);
                obj_ht->write_property(obj, member, *value TSRMLS_CC);                obj_ht->write_property(obj, member, *value, 0 TSRMLS_CC);
                 zval_ptr_dtor(&member);                  zval_ptr_dtor(&member);
         }          }
         return ZEND_HASH_APPLY_KEEP;          return ZEND_HASH_APPLY_KEEP;
Line 984  static int zend_merge_property(zval **value TSRMLS_DC, Line 1008  static int zend_merge_property(zval **value TSRMLS_DC,
  * because it may call __set from the uninitialized object otherwise. */   * because it may call __set from the uninitialized object otherwise. */
 ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destroy_ht TSRMLS_DC) /* {{{ */  ZEND_API void zend_merge_properties(zval *obj, HashTable *properties, int destroy_ht TSRMLS_DC) /* {{{ */
 {  {
        zend_object_handlers *obj_ht = Z_OBJ_HT_P(obj);        const zend_object_handlers *obj_ht = Z_OBJ_HT_P(obj);
         zend_class_entry *old_scope = EG(scope);          zend_class_entry *old_scope = EG(scope);
   
         EG(scope) = Z_OBJCE_P(obj);          EG(scope) = Z_OBJCE_P(obj);
Line 1000  ZEND_API void zend_merge_properties(zval *obj, HashTab Line 1024  ZEND_API void zend_merge_properties(zval *obj, HashTab
   
 ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC) /* {{{ */  ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
 {  {
        if (!class_type->constants_updated || !CE_STATIC_MEMBERS(class_type)) {        if ((class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED) == 0 || (!CE_STATIC_MEMBERS(class_type) && class_type->default_static_members_count)) {
                 zend_class_entry **scope = EG(in_execution)?&EG(scope):&CG(active_class_entry);                  zend_class_entry **scope = EG(in_execution)?&EG(scope):&CG(active_class_entry);
                 zend_class_entry *old_scope = *scope;                  zend_class_entry *old_scope = *scope;
                   int i;
   
                 *scope = class_type;                  *scope = class_type;
                 zend_hash_apply_with_argument(&class_type->constants_table, (apply_func_arg_t) zval_update_constant, (void*)1 TSRMLS_CC);                  zend_hash_apply_with_argument(&class_type->constants_table, (apply_func_arg_t) zval_update_constant, (void*)1 TSRMLS_CC);
                 zend_hash_apply_with_argument(&class_type->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);  
   
                if (!CE_STATIC_MEMBERS(class_type)) {                for (i = 0; i < class_type->default_properties_count; i++) {
                        HashPosition pos;                        if (class_type->default_properties_table[i]) {
                                 zval_update_constant(&class_type->default_properties_table[i], (void**)1 TSRMLS_CC);
                         }
                 }
 
                 if (!CE_STATIC_MEMBERS(class_type) && class_type->default_static_members_count) {
                         zval **p;                          zval **p;
   
                         if (class_type->parent) {                          if (class_type->parent) {
                                 zend_update_class_constants(class_type->parent TSRMLS_CC);                                  zend_update_class_constants(class_type->parent TSRMLS_CC);
                         }                          }
 #if ZTS  #if ZTS
                        ALLOC_HASHTABLE(CG(static_members)[(zend_intptr_t)(class_type->static_members)]);                        CG(static_members_table)[(zend_intptr_t)(class_type->static_members_table)] = emalloc(sizeof(zval*) * class_type->default_static_members_count);
 #else  #else
                        ALLOC_HASHTABLE(class_type->static_members);                        class_type->static_members_table = emalloc(sizeof(zval*) * class_type->default_static_members_count);
 #endif  #endif
                        zend_hash_init(CE_STATIC_MEMBERS(class_type), zend_hash_num_elements(&class_type->default_static_members), NULL, ZVAL_PTR_DTOR, 0);                        for (i = 0; i < class_type->default_static_members_count; i++) {
                                p = &class_type->default_static_members_table[i];
                        zend_hash_internal_pointer_reset_ex(&class_type->default_static_members, &pos); 
                        while (zend_hash_get_current_data_ex(&class_type->default_static_members, (void**)&p, &pos) == SUCCESS) { 
                                char *str_index; 
                                uint str_length; 
                                ulong num_index; 
                                zval **q; 
 
                                zend_hash_get_current_key_ex(&class_type->default_static_members, &str_index, &str_length, &num_index, 0, &pos); 
                                 if (Z_ISREF_PP(p) &&                                  if (Z_ISREF_PP(p) &&
                                         class_type->parent &&                                          class_type->parent &&
                                        zend_hash_find(&class_type->parent->default_static_members, str_index, str_length, (void**)&q) == SUCCESS &&                                        i < class_type->parent->default_static_members_count &&
                                        *p == *q &&                                        *p == class_type->parent->default_static_members_table[i] &&
                                        zend_hash_find(CE_STATIC_MEMBERS(class_type->parent), str_index, str_length, (void**)&q) == SUCCESS                                        CE_STATIC_MEMBERS(class_type->parent)[i]
                                 ) {                                  ) {
                                        Z_ADDREF_PP(q);                                        zval *q = CE_STATIC_MEMBERS(class_type->parent)[i];
                                        Z_SET_ISREF_PP(q);
                                        zend_hash_add(CE_STATIC_MEMBERS(class_type), str_index, str_length, (void**)q, sizeof(zval*), NULL);                                        Z_ADDREF_P(q);
                                         Z_SET_ISREF_P(q);
                                         CE_STATIC_MEMBERS(class_type)[i] = q;
                                 } else {                                  } else {
                                         zval *r;                                          zval *r;
   
Line 1046  ZEND_API void zend_update_class_constants(zend_class_e Line 1069  ZEND_API void zend_update_class_constants(zend_class_e
                                         *r = **p;                                          *r = **p;
                                         INIT_PZVAL(r);                                          INIT_PZVAL(r);
                                         zval_copy_ctor(r);                                          zval_copy_ctor(r);
                                        zend_hash_add(CE_STATIC_MEMBERS(class_type), str_index, str_length, (void**)&r, sizeof(zval*), NULL);                                        CE_STATIC_MEMBERS(class_type)[i] = r;
                                 }                                  }
                                 zend_hash_move_forward_ex(&class_type->default_static_members, &pos);  
                         }                          }
                 }                  }
                 zend_hash_apply_with_argument(CE_STATIC_MEMBERS(class_type), (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);  
   
                   for (i = 0; i < class_type->default_static_members_count; i++) {
                           zval_update_constant(&CE_STATIC_MEMBERS(class_type)[i], (void**)1 TSRMLS_CC);
                   }
   
                 *scope = old_scope;                  *scope = old_scope;
                class_type->constants_updated = 1;                class_type->ce_flags |= ZEND_ACC_CONSTANTS_UPDATED;
         }          }
 }  }
 /* }}} */  /* }}} */
   
   ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type) /* {{{ */
   {
           int i;
   
           if (class_type->default_properties_count) {
                   object->properties_table = emalloc(sizeof(zval*) * class_type->default_properties_count);
                   for (i = 0; i < class_type->default_properties_count; i++) {
                           object->properties_table[i] = class_type->default_properties_table[i];
                           if (class_type->default_properties_table[i]) {
   #if ZTS
                                   ALLOC_ZVAL( object->properties_table[i]);
                                   MAKE_COPY_ZVAL(&class_type->default_properties_table[i], object->properties_table[i]);
   #else
                                   Z_ADDREF_P(object->properties_table[i]);
   #endif
                           }
                   }
                   object->properties = NULL;
           }
   }
   /* }}} */
   
 /* This function requires 'properties' to contain all props declared in the  /* This function requires 'properties' to contain all props declared in the
  * class and all props being public. If only a subset is given or the class   * class and all props being public. If only a subset is given or the class
  * has protected members then you need to merge the properties seperately by   * has protected members then you need to merge the properties seperately by
  * calling zend_merge_properties(). */   * calling zend_merge_properties(). */
 ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties ZEND_FILE_LINE_DC TSRMLS_DC) /* {{{ */  ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties ZEND_FILE_LINE_DC TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;  
         zend_object *object;          zend_object *object;
   
         if (class_type->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {          if (class_type->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
                char *what = class_type->ce_flags & ZEND_ACC_INTERFACE ? "interface" : "abstract class";                char *what =   (class_type->ce_flags & ZEND_ACC_INTERFACE)                ? "interface"
                                          :((class_type->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) ? "trait"
                                          :                                                              "abstract class";
                 zend_error(E_ERROR, "Cannot instantiate %s %s", what, class_type->name);                  zend_error(E_ERROR, "Cannot instantiate %s %s", what, class_type->name);
         }          }
   
Line 1080  ZEND_API int _object_and_properties_init(zval *arg, ze Line 1128  ZEND_API int _object_and_properties_init(zval *arg, ze
                 Z_OBJVAL_P(arg) = zend_objects_new(&object, class_type TSRMLS_CC);                  Z_OBJVAL_P(arg) = zend_objects_new(&object, class_type TSRMLS_CC);
                 if (properties) {                  if (properties) {
                         object->properties = properties;                          object->properties = properties;
                           object->properties_table = NULL;
                 } else {                  } else {
                        ALLOC_HASHTABLE_REL(object->properties);                        object_properties_init(object, class_type);
                        zend_hash_init(object->properties, zend_hash_num_elements(&class_type->default_properties), NULL, ZVAL_PTR_DTOR, 0); 
                        zend_hash_copy(object->properties, &class_type->default_properties, zval_copy_property_ctor(class_type), (void *) &tmp, sizeof(zval *)); 
                 }                  }
         } else {          } else {
                 Z_OBJVAL_P(arg) = class_type->create_object(class_type TSRMLS_CC);                  Z_OBJVAL_P(arg) = class_type->create_object(class_type TSRMLS_CC);
Line 1437  ZEND_API int add_property_long_ex(zval *arg, const cha Line 1484  ZEND_API int add_property_long_ex(zval *arg, const cha
         MAKE_STD_ZVAL(z_key);          MAKE_STD_ZVAL(z_key);
         ZVAL_STRINGL(z_key, key, key_len-1, 1);          ZVAL_STRINGL(z_key, key, key_len-1, 1);
   
        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp TSRMLS_CC);        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp, 0 TSRMLS_CC);
         zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */          zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
         zval_ptr_dtor(&z_key);          zval_ptr_dtor(&z_key);
         return SUCCESS;          return SUCCESS;
Line 1455  ZEND_API int add_property_bool_ex(zval *arg, const cha Line 1502  ZEND_API int add_property_bool_ex(zval *arg, const cha
         MAKE_STD_ZVAL(z_key);          MAKE_STD_ZVAL(z_key);
         ZVAL_STRINGL(z_key, key, key_len-1, 1);          ZVAL_STRINGL(z_key, key, key_len-1, 1);
   
        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp TSRMLS_CC);        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp, 0 TSRMLS_CC);
         zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */          zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
         zval_ptr_dtor(&z_key);          zval_ptr_dtor(&z_key);
         return SUCCESS;          return SUCCESS;
Line 1473  ZEND_API int add_property_null_ex(zval *arg, const cha Line 1520  ZEND_API int add_property_null_ex(zval *arg, const cha
         MAKE_STD_ZVAL(z_key);          MAKE_STD_ZVAL(z_key);
         ZVAL_STRINGL(z_key, key, key_len-1, 1);          ZVAL_STRINGL(z_key, key, key_len-1, 1);
   
        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp TSRMLS_CC);        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp, 0 TSRMLS_CC);
         zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */          zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
         zval_ptr_dtor(&z_key);          zval_ptr_dtor(&z_key);
         return SUCCESS;          return SUCCESS;
Line 1491  ZEND_API int add_property_resource_ex(zval *arg, const Line 1538  ZEND_API int add_property_resource_ex(zval *arg, const
         MAKE_STD_ZVAL(z_key);          MAKE_STD_ZVAL(z_key);
         ZVAL_STRINGL(z_key, key, key_len-1, 1);          ZVAL_STRINGL(z_key, key, key_len-1, 1);
   
        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp TSRMLS_CC);        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp, 0 TSRMLS_CC);
         zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */          zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
         zval_ptr_dtor(&z_key);          zval_ptr_dtor(&z_key);
         return SUCCESS;          return SUCCESS;
Line 1509  ZEND_API int add_property_double_ex(zval *arg, const c Line 1556  ZEND_API int add_property_double_ex(zval *arg, const c
         MAKE_STD_ZVAL(z_key);          MAKE_STD_ZVAL(z_key);
         ZVAL_STRINGL(z_key, key, key_len-1, 1);          ZVAL_STRINGL(z_key, key, key_len-1, 1);
   
        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp TSRMLS_CC);        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp, 0 TSRMLS_CC);
         zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */          zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
         zval_ptr_dtor(&z_key);          zval_ptr_dtor(&z_key);
         return SUCCESS;          return SUCCESS;
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int add_property_string_ex(zval *arg, const char *key, uint key_len, char *str, int duplicate TSRMLS_DC) /* {{{ */ZEND_API int add_property_string_ex(zval *arg, const char *key, uint key_len, const char *str, int duplicate TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
         zval *z_key;          zval *z_key;
Line 1527  ZEND_API int add_property_string_ex(zval *arg, const c Line 1574  ZEND_API int add_property_string_ex(zval *arg, const c
         MAKE_STD_ZVAL(z_key);          MAKE_STD_ZVAL(z_key);
         ZVAL_STRINGL(z_key, key, key_len-1, 1);          ZVAL_STRINGL(z_key, key, key_len-1, 1);
   
        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp TSRMLS_CC);        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp, 0 TSRMLS_CC);
         zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */          zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
         zval_ptr_dtor(&z_key);          zval_ptr_dtor(&z_key);
         return SUCCESS;          return SUCCESS;
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, char *str, uint length, int duplicate TSRMLS_DC) /* {{{ */ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, const char *str, uint length, int duplicate TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
         zval *z_key;          zval *z_key;
Line 1545  ZEND_API int add_property_stringl_ex(zval *arg, const  Line 1592  ZEND_API int add_property_stringl_ex(zval *arg, const 
         MAKE_STD_ZVAL(z_key);          MAKE_STD_ZVAL(z_key);
         ZVAL_STRINGL(z_key, key, key_len-1, 1);          ZVAL_STRINGL(z_key, key, key_len-1, 1);
   
        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp TSRMLS_CC);        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp, 0 TSRMLS_CC);
         zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */          zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
         zval_ptr_dtor(&z_key);          zval_ptr_dtor(&z_key);
         return SUCCESS;          return SUCCESS;
Line 1559  ZEND_API int add_property_zval_ex(zval *arg, const cha Line 1606  ZEND_API int add_property_zval_ex(zval *arg, const cha
         MAKE_STD_ZVAL(z_key);          MAKE_STD_ZVAL(z_key);
         ZVAL_STRINGL(z_key, key, key_len-1, 1);          ZVAL_STRINGL(z_key, key, key_len-1, 1);
   
        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, value TSRMLS_CC);        Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, value, 0 TSRMLS_CC);
         zval_ptr_dtor(&z_key);          zval_ptr_dtor(&z_key);
         return SUCCESS;          return SUCCESS;
 }  }
Line 1657  try_again: Line 1704  try_again:
 }  }
 /* }}} */  /* }}} */
   
   ZEND_API void zend_collect_module_handlers(TSRMLS_D) /* {{{ */
   {
           HashPosition pos;
           zend_module_entry *module;
           int startup_count = 0;
           int shutdown_count = 0;
           int post_deactivate_count = 0;
           zend_class_entry **pce;
           int class_count = 0;
   
           /* Collect extensions with request startup/shutdown handlers */
           for (zend_hash_internal_pointer_reset_ex(&module_registry, &pos);
                zend_hash_get_current_data_ex(&module_registry, (void *) &module, &pos) == SUCCESS;
                zend_hash_move_forward_ex(&module_registry, &pos)) {
                   if (module->request_startup_func) {
                           startup_count++;
                   }
                   if (module->request_shutdown_func) {
                           shutdown_count++;
                   }
                   if (module->post_deactivate_func) {
                           post_deactivate_count++;
                   }
           }
           module_request_startup_handlers = (zend_module_entry**)malloc(
               sizeof(zend_module_entry*) *
                   (startup_count + 1 +
                    shutdown_count + 1 +
                    post_deactivate_count + 1));
           module_request_startup_handlers[startup_count] = NULL;
           module_request_shutdown_handlers = module_request_startup_handlers + startup_count + 1;
           module_request_shutdown_handlers[shutdown_count] = NULL;
           module_post_deactivate_handlers = module_request_shutdown_handlers + shutdown_count + 1;
           module_post_deactivate_handlers[post_deactivate_count] = NULL;
           startup_count = 0;
           
           for (zend_hash_internal_pointer_reset_ex(&module_registry, &pos);
                zend_hash_get_current_data_ex(&module_registry, (void *) &module, &pos) == SUCCESS;
                zend_hash_move_forward_ex(&module_registry, &pos)) {
                   if (module->request_startup_func) {
                           module_request_startup_handlers[startup_count++] = module;
                   }
                   if (module->request_shutdown_func) {
                           module_request_shutdown_handlers[--shutdown_count] = module;
                   }
                   if (module->post_deactivate_func) {
                           module_post_deactivate_handlers[--post_deactivate_count] = module;
                   }
           }
   
           /* Collect internal classes with static members */
           for (zend_hash_internal_pointer_reset_ex(CG(class_table), &pos);
                zend_hash_get_current_data_ex(CG(class_table), (void *) &pce, &pos) == SUCCESS;
                zend_hash_move_forward_ex(CG(class_table), &pos)) {
                   if ((*pce)->type == ZEND_INTERNAL_CLASS &&
                       (*pce)->default_static_members_count > 0) {
                       class_count++;
                   }
           }
   
           class_cleanup_handlers = (zend_class_entry**)malloc(
                   sizeof(zend_class_entry*) *
                   (class_count + 1));
           class_cleanup_handlers[class_count] = NULL;
   
           if (class_count) {
                   for (zend_hash_internal_pointer_reset_ex(CG(class_table), &pos);
                        zend_hash_get_current_data_ex(CG(class_table), (void *) &pce, &pos) == SUCCESS;
                    zend_hash_move_forward_ex(CG(class_table), &pos)) {
                           if ((*pce)->type == ZEND_INTERNAL_CLASS &&
                               (*pce)->default_static_members_count > 0) {
                               class_cleanup_handlers[--class_count] = *pce;
                           }
                   }
           }
   }
   /* }}} */
   
 ZEND_API int zend_startup_modules(TSRMLS_D) /* {{{ */  ZEND_API int zend_startup_modules(TSRMLS_D) /* {{{ */
 {  {
         zend_hash_sort(&module_registry, zend_sort_modules, NULL, 0 TSRMLS_CC);          zend_hash_sort(&module_registry, zend_sort_modules, NULL, 0 TSRMLS_CC);
Line 1665  ZEND_API int zend_startup_modules(TSRMLS_D) /* {{{ */ Line 1790  ZEND_API int zend_startup_modules(TSRMLS_D) /* {{{ */
 }  }
 /* }}} */  /* }}} */
   
   ZEND_API void zend_destroy_modules(void) /* {{{ */
   {
           free(class_cleanup_handlers);
           free(module_request_startup_handlers);
           zend_hash_graceful_reverse_destroy(&module_registry);
   }
   /* }}} */
   
 ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module TSRMLS_DC) /* {{{ */  ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module TSRMLS_DC) /* {{{ */
 {  {
         int name_len;          int name_len;
Line 1798  ZEND_API int zend_register_functions(zend_class_entry  Line 1931  ZEND_API int zend_register_functions(zend_class_entry 
         const zend_function_entry *ptr = functions;          const zend_function_entry *ptr = functions;
         zend_function function, *reg_function;          zend_function function, *reg_function;
         zend_internal_function *internal_function = (zend_internal_function *)&function;          zend_internal_function *internal_function = (zend_internal_function *)&function;
        int count=0, unload=0;        int count=0, unload=0, result=0;
         HashTable *target_function_table = function_table;          HashTable *target_function_table = function_table;
         int error_type;          int error_type;
         zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__callstatic = NULL, *__tostring = NULL;          zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__callstatic = NULL, *__tostring = NULL;
        char *lowercase_name;        const char *lowercase_name;
         int fname_len;          int fname_len;
        char *lc_class_name = NULL;        const char *lc_class_name = NULL;
         int class_name_len = 0;          int class_name_len = 0;
   
         if (type==MODULE_PERSISTENT) {          if (type==MODULE_PERSISTENT) {
Line 1835  ZEND_API int zend_register_functions(zend_class_entry  Line 1968  ZEND_API int zend_register_functions(zend_class_entry 
                 internal_function->function_name = (char*)ptr->fname;                  internal_function->function_name = (char*)ptr->fname;
                 internal_function->scope = scope;                  internal_function->scope = scope;
                 internal_function->prototype = NULL;                  internal_function->prototype = NULL;
                 if (ptr->arg_info) {  
                         internal_function->arg_info = (zend_arg_info*)ptr->arg_info+1;  
                         internal_function->num_args = ptr->num_args;  
                         /* Currently you cannot denote that the function can accept less arguments than num_args */  
                         if (ptr->arg_info[0].required_num_args == -1) {  
                                 internal_function->required_num_args = ptr->num_args;  
                         } else {  
                                 internal_function->required_num_args = ptr->arg_info[0].required_num_args;  
                         }  
                         internal_function->pass_rest_by_reference = ptr->arg_info[0].pass_by_reference;  
                         internal_function->return_reference = ptr->arg_info[0].return_reference;  
                 } else {  
                         internal_function->arg_info = NULL;  
                         internal_function->num_args = 0;  
                         internal_function->required_num_args = 0;  
                         internal_function->pass_rest_by_reference = 0;  
                         internal_function->return_reference = 0;  
                 }  
                 if (ptr->flags) {                  if (ptr->flags) {
                         if (!(ptr->flags & ZEND_ACC_PPP_MASK)) {                          if (!(ptr->flags & ZEND_ACC_PPP_MASK)) {
                                 if (ptr->flags != ZEND_ACC_DEPRECATED || scope) {                                  if (ptr->flags != ZEND_ACC_DEPRECATED || scope) {
Line 1865  ZEND_API int zend_register_functions(zend_class_entry  Line 1980  ZEND_API int zend_register_functions(zend_class_entry 
                 } else {                  } else {
                         internal_function->fn_flags = ZEND_ACC_PUBLIC;                          internal_function->fn_flags = ZEND_ACC_PUBLIC;
                 }                  }
                   if (ptr->arg_info) {
                           zend_internal_function_info *info = (zend_internal_function_info*)ptr->arg_info;
                           
                           internal_function->arg_info = (zend_arg_info*)ptr->arg_info+1;
                           internal_function->num_args = ptr->num_args;
                           /* Currently you cannot denote that the function can accept less arguments than num_args */
                           if (info->required_num_args == -1) {
                                   internal_function->required_num_args = ptr->num_args;
                           } else {
                                   internal_function->required_num_args = info->required_num_args;
                           }
                           if (info->pass_rest_by_reference) {
                                   if (info->pass_rest_by_reference == ZEND_SEND_PREFER_REF) {
                                           internal_function->fn_flags |= ZEND_ACC_PASS_REST_PREFER_REF;
                                   } else {
                                           internal_function->fn_flags |= ZEND_ACC_PASS_REST_BY_REFERENCE;
                                   }
                           }
                           if (info->return_reference) {
                                   internal_function->fn_flags |= ZEND_ACC_RETURN_REFERENCE;
                           }
                   } else {
                           internal_function->arg_info = NULL;
                           internal_function->num_args = 0;
                           internal_function->required_num_args = 0;
                   }
                 if (ptr->flags & ZEND_ACC_ABSTRACT) {                  if (ptr->flags & ZEND_ACC_ABSTRACT) {
                         if (scope) {                          if (scope) {
                                 /* This is a class that must be abstract itself. Here we set the check info. */                                  /* This is a class that must be abstract itself. Here we set the check info. */
Line 1881  ZEND_API int zend_register_functions(zend_class_entry  Line 2022  ZEND_API int zend_register_functions(zend_class_entry 
                         }                          }
                 } else {                  } else {
                         if (scope && (scope->ce_flags & ZEND_ACC_INTERFACE)) {                          if (scope && (scope->ce_flags & ZEND_ACC_INTERFACE)) {
                                efree(lc_class_name);                                efree((char*)lc_class_name);
                                 zend_error(error_type, "Interface %s cannot contain non abstract method %s()", scope->name, ptr->fname);                                  zend_error(error_type, "Interface %s cannot contain non abstract method %s()", scope->name, ptr->fname);
                                 return FAILURE;                                  return FAILURE;
                         }                          }
                         if (!internal_function->handler) {                          if (!internal_function->handler) {
                                 if (scope) {                                  if (scope) {
                                        efree(lc_class_name);                                        efree((char*)lc_class_name);
                                 }                                  }
                                 zend_error(error_type, "Method %s%s%s() cannot be a NULL function", scope ? scope->name : "", scope ? "::" : "", ptr->fname);                                  zend_error(error_type, "Method %s%s%s() cannot be a NULL function", scope ? scope->name : "", scope ? "::" : "", ptr->fname);
                                 zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);                                  zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);
Line 1895  ZEND_API int zend_register_functions(zend_class_entry  Line 2036  ZEND_API int zend_register_functions(zend_class_entry 
                         }                          }
                 }                  }
                 fname_len = strlen(ptr->fname);                  fname_len = strlen(ptr->fname);
                lowercase_name = zend_str_tolower_dup(ptr->fname, fname_len);                lowercase_name = zend_new_interned_string(zend_str_tolower_dup(ptr->fname, fname_len), fname_len + 1, 1 TSRMLS_CC);
                if (zend_hash_add(target_function_table, lowercase_name, fname_len+1, &function, sizeof(zend_function), (void**)&reg_function) == FAILURE) {                if (IS_INTERNED(lowercase_name)) {
                         result = zend_hash_quick_add(target_function_table, lowercase_name, fname_len+1, INTERNED_HASH(lowercase_name), &function, sizeof(zend_function), (void**)&reg_function);
                 } else {
                         result = zend_hash_add(target_function_table, lowercase_name, fname_len+1, &function, sizeof(zend_function), (void**)&reg_function);
                 }
                 if (result == FAILURE) {
                         unload=1;                          unload=1;
                        efree(lowercase_name);                        str_efree(lowercase_name);
                         break;                          break;
                 }                  }
                 if (scope) {                  if (scope) {
Line 1906  ZEND_API int zend_register_functions(zend_class_entry  Line 2052  ZEND_API int zend_register_functions(zend_class_entry 
                          * If it's an old-style constructor, store it only if we don't have                           * If it's an old-style constructor, store it only if we don't have
                          * a constructor already.                           * a constructor already.
                          */                           */
                        if ((fname_len == class_name_len) && !memcmp(lowercase_name, lc_class_name, class_name_len+1) && !ctor) {                        if ((fname_len == class_name_len) && !ctor && !memcmp(lowercase_name, lc_class_name, class_name_len+1)) {
                                 ctor = reg_function;                                  ctor = reg_function;
                         } else if ((fname_len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) {                          } else if ((fname_len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) {
                                 ctor = reg_function;                                  ctor = reg_function;
Line 1940  ZEND_API int zend_register_functions(zend_class_entry  Line 2086  ZEND_API int zend_register_functions(zend_class_entry 
                 }                  }
                 ptr++;                  ptr++;
                 count++;                  count++;
                efree(lowercase_name);                str_efree(lowercase_name);
         }          }
         if (unload) { /* before unloading, display all remaining bad function in the module */          if (unload) { /* before unloading, display all remaining bad function in the module */
                 if (scope) {                  if (scope) {
                        efree(lc_class_name);                        efree((char*)lc_class_name);
                 }                  }
                 while (ptr->fname) {                  while (ptr->fname) {
                         fname_len = strlen(ptr->fname);                          fname_len = strlen(ptr->fname);
Line 1952  ZEND_API int zend_register_functions(zend_class_entry  Line 2098  ZEND_API int zend_register_functions(zend_class_entry 
                         if (zend_hash_exists(target_function_table, lowercase_name, fname_len+1)) {                          if (zend_hash_exists(target_function_table, lowercase_name, fname_len+1)) {
                                 zend_error(error_type, "Function registration failed - duplicate name - %s%s%s", scope ? scope->name : "", scope ? "::" : "", ptr->fname);                                  zend_error(error_type, "Function registration failed - duplicate name - %s%s%s", scope ? scope->name : "", scope ? "::" : "", ptr->fname);
                         }                          }
                        efree(lowercase_name);                        efree((char*)lowercase_name);
                         ptr++;                          ptr++;
                 }                  }
                 zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);                  zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);
Line 2032  ZEND_API int zend_register_functions(zend_class_entry  Line 2178  ZEND_API int zend_register_functions(zend_class_entry 
                         }                          }
                         __isset->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;                          __isset->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
                 }                  }
                efree(lc_class_name);                efree((char*)lc_class_name);
         }          }
         return SUCCESS;          return SUCCESS;
 }  }
Line 2085  ZEND_API int zend_get_module_started(const char *modul Line 2231  ZEND_API int zend_get_module_started(const char *modul
   
 static int clean_module_class(const zend_class_entry **ce, int *module_number TSRMLS_DC) /* {{{ */  static int clean_module_class(const zend_class_entry **ce, int *module_number TSRMLS_DC) /* {{{ */
 {  {
        if ((*ce)->type == ZEND_INTERNAL_CLASS && (*ce)->module->module_number == *module_number) {        if ((*ce)->type == ZEND_INTERNAL_CLASS && (*ce)->info.internal.module->module_number == *module_number) {
                 return ZEND_HASH_APPLY_REMOVE;                  return ZEND_HASH_APPLY_REMOVE;
         } else {          } else {
                 return ZEND_HASH_APPLY_KEEP;                  return ZEND_HASH_APPLY_KEEP;
Line 2134  void module_destructor(zend_module_entry *module) /* { Line 2280  void module_destructor(zend_module_entry *module) /* {
   
 #if HAVE_LIBDL  #if HAVE_LIBDL
 #if !(defined(NETWARE) && defined(APACHE_1_BUILD))  #if !(defined(NETWARE) && defined(APACHE_1_BUILD))
        if (module->handle) {        if (module->handle && !getenv("ZEND_DONT_UNLOAD_MODULES")) {
                 DL_UNLOAD(module->handle);                  DL_UNLOAD(module->handle);
         }          }
 #endif  #endif
Line 2142  void module_destructor(zend_module_entry *module) /* { Line 2288  void module_destructor(zend_module_entry *module) /* {
 }  }
 /* }}} */  /* }}} */
   
/* call request startup for all modules */void zend_activate_modules(TSRMLS_D) /* {{{ */
int module_registry_request_startup(zend_module_entry *module TSRMLS_DC) /* {{{ */ 
 {  {
        if (module->request_startup_func) {        zend_module_entry **p = module_request_startup_handlers;
#if 0
                zend_printf("%s: Request startup\n", module->name);        while (*p) {
#endif                zend_module_entry *module = *p;
 
                 if (module->request_startup_func(module->type, module->module_number TSRMLS_CC)==FAILURE) {                  if (module->request_startup_func(module->type, module->module_number TSRMLS_CC)==FAILURE) {
                         zend_error(E_WARNING, "request_startup() for %s module failed", module->name);                          zend_error(E_WARNING, "request_startup() for %s module failed", module->name);
                         exit(1);                          exit(1);
                 }                  }
                   p++;
         }          }
         return 0;  
 }  }
 /* }}} */  /* }}} */
   
Line 2171  int module_registry_cleanup(zend_module_entry *module  Line 2317  int module_registry_cleanup(zend_module_entry *module 
 }  }
 /* }}} */  /* }}} */
   
   void zend_deactivate_modules(TSRMLS_D) /* {{{ */
   {
           EG(opline_ptr) = NULL; /* we're no longer executing anything */
   
           zend_try {
                   if (EG(full_tables_cleanup)) {
                           zend_hash_reverse_apply(&module_registry, (apply_func_t) module_registry_cleanup TSRMLS_CC);
                   } else {
                           zend_module_entry **p = module_request_shutdown_handlers;
   
                           while (*p) {
                                   zend_module_entry *module = *p;
   
                                   module->request_shutdown_func(module->type, module->module_number TSRMLS_CC);
                                   p++;
                           }
                   }
           } zend_end_try();
   }
   /* }}} */
   
   ZEND_API void zend_cleanup_internal_classes(TSRMLS_D) /* {{{ */
   {
           zend_class_entry **p = class_cleanup_handlers;
   
           while (*p) {
                   zend_cleanup_internal_class_data(*p TSRMLS_CC);
                   p++;
           }
   }
   /* }}} */
   
 int module_registry_unload_temp(const zend_module_entry *module TSRMLS_DC) /* {{{ */  int module_registry_unload_temp(const zend_module_entry *module TSRMLS_DC) /* {{{ */
 {  {
         return (module->type == MODULE_TEMPORARY) ? ZEND_HASH_APPLY_REMOVE : ZEND_HASH_APPLY_STOP;          return (module->type == MODULE_TEMPORARY) ? ZEND_HASH_APPLY_REMOVE : ZEND_HASH_APPLY_STOP;
 }  }
 /* }}} */  /* }}} */
   
   static int exec_done_cb(zend_module_entry *module TSRMLS_DC) /* {{{ */
   {
           if (module->post_deactivate_func) {
                   module->post_deactivate_func();
           }
           return 0;
   }
   /* }}} */
   
   void zend_post_deactivate_modules(TSRMLS_D) /* {{{ */
   {
           if (EG(full_tables_cleanup)) {
                   zend_hash_apply(&module_registry, (apply_func_t) exec_done_cb TSRMLS_CC);
                   zend_hash_reverse_apply(&module_registry, (apply_func_t) module_registry_unload_temp TSRMLS_CC);
           } else {
                   zend_module_entry **p = module_post_deactivate_handlers;
   
                   while (*p) {
                           zend_module_entry *module = *p;
   
                           module->post_deactivate_func();
                           p++;
                   }
           }
   }
   /* }}} */
   
 /* return the next free module number */  /* return the next free module number */
 int zend_next_free_module(void) /* {{{ */  int zend_next_free_module(void) /* {{{ */
 {  {
        return ++module_count;        return zend_hash_num_elements(&module_registry) + 1;
 }  }
 /* }}} */  /* }}} */
   
 static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class_entry, zend_uint ce_flags TSRMLS_DC) /* {{{ */  static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class_entry, zend_uint ce_flags TSRMLS_DC) /* {{{ */
 {  {
         zend_class_entry *class_entry = malloc(sizeof(zend_class_entry));          zend_class_entry *class_entry = malloc(sizeof(zend_class_entry));
        char *lowercase_name = malloc(orig_class_entry->name_length + 1);        char *lowercase_name = emalloc(orig_class_entry->name_length + 1);
         *class_entry = *orig_class_entry;          *class_entry = *orig_class_entry;
   
         class_entry->type = ZEND_INTERNAL_CLASS;          class_entry->type = ZEND_INTERNAL_CLASS;
         zend_initialize_class_data(class_entry, 0 TSRMLS_CC);          zend_initialize_class_data(class_entry, 0 TSRMLS_CC);
         class_entry->ce_flags = ce_flags;          class_entry->ce_flags = ce_flags;
        class_entry->module = EG(current_module);        class_entry->info.internal.module = EG(current_module);
   
        if (class_entry->builtin_functions) {        if (class_entry->info.internal.builtin_functions) {
                zend_register_functions(class_entry, class_entry->builtin_functions, &class_entry->function_table, MODULE_PERSISTENT TSRMLS_CC);                zend_register_functions(class_entry, class_entry->info.internal.builtin_functions, &class_entry->function_table, MODULE_PERSISTENT TSRMLS_CC);
         }          }
   
         zend_str_tolower_copy(lowercase_name, orig_class_entry->name, class_entry->name_length);          zend_str_tolower_copy(lowercase_name, orig_class_entry->name, class_entry->name_length);
        zend_hash_update(CG(class_table), lowercase_name, class_entry->name_length+1, &class_entry, sizeof(zend_class_entry *), NULL);        lowercase_name = (char*)zend_new_interned_string(lowercase_name, class_entry->name_length + 1, 1 TSRMLS_CC);
        free(lowercase_name);        if (IS_INTERNED(lowercase_name)) {
                 zend_hash_quick_update(CG(class_table), lowercase_name, class_entry->name_length+1, INTERNED_HASH(lowercase_name), &class_entry, sizeof(zend_class_entry *), NULL);
         } else {
                 zend_hash_update(CG(class_table), lowercase_name, class_entry->name_length+1, &class_entry, sizeof(zend_class_entry *), NULL);
         }
         str_efree(lowercase_name);
         return class_entry;          return class_entry;
 }  }
 /* }}} */  /* }}} */
Line 2326  static zend_object_value display_disabled_class(zend_c Line 2536  static zend_object_value display_disabled_class(zend_c
         zend_object_value retval;          zend_object_value retval;
         zend_object *intern;          zend_object *intern;
         retval = zend_objects_new(&intern, class_type TSRMLS_CC);          retval = zend_objects_new(&intern, class_type TSRMLS_CC);
         ALLOC_HASHTABLE(intern->properties);  
         zend_hash_init(intern->properties, 0, NULL, ZVAL_PTR_DTOR, 0);  
         zend_error(E_WARNING, "%s() has been disabled for security reasons", class_type->name);          zend_error(E_WARNING, "%s() has been disabled for security reasons", class_type->name);
         return retval;          return retval;
 }  }
Line 2400  static int zend_is_callable_check_class(const char *na Line 2608  static int zend_is_callable_check_class(const char *na
                         *strict_class = 1;                          *strict_class = 1;
                         ret = 1;                          ret = 1;
                 }                  }
        } else if (zend_lookup_class_ex(name, name_len, 1, &pce TSRMLS_CC) == SUCCESS) {        } else if (zend_lookup_class_ex(name, name_len, NULL, 1, &pce TSRMLS_CC) == SUCCESS) {
                 zend_class_entry *scope = EG(active_op_array) ? EG(active_op_array)->scope : NULL;                  zend_class_entry *scope = EG(active_op_array) ? EG(active_op_array)->scope : NULL;
   
                 fcc->calling_scope = *pce;                  fcc->calling_scope = *pce;
Line 2427  static int zend_is_callable_check_func(int check_flags Line 2635  static int zend_is_callable_check_func(int check_flags
 {  {
         zend_class_entry *ce_org = fcc->calling_scope;          zend_class_entry *ce_org = fcc->calling_scope;
         int retval = 0;          int retval = 0;
        char *mname, *lmname, *colon;        char *mname, *lmname;
         const char *colon;
         int clen, mlen;          int clen, mlen;
         zend_class_entry *last_scope;          zend_class_entry *last_scope;
         HashTable *ftable;          HashTable *ftable;
Line 2553  get_function_via_handler: Line 2762  get_function_via_handler:
                         if (strict_class && ce_org->__call) {                          if (strict_class && ce_org->__call) {
                                 fcc->function_handler = emalloc(sizeof(zend_internal_function));                                  fcc->function_handler = emalloc(sizeof(zend_internal_function));
                                 fcc->function_handler->internal_function.type = ZEND_INTERNAL_FUNCTION;                                  fcc->function_handler->internal_function.type = ZEND_INTERNAL_FUNCTION;
                                fcc->function_handler->internal_function.module = ce_org->module;                                fcc->function_handler->internal_function.module = (ce_org->type == ZEND_INTERNAL_CLASS) ? ce_org->info.internal.module : NULL;
                                 fcc->function_handler->internal_function.handler = zend_std_call_user_call;                                  fcc->function_handler->internal_function.handler = zend_std_call_user_call;
                                 fcc->function_handler->internal_function.arg_info = NULL;                                  fcc->function_handler->internal_function.arg_info = NULL;
                                 fcc->function_handler->internal_function.num_args = 0;                                  fcc->function_handler->internal_function.num_args = 0;
                                 fcc->function_handler->internal_function.scope = ce_org;                                  fcc->function_handler->internal_function.scope = ce_org;
                                 fcc->function_handler->internal_function.fn_flags = ZEND_ACC_CALL_VIA_HANDLER;                                  fcc->function_handler->internal_function.fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
                                 fcc->function_handler->internal_function.function_name = estrndup(mname, mlen);                                  fcc->function_handler->internal_function.function_name = estrndup(mname, mlen);
                                 fcc->function_handler->internal_function.pass_rest_by_reference = 0;  
                                 fcc->function_handler->internal_function.return_reference = ZEND_RETURN_VALUE;  
                                 call_via_handler = 1;                                  call_via_handler = 1;
                                 retval = 1;                                  retval = 1;
                         } else if (Z_OBJ_HT_P(fcc->object_ptr)->get_method) {                          } else if (Z_OBJ_HT_P(fcc->object_ptr)->get_method) {
                                fcc->function_handler = Z_OBJ_HT_P(fcc->object_ptr)->get_method(&fcc->object_ptr, mname, mlen TSRMLS_CC);                                fcc->function_handler = Z_OBJ_HT_P(fcc->object_ptr)->get_method(&fcc->object_ptr, mname, mlen, NULL TSRMLS_CC);
                                 if (fcc->function_handler) {                                  if (fcc->function_handler) {
                                         if (strict_class &&                                          if (strict_class &&
                                             (!fcc->function_handler->common.scope ||                                              (!fcc->function_handler->common.scope ||
                                              !instanceof_function(ce_org, fcc->function_handler->common.scope TSRMLS_CC))) {                                               !instanceof_function(ce_org, fcc->function_handler->common.scope TSRMLS_CC))) {
                                                 if ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) {                                                  if ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) {
                                                         if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {                                                          if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
                                                                efree(fcc->function_handler->common.function_name);                                                                efree((char*)fcc->function_handler->common.function_name);
                                                         }                                                          }
                                                         efree(fcc->function_handler);                                                          efree(fcc->function_handler);
                                                 }                                                  }
Line 2586  get_function_via_handler: Line 2793  get_function_via_handler:
                         if (fcc->calling_scope->get_static_method) {                          if (fcc->calling_scope->get_static_method) {
                                 fcc->function_handler = fcc->calling_scope->get_static_method(fcc->calling_scope, mname, mlen TSRMLS_CC);                                  fcc->function_handler = fcc->calling_scope->get_static_method(fcc->calling_scope, mname, mlen TSRMLS_CC);
                         } else {                          } else {
                                fcc->function_handler = zend_std_get_static_method(fcc->calling_scope, mname, mlen TSRMLS_CC);                                fcc->function_handler = zend_std_get_static_method(fcc->calling_scope, mname, mlen, NULL TSRMLS_CC);
                         }                          }
                         if (fcc->function_handler) {                          if (fcc->function_handler) {
                                 retval = 1;                                  retval = 1;
Line 2748  ZEND_API zend_bool zend_is_callable_ex(zval *callable, Line 2955  ZEND_API zend_bool zend_is_callable_ex(zval *callable,
                              fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||                               fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
                              fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {                               fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
                                 if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {                                  if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
                                        efree(fcc->function_handler->common.function_name);                                        efree((char*)fcc->function_handler->common.function_name);
                                 }                                  }
                                 efree(fcc->function_handler);                                  efree(fcc->function_handler);
                         }                          }
Line 2826  ZEND_API zend_bool zend_is_callable_ex(zval *callable, Line 3033  ZEND_API zend_bool zend_is_callable_ex(zval *callable,
                                              fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||                                               fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
                                              fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {                                               fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
                                                 if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {                                                  if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
                                                        efree(fcc->function_handler->common.function_name);                                                        efree((char*)fcc->function_handler->common.function_name);
                                                 }                                                  }
                                                 efree(fcc->function_handler);                                                  efree(fcc->function_handler);
                                         }                                          }
Line 2904  ZEND_API zend_bool zend_make_callable(zval *callable,  Line 3111  ZEND_API zend_bool zend_make_callable(zval *callable, 
                      fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||                       fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
                      fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION)) {                       fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
                         if (fcc.function_handler->type != ZEND_OVERLOADED_FUNCTION) {                          if (fcc.function_handler->type != ZEND_OVERLOADED_FUNCTION) {
                                efree(fcc.function_handler->common.function_name);                                efree((char*)fcc.function_handler->common.function_name);
                         }                          }
                         efree(fcc.function_handler);                          efree(fcc.function_handler);
                 }                  }
Line 3090  ZEND_API const char *zend_get_module_version(const cha Line 3297  ZEND_API const char *zend_get_module_version(const cha
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_declare_property_ex(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type, char *doc_comment, int doc_comment_len TSRMLS_DC) /* {{{ */ZEND_API int zend_declare_property_ex(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type, const char *doc_comment, int doc_comment_len TSRMLS_DC) /* {{{ */
 {  {
        zend_property_info property_info;        zend_property_info property_info, *property_info_ptr;
        HashTable *target_symbol_table;        const char *interned_name;
         ulong h = zend_get_hash_value(name, name_length+1);
   
         if (!(access_type & ZEND_ACC_PPP_MASK)) {          if (!(access_type & ZEND_ACC_PPP_MASK)) {
                 access_type |= ZEND_ACC_PUBLIC;                  access_type |= ZEND_ACC_PUBLIC;
         }          }
         if (access_type & ZEND_ACC_STATIC) {          if (access_type & ZEND_ACC_STATIC) {
                target_symbol_table = &ce->default_static_members;                if (zend_hash_quick_find(&ce->properties_info, name, name_length + 1, h, (void**)&property_info_ptr) == SUCCESS &&
                     (property_info_ptr->flags & ZEND_ACC_STATIC) != 0) {
                         property_info.offset = property_info_ptr->offset;
                         zval_ptr_dtor(&ce->default_static_members_table[property_info.offset]);
                         zend_hash_quick_del(&ce->properties_info, name, name_length + 1, h);
                 } else {
                         property_info.offset = ce->default_static_members_count++;
                         ce->default_static_members_table = perealloc(ce->default_static_members_table, sizeof(zval*) * ce->default_static_members_count, ce->type == ZEND_INTERNAL_CLASS);
                 }
                 ce->default_static_members_table[property_info.offset] = property;
                 if (ce->type == ZEND_USER_CLASS) {
                         ce->static_members_table = ce->default_static_members_table;
                 }
         } else {          } else {
                target_symbol_table = &ce->default_properties;                if (zend_hash_quick_find(&ce->properties_info, name, name_length + 1, h, (void**)&property_info_ptr) == SUCCESS &&
                     (property_info_ptr->flags & ZEND_ACC_STATIC) == 0) {
                         property_info.offset = property_info_ptr->offset;
                         zval_ptr_dtor(&ce->default_properties_table[property_info.offset]);
                         zend_hash_quick_del(&ce->properties_info, name, name_length + 1, h);
                 } else {
                         property_info.offset = ce->default_properties_count++;
                         ce->default_properties_table = perealloc(ce->default_properties_table, sizeof(zval*) * ce->default_properties_count, ce->type == ZEND_INTERNAL_CLASS);
                 }
                 ce->default_properties_table[property_info.offset] = property;
         }          }
         if (ce->type & ZEND_INTERNAL_CLASS) {          if (ce->type & ZEND_INTERNAL_CLASS) {
                 switch(Z_TYPE_P(property)) {                  switch(Z_TYPE_P(property)) {
Line 3121  ZEND_API int zend_declare_property_ex(zend_class_entry Line 3350  ZEND_API int zend_declare_property_ex(zend_class_entry
                                 int priv_name_length;                                  int priv_name_length;
   
                                 zend_mangle_property_name(&priv_name, &priv_name_length, ce->name, ce->name_length, name, name_length, ce->type & ZEND_INTERNAL_CLASS);                                  zend_mangle_property_name(&priv_name, &priv_name_length, ce->name, ce->name_length, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
                                 zend_hash_update(target_symbol_table, priv_name, priv_name_length+1, &property, sizeof(zval *), NULL);  
                                 property_info.name = priv_name;                                  property_info.name = priv_name;
                                 property_info.name_length = priv_name_length;                                  property_info.name_length = priv_name_length;
                         }                          }
Line 3131  ZEND_API int zend_declare_property_ex(zend_class_entry Line 3359  ZEND_API int zend_declare_property_ex(zend_class_entry
                                 int prot_name_length;                                  int prot_name_length;
   
                                 zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);                                  zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
                                 zend_hash_update(target_symbol_table, prot_name, prot_name_length+1, &property, sizeof(zval *), NULL);  
                                 property_info.name = prot_name;                                  property_info.name = prot_name;
                                 property_info.name_length = prot_name_length;                                  property_info.name_length = prot_name_length;
                         }                          }
                         break;                          break;
                 case ZEND_ACC_PUBLIC:                  case ZEND_ACC_PUBLIC:
                        if (ce->parent) {                        if (IS_INTERNED(name)) {
                                char *prot_name;                                property_info.name = (char*)name;
                                int prot_name_length;                        } else {
                                property_info.name = ce->type & ZEND_INTERNAL_CLASS ? zend_strndup(name, name_length) : estrndup(name, name_length);
                                zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS); 
                                zend_hash_del(target_symbol_table, prot_name, prot_name_length+1); 
                                pefree(prot_name, ce->type & ZEND_INTERNAL_CLASS); 
                         }                          }
                         zend_hash_update(target_symbol_table, name, name_length+1, &property, sizeof(zval *), NULL);  
                         property_info.name = ce->type & ZEND_INTERNAL_CLASS ? zend_strndup(name, name_length) : estrndup(name, name_length);  
                         property_info.name_length = name_length;                          property_info.name_length = name_length;
                         break;                          break;
         }          }
   
           interned_name = zend_new_interned_string(property_info.name, property_info.name_length+1, 0 TSRMLS_CC);
           if (interned_name != property_info.name) {
                   if (ce->type == ZEND_USER_CLASS) {
                           efree((char*)property_info.name);
                   } else {
                           free((char*)property_info.name);
                   }
                   property_info.name = interned_name;
           }
   
         property_info.flags = access_type;          property_info.flags = access_type;
        property_info.h = zend_get_hash_value(property_info.name, property_info.name_length+1);        property_info.h = (access_type & ZEND_ACC_PUBLIC) ? h : zend_get_hash_value(property_info.name, property_info.name_length+1);
   
         property_info.doc_comment = doc_comment;          property_info.doc_comment = doc_comment;
         property_info.doc_comment_len = doc_comment_len;          property_info.doc_comment_len = doc_comment_len;
   
         property_info.ce = ce;          property_info.ce = ce;
   
        zend_hash_update(&ce->properties_info, name, name_length + 1, &property_info, sizeof(zend_property_info), NULL);        zend_hash_quick_update(&ce->properties_info, name, name_length+1, h, &property_info, sizeof(zend_property_info), NULL);
   
         return SUCCESS;          return SUCCESS;
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_length, zval *property, int access_type TSRMLS_DC) /* {{{ */ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type TSRMLS_DC) /* {{{ */
 {  {
         return zend_declare_property_ex(ce, name, name_length, property, access_type, NULL, 0 TSRMLS_CC);          return zend_declare_property_ex(ce, name, name_length, property, access_type, NULL, 0 TSRMLS_CC);
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_declare_property_null(zend_class_entry *ce, char *name, int name_length, int access_type TSRMLS_DC) /* {{{ */ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, int name_length, int access_type TSRMLS_DC) /* {{{ */
 {  {
         zval *property;          zval *property;
   
Line 3184  ZEND_API int zend_declare_property_null(zend_class_ent Line 3417  ZEND_API int zend_declare_property_null(zend_class_ent
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_declare_property_bool(zend_class_entry *ce, char *name, int name_length, long value, int access_type TSRMLS_DC) /* {{{ */ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC) /* {{{ */
 {  {
         zval *property;          zval *property;
   
Line 3199  ZEND_API int zend_declare_property_bool(zend_class_ent Line 3432  ZEND_API int zend_declare_property_bool(zend_class_ent
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_declare_property_long(zend_class_entry *ce, char *name, int name_length, long value, int access_type TSRMLS_DC) /* {{{ */ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, int name_length, long value, int access_type TSRMLS_DC) /* {{{ */
 {  {
         zval *property;          zval *property;
   
Line 3214  ZEND_API int zend_declare_property_long(zend_class_ent Line 3447  ZEND_API int zend_declare_property_long(zend_class_ent
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_declare_property_double(zend_class_entry *ce, char *name, int name_length, double value, int access_type TSRMLS_DC) /* {{{ */ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, int name_length, double value, int access_type TSRMLS_DC) /* {{{ */
 {  {
         zval *property;          zval *property;
   
Line 3229  ZEND_API int zend_declare_property_double(zend_class_e Line 3462  ZEND_API int zend_declare_property_double(zend_class_e
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_declare_property_string(zend_class_entry *ce, char *name, int name_length, char *value, int access_type TSRMLS_DC) /* {{{ */ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, int name_length, const char *value, int access_type TSRMLS_DC) /* {{{ */
 {  {
         zval *property;          zval *property;
         int len = strlen(value);          int len = strlen(value);
Line 3246  ZEND_API int zend_declare_property_string(zend_class_e Line 3479  ZEND_API int zend_declare_property_string(zend_class_e
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, char *name, int name_length, char *value, int value_len, int access_type TSRMLS_DC) /* {{{ */ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, int name_length, const char *value, int value_len, int access_type TSRMLS_DC) /* {{{ */
 {  {
         zval *property;          zval *property;
   
Line 3350  ZEND_API int zend_declare_class_constant_string(zend_c Line 3583  ZEND_API int zend_declare_class_constant_string(zend_c
 }  }
 /* }}} */  /* }}} */
   
ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, char *name, int name_length, zval *value TSRMLS_DC) /* {{{ */ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, int name_length, zval *value TSRMLS_DC) /* {{{ */
 {  {
         zval *property;          zval *property;
         zend_class_entry *old_scope = EG(scope);          zend_class_entry *old_scope = EG(scope);
Line 3358  ZEND_API void zend_update_property(zend_class_entry *s Line 3591  ZEND_API void zend_update_property(zend_class_entry *s
         EG(scope) = scope;          EG(scope) = scope;
   
         if (!Z_OBJ_HT_P(object)->write_property) {          if (!Z_OBJ_HT_P(object)->write_property) {
                char *class_name;                const char *class_name;
                 zend_uint class_name_len;                  zend_uint class_name_len;
   
                 zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);                  zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
Line 3367  ZEND_API void zend_update_property(zend_class_entry *s Line 3600  ZEND_API void zend_update_property(zend_class_entry *s
         }          }
         MAKE_STD_ZVAL(property);          MAKE_STD_ZVAL(property);
         ZVAL_STRINGL(property, name, name_length, 1);          ZVAL_STRINGL(property, name, name_length, 1);
        Z_OBJ_HT_P(object)->write_property(object, property, value TSRMLS_CC);        Z_OBJ_HT_P(object)->write_property(object, property, value, 0 TSRMLS_CC);
         zval_ptr_dtor(&property);          zval_ptr_dtor(&property);
   
         EG(scope) = old_scope;          EG(scope) = old_scope;
 }  }
 /* }}} */  /* }}} */
   
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, char *name, int name_length TSRMLS_DC) /* {{{ */ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3386  ZEND_API void zend_update_property_null(zend_class_ent Line 3619  ZEND_API void zend_update_property_null(zend_class_ent
 }  }
 /* }}} */  /* }}} */
   
ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC) /* {{{ */ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3398  ZEND_API void zend_update_property_bool(zend_class_ent Line 3631  ZEND_API void zend_update_property_bool(zend_class_ent
 }  }
 /* }}} */  /* }}} */
   
ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC) /* {{{ */ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3410  ZEND_API void zend_update_property_long(zend_class_ent Line 3643  ZEND_API void zend_update_property_long(zend_class_ent
 }  }
 /* }}} */  /* }}} */
   
ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, char *name, int name_length, double value TSRMLS_DC) /* {{{ */ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, int name_length, double value TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3422  ZEND_API void zend_update_property_double(zend_class_e Line 3655  ZEND_API void zend_update_property_double(zend_class_e
 }  }
 /* }}} */  /* }}} */
   
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, char *name, int name_length, const char *value TSRMLS_DC) /* {{{ */ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3434  ZEND_API void zend_update_property_string(zend_class_e Line 3667  ZEND_API void zend_update_property_string(zend_class_e
 }  }
 /* }}} */  /* }}} */
   
ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, char *name, int name_length, const char *value, int value_len TSRMLS_DC) /* {{{ */ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value, int value_len TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3446  ZEND_API void zend_update_property_stringl(zend_class_ Line 3679  ZEND_API void zend_update_property_stringl(zend_class_
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_update_static_property(zend_class_entry *scope, char *name, int name_length, zval *value TSRMLS_DC) /* {{{ */ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, int name_length, zval *value TSRMLS_DC) /* {{{ */
 {  {
         zval **property;          zval **property;
         zend_class_entry *old_scope = EG(scope);          zend_class_entry *old_scope = EG(scope);
   
         EG(scope) = scope;          EG(scope) = scope;
        property = zend_std_get_static_property(scope, name, name_length, 0 TSRMLS_CC);        property = zend_std_get_static_property(scope, name, name_length, 0, NULL TSRMLS_CC);
         EG(scope) = old_scope;          EG(scope) = old_scope;
         if (!property) {          if (!property) {
                 return FAILURE;                  return FAILURE;
Line 3481  ZEND_API int zend_update_static_property(zend_class_en Line 3714  ZEND_API int zend_update_static_property(zend_class_en
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_update_static_property_null(zend_class_entry *scope, char *name, int name_length TSRMLS_DC) /* {{{ */ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, int name_length TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3493  ZEND_API int zend_update_static_property_null(zend_cla Line 3726  ZEND_API int zend_update_static_property_null(zend_cla
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, char *name, int name_length, long value TSRMLS_DC) /* {{{ */ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3505  ZEND_API int zend_update_static_property_bool(zend_cla Line 3738  ZEND_API int zend_update_static_property_bool(zend_cla
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_update_static_property_long(zend_class_entry *scope, char *name, int name_length, long value TSRMLS_DC) /* {{{ */ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3517  ZEND_API int zend_update_static_property_long(zend_cla Line 3750  ZEND_API int zend_update_static_property_long(zend_cla
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_update_static_property_double(zend_class_entry *scope, char *name, int name_length, double value TSRMLS_DC) /* {{{ */ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, int name_length, double value TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3529  ZEND_API int zend_update_static_property_double(zend_c Line 3762  ZEND_API int zend_update_static_property_double(zend_c
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_update_static_property_string(zend_class_entry *scope, char *name, int name_length, const char *value TSRMLS_DC) /* {{{ */ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, int name_length, const char *value TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3541  ZEND_API int zend_update_static_property_string(zend_c Line 3774  ZEND_API int zend_update_static_property_string(zend_c
 }  }
 /* }}} */  /* }}} */
   
ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, char *name, int name_length, const char *value, int value_len TSRMLS_DC) /* {{{ */ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, int name_length, const char *value, int value_len TSRMLS_DC) /* {{{ */
 {  {
         zval *tmp;          zval *tmp;
   
Line 3553  ZEND_API int zend_update_static_property_stringl(zend_ Line 3786  ZEND_API int zend_update_static_property_stringl(zend_
 }  }
 /* }}} */  /* }}} */
   
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, char *name, int name_length, zend_bool silent TSRMLS_DC) /* {{{ */ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_bool silent TSRMLS_DC) /* {{{ */
 {  {
         zval *property, *value;          zval *property, *value;
         zend_class_entry *old_scope = EG(scope);          zend_class_entry *old_scope = EG(scope);
Line 3561  ZEND_API zval *zend_read_property(zend_class_entry *sc Line 3794  ZEND_API zval *zend_read_property(zend_class_entry *sc
         EG(scope) = scope;          EG(scope) = scope;
   
         if (!Z_OBJ_HT_P(object)->read_property) {          if (!Z_OBJ_HT_P(object)->read_property) {
                char *class_name;                const char *class_name;
                 zend_uint class_name_len;                  zend_uint class_name_len;
   
                 zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);                  zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
Line 3570  ZEND_API zval *zend_read_property(zend_class_entry *sc Line 3803  ZEND_API zval *zend_read_property(zend_class_entry *sc
   
         MAKE_STD_ZVAL(property);          MAKE_STD_ZVAL(property);
         ZVAL_STRINGL(property, name, name_length, 1);          ZVAL_STRINGL(property, name, name_length, 1);
        value = Z_OBJ_HT_P(object)->read_property(object, property, silent?BP_VAR_IS:BP_VAR_R TSRMLS_CC);        value = Z_OBJ_HT_P(object)->read_property(object, property, silent?BP_VAR_IS:BP_VAR_R, 0 TSRMLS_CC);
         zval_ptr_dtor(&property);          zval_ptr_dtor(&property);
   
         EG(scope) = old_scope;          EG(scope) = old_scope;
Line 3578  ZEND_API zval *zend_read_property(zend_class_entry *sc Line 3811  ZEND_API zval *zend_read_property(zend_class_entry *sc
 }  }
 /* }}} */  /* }}} */
   
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, char *name, int name_length, zend_bool silent TSRMLS_DC) /* {{{ */ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, int name_length, zend_bool silent TSRMLS_DC) /* {{{ */
 {  {
         zval **property;          zval **property;
         zend_class_entry *old_scope = EG(scope);          zend_class_entry *old_scope = EG(scope);
   
         EG(scope) = scope;          EG(scope) = scope;
        property = zend_std_get_static_property(scope, name, name_length, silent TSRMLS_CC);        property = zend_std_get_static_property(scope, name, name_length, silent, NULL TSRMLS_CC);
         EG(scope) = old_scope;          EG(scope) = old_scope;
   
         return property?*property:NULL;          return property?*property:NULL;

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>