Permalink
Browse files

handling of reflection objects has been corrected (#30, #40)

  • Loading branch information...
zenovich committed Sep 26, 2012
1 parent 77b0f32 commit b048339fde25c9ffc125f0cf2d82fbc0665ed38a
Showing with 28 additions and 27 deletions.
  1. +19 −5 php_runkit.h
  2. +5 −18 runkit.c
  3. +3 −3 runkit_functions.c
  4. +1 −1 runkit_props.c
View
@@ -132,7 +132,7 @@ ZEND_BEGIN_MODULE_GLOBALS(runkit)
HashTable *replaced_internal_functions;
zend_bool internal_override;
# ifdef ZEND_ENGINE_2
- zval *name_str_zval, *removed_method_str_zval, *removed_function_str_zval, *removed_parameter_str_zval, *removed_property_str_zval;
+ const char *name_str, *removed_method_str, *removed_function_str, *removed_parameter_str, *removed_property_str;
zend_function *removed_function, *removed_method;
# endif
#endif
@@ -504,21 +504,35 @@ struct _php_runkit_sandbox_object {
# if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4) || (PHP_MAJOR_VERSION > 5)
# define PHP_RUNKIT_UPDATE_REFLECTION_OBJECT_NAME(object, handle, name) { \
- zval obj; \
+ zval obj, *zvname, *zvnew_name; \
+ INIT_ZVAL(obj); \
Z_TYPE(obj) = IS_OBJECT; \
Z_OBJ_HANDLE(obj) = (handle); \
obj.RUNKIT_REFCOUNT = 1; \
obj.RUNKIT_IS_REF = 1; \
- zend_std_write_property(&obj, RUNKIT_G(name_str_zval), (name), NULL TSRMLS_CC); \
+ MAKE_STD_ZVAL(zvname); \
+ ZVAL_STRING(zvname, RUNKIT_G(name_str), 1); \
+ MAKE_STD_ZVAL(zvnew_name); \
+ ZVAL_STRING(zvnew_name, (name), 1); \
+ zend_std_write_property(&obj, zvname, zvnew_name, NULL TSRMLS_CC); \
+ zval_ptr_dtor(&zvnew_name); \
+ zval_ptr_dtor(&zvname); \
}
# else
# define PHP_RUNKIT_UPDATE_REFLECTION_OBJECT_NAME(object, handle, name) { \
- zval obj; \
+ zval obj, *zvname, *zvnew_name; \
+ INIT_ZVAL(obj); \
Z_TYPE(obj) = IS_OBJECT; \
Z_OBJ_HANDLE(obj) = (handle); \
obj.RUNKIT_REFCOUNT = 1; \
obj.RUNKIT_IS_REF = 1; \
- zend_get_std_object_handlers()->write_property(&obj, RUNKIT_G(name_str_zval), (name) TSRMLS_CC); \
+ MAKE_STD_ZVAL(zvname); \
+ ZVAL_STRING(zvname, (char *) RUNKIT_G(name_str), 1); \
+ MAKE_STD_ZVAL(zvnew_name); \
+ ZVAL_STRING(zvnew_name, (char *) (name), 1); \
+ zend_get_std_object_handlers()->write_property(&obj, zvname, zvnew_name TSRMLS_CC); \
+ zval_ptr_dtor(&zvnew_name); \
+ zval_ptr_dtor(&zvname); \
}
# endif
View
@@ -203,16 +203,11 @@ static void php_runkit_globals_ctor(void *pDest TSRMLS_DC)
runkit_global->replaced_internal_functions = NULL;
runkit_global->misplaced_internal_functions = NULL;
# ifdef ZEND_ENGINE_2
- MAKE_STD_ZVAL(runkit_global->name_str_zval);
- ZVAL_STRINGL(runkit_global->name_str_zval, "name", sizeof("name") - 1, 1);
- MAKE_STD_ZVAL(runkit_global->removed_method_str_zval);
- ZVAL_STRINGL(runkit_global->removed_method_str_zval, "__method_removed_by_runkit__", sizeof("__method_removed_by_runkit__") - 1, 1);
- MAKE_STD_ZVAL(runkit_global->removed_function_str_zval);
- ZVAL_STRINGL(runkit_global->removed_function_str_zval, "__function_removed_by_runkit__", sizeof("__function_removed_by_runkit__") - 1, 1);
- MAKE_STD_ZVAL(runkit_global->removed_parameter_str_zval);
- ZVAL_STRINGL(runkit_global->removed_parameter_str_zval, "__parameter_removed_by_runkit__", sizeof("__parameter_removed_by_runkit__") - 1, 1);
- MAKE_STD_ZVAL(runkit_global->removed_property_str_zval);
- ZVAL_STRINGL(runkit_global->removed_property_str_zval, "__property_removed_by_runkit__", sizeof("__property_removed_by_runkit__") - 1, 1);
+ runkit_global->name_str = "name";
+ runkit_global->removed_method_str = "__method_removed_by_runkit__";
+ runkit_global->removed_function_str = "__function_removed_by_runkit__";
+ runkit_global->removed_parameter_str = "__parameter_removed_by_runkit__";
+ runkit_global->removed_property_str = "__property_removed_by_runkit__";
_php_runkit_init_stub_function("__function_removed_by_runkit__", ZEND_FN(_php_runkit_removed_function), &runkit_global->removed_function);
_php_runkit_init_stub_function("__method_removed_by_runkit__", ZEND_FN(_php_runkit_removed_method), &runkit_global->removed_method);
@@ -319,14 +314,6 @@ PHP_MSHUTDOWN_FUNCTION(runkit)
{
#if defined(PHP_RUNKIT_SUPERGLOBALS) || defined(PHP_RUNKIT_MANIPULATION)
UNREGISTER_INI_ENTRIES();
-#endif
-# ifdef PHP_RUNKIT_MANIPULATION
-# ifdef ZEND_ENGINE_2
- zval_ptr_dtor(&RUNKIT_G(name_str_zval));
- zval_ptr_dtor(&RUNKIT_G(removed_method_str_zval));
- zval_ptr_dtor(&RUNKIT_G(removed_function_str_zval));
- zval_ptr_dtor(&RUNKIT_G(removed_parameter_str_zval));
-# endif
#endif
return (1)
View
@@ -394,7 +394,7 @@ void php_runkit_remove_function_from_reflection_objects(zend_function *fe TSRMLS
#if !RUNKIT_ABOVE53
refl_obj->free_ptr = 0;
#endif
- PHP_RUNKIT_UPDATE_REFLECTION_OBJECT_NAME(object, i, RUNKIT_G(removed_function_str_zval));
+ PHP_RUNKIT_UPDATE_REFLECTION_OBJECT_NAME(object, i, RUNKIT_G(removed_function_str));
}
} else if (object->ce == reflection_method_ptr) {
reflection_object *refl_obj = (reflection_object *) object;
@@ -411,15 +411,15 @@ void php_runkit_remove_function_from_reflection_objects(zend_function *fe TSRMLS
#if !RUNKIT_ABOVE53
refl_obj->free_ptr = 1;
#endif
- PHP_RUNKIT_UPDATE_REFLECTION_OBJECT_NAME(object, i, RUNKIT_G(removed_method_str_zval));
+ PHP_RUNKIT_UPDATE_REFLECTION_OBJECT_NAME(object, i, RUNKIT_G(removed_method_str));
}
} else if (object->ce == reflection_parameter_ptr) {
reflection_object *refl_obj = (reflection_object *) object;
parameter_reference *reference = (parameter_reference *) refl_obj->ptr;
if (reference && reference->fptr == fe) {
PHP_RUNKIT_DELETE_REFLECTION_FUNCTION_PTR(refl_obj);
refl_obj->ptr = NULL;
- PHP_RUNKIT_UPDATE_REFLECTION_OBJECT_NAME(object, i, RUNKIT_G(removed_parameter_str_zval));
+ PHP_RUNKIT_UPDATE_REFLECTION_OBJECT_NAME(object, i, RUNKIT_G(removed_parameter_str));
}
}
}
View
@@ -452,7 +452,7 @@ void php_runkit_remove_property_from_reflection_objects(zend_class_entry *ce, co
#endif
refl_obj->ptr = NULL;
}
- PHP_RUNKIT_UPDATE_REFLECTION_OBJECT_NAME(object, i, RUNKIT_G(removed_property_str_zval));
+ PHP_RUNKIT_UPDATE_REFLECTION_OBJECT_NAME(object, i, RUNKIT_G(removed_property_str));
}
}
}

0 comments on commit b048339

Please sign in to comment.