Created
December 30, 2009 05:02
-
-
Save co3k/265855 to your computer and use it in GitHub Desktop.
PHP 5.3 で runkit をコンパイルするための自分用パッチ(サンドボックスのあたりはたぶんまだ動かないと思う)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: runkit_methods.c | |
=================================================================== | |
--- runkit_methods.c (revision 292782) | |
+++ runkit_methods.c (working copy) | |
@@ -181,7 +181,7 @@ | |
/* {{{ php_runkit_update_children_methods | |
Scan the class_table for children of the class just updated */ | |
-int php_runkit_update_children_methods(zend_class_entry *ce, int num_args, va_list args, zend_hash_key *hash_key) | |
+int php_runkit_update_children_methods(zend_class_entry *ce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) | |
{ | |
zend_class_entry *ancestor_class = va_arg(args, zend_class_entry*); | |
zend_class_entry *parent_class = va_arg(args, zend_class_entry*); | |
@@ -190,7 +190,9 @@ | |
char *fname = va_arg(args, char*); | |
int fname_len = va_arg(args, int); | |
zend_function *cfe = NULL; | |
+#if !(PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) && !(PHP_MAJOR_VERSION >= 6) | |
TSRMLS_FETCH(); | |
+#endif | |
#ifdef ZEND_ENGINE_2 | |
ce = *((zend_class_entry**)ce); | |
@@ -210,7 +212,7 @@ | |
} | |
/* Process children of this child */ | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, fe, fname, fname_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, fe, fname, fname_len); | |
PHP_RUNKIT_FUNCTION_ADD_REF(fe); | |
if (zend_hash_add_or_update(&ce->function_table, fname, fname_len + 1, fe, sizeof(zend_function), NULL, cfe ? HASH_UPDATE : HASH_ADD) == FAILURE) { | |
@@ -226,7 +228,7 @@ | |
/* {{{ php_runkit_clean_children | |
Scan the class_table for children of the class just updated */ | |
-int php_runkit_clean_children_methods(zend_class_entry *ce, int num_args, va_list args, zend_hash_key *hash_key) | |
+int php_runkit_clean_children_methods(zend_class_entry *ce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) | |
{ | |
zend_class_entry *ancestor_class = va_arg(args, zend_class_entry*); | |
zend_class_entry *parent_class = va_arg(args, zend_class_entry*); | |
@@ -234,7 +236,9 @@ | |
char *fname = va_arg(args, char*); | |
int fname_len = va_arg(args, int); | |
zend_function *cfe = NULL; | |
+#if !(PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) && !(PHP_MAJOR_VERSION >= 6) | |
TSRMLS_FETCH(); | |
+#endif | |
#ifdef ZEND_ENGINE_2 | |
ce = *((zend_class_entry**)ce); | |
@@ -259,7 +263,7 @@ | |
} | |
/* Process children of this child */ | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, fname, fname_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, fname, fname_len); | |
zend_hash_del(&ce->function_table, fname, fname_len + 1); | |
@@ -345,7 +349,7 @@ | |
func.common.fn_flags |= ZEND_ACC_ALLOW_STATIC; | |
#endif | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, &func, methodname, | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, &func, methodname, | |
methodname_len); | |
if (zend_hash_add_or_update(&ce->function_table, methodname, methodname_len + 1, &func, sizeof(zend_function), NULL, add_or_update) == FAILURE) { | |
@@ -404,7 +408,7 @@ | |
PHP_RUNKIT_ADD_MAGIC_METHOD(dce, dfunc, dfeInHashTable); | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_methods, 5, dce, dce, &dfe, dfunc, dfunc_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_methods, 5, dce, dce, &dfe, dfunc, dfunc_len); | |
return SUCCESS; | |
} | |
@@ -456,7 +460,7 @@ | |
ancestor_class = php_runkit_locate_scope(ce, fe, methodname, methodname_len); | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, methodname, methodname_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, methodname, methodname_len); | |
if (zend_hash_del(&ce->function_table, methodname, methodname_len + 1) == FAILURE) { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to remove method from class"); | |
@@ -501,7 +505,7 @@ | |
} | |
ancestor_class = php_runkit_locate_scope(ce, fe, methodname, methodname_len); | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, methodname, | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, methodname, | |
methodname_len); | |
func = *fe; | |
Index: runkit_props.c | |
=================================================================== | |
--- runkit_props.c (revision 292782) | |
+++ runkit_props.c (working copy) | |
@@ -42,10 +42,10 @@ | |
} | |
/* Process children of this child */ | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_def_props, 4, ce, p, pname, pname_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_def_props, 4, ce, p, pname, pname_len); | |
zend_hash_del(&ce->default_properties, pname, pname_len + 1); | |
- ZVAL_ADDREF(p); | |
+ Z_ADDREF_P(p); | |
if (zend_hash_add(&ce->default_properties, pname, pname_len + 1, p, sizeof(zval*), NULL) == FAILURE) { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error updating child class"); | |
return ZEND_HASH_APPLY_KEEP; | |
@@ -143,7 +143,7 @@ | |
#ifdef ZEND_ENGINE_2 | |
if (visibility != ZEND_ACC_PRIVATE) { | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_def_props, 4, ce, copyval, key, key_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_def_props, 4, ce, copyval, key, key_len); | |
} | |
#endif | |
Index: runkit_sandbox_parent.c | |
=================================================================== | |
--- runkit_sandbox_parent.c (revision 292782) | |
+++ runkit_sandbox_parent.c (working copy) | |
@@ -94,8 +94,13 @@ | |
ALLOC_INIT_ZVAL(hidden); | |
array_init(hidden); | |
ht = Z_ARRVAL_P(hidden); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ if (Z_REFCOUNT_PP(symtable) > 1 && | |
+ !Z_ISREF_PP(symtable)) { | |
+#else | |
if ((*symtable)->refcount > 1 && | |
!(*symtable)->is_ref) { | |
+#endif | |
zval *cv; | |
MAKE_STD_ZVAL(cv); | |
@@ -105,8 +110,13 @@ | |
INIT_PZVAL(cv); | |
*symtable = cv; | |
} | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_SET_ISREF_PP(symtable); | |
+ Z_ADDREF_PP(symtable); | |
+#else | |
(*symtable)->is_ref = 1; | |
(*symtable)->refcount++; | |
+#endif | |
zend_hash_update(ht, objval->self->parent_scope_name, objval->self->parent_scope_namelen + 1, (void*)symtable, sizeof(zval*), NULL); | |
/* Store that dummy array in the sandbox's hidden properties table so that it gets cleaned up on dtor */ | |
@@ -168,7 +178,7 @@ | |
int i; | |
- if (!zend_is_callable(func_name, IS_CALLABLE_CHECK_NO_ACCESS, &name)) { | |
+ if (!zend_is_callable(func_name, IS_CALLABLE_CHECK_NO_ACCESS, &name TSRMLS_CC)) { | |
php_error_docref1(NULL TSRMLS_CC, name, E_WARNING, "Function not defined"); | |
if (name) { | |
efree(name); | |
@@ -278,7 +288,7 @@ | |
op_array = zend_compile_file(&file_handle, type TSRMLS_CC); | |
zend_destroy_file_handle(&file_handle TSRMLS_CC); | |
} else { | |
- zend_file_handle_dtor(&file_handle); | |
+ zend_file_handle_dtor(&file_handle TSRMLS_CC); | |
RETVAL_TRUE; | |
already_included = 1; | |
} | |
@@ -534,7 +544,11 @@ | |
/* ZE expects refcount == 0 for unowned values */ | |
INIT_PZVAL(return_value); | |
PHP_SANDBOX_CROSS_SCOPE_ZVAL_COPY_CTOR(return_value); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_DELREF(return_value); | |
+#else | |
return_value->refcount--; | |
+#endif | |
return return_value; | |
} else { | |
@@ -607,7 +621,11 @@ | |
member_copy = *member; | |
member = &member_copy; | |
zval_copy_ctor(member); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_SET_REFCOUNT_P(member, 1); | |
+#else | |
member->refcount = 1; | |
+#endif | |
convert_to_string(member); | |
} | |
@@ -680,7 +698,11 @@ | |
member_copy = *member; | |
member = &member_copy; | |
zval_copy_ctor(member); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_SET_REFCOUNT_P(member, 1); | |
+#else | |
member->refcount = 1; | |
+#endif | |
convert_to_string(member); | |
} | |
Index: runkit_import.c | |
=================================================================== | |
--- runkit_import.c (revision 292782) | |
+++ runkit_import.c (working copy) | |
@@ -126,7 +126,7 @@ | |
continue; | |
} | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_clean_children_methods, 4, scope, dce, fn, fn_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_clean_children_methods, 4, scope, dce, fn, fn_len); | |
if (zend_hash_del(&dce->function_table, fn, fn_len + 1) == FAILURE) { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error removing old method in destination class %s::%s", dce->name, fe->common.function_name); | |
zend_hash_move_forward_ex(&ce->function_table, &pos); | |
@@ -138,7 +138,7 @@ | |
#ifdef ZEND_ENGINE_2 | |
fe->common.scope = dce; | |
#endif | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_methods, 5, dce, dce, fe, fn, fn_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_methods, 5, dce, dce, fe, fn, fn_len); | |
if (zend_hash_add(&dce->function_table, fn, fn_len + 1, fe, sizeof(zend_function), NULL) == FAILURE) { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failure importing %s::%s()", ce->name, fe->common.function_name); | |
@@ -179,13 +179,13 @@ | |
goto import_const_skip; | |
} | |
} | |
- ZVAL_ADDREF(*c); | |
+ Z_ADDREF_P(*c); | |
if (zend_hash_add_or_update(&dce->constants_table, key, key_len, (void*)c, sizeof(zval*), NULL, action) == FAILURE) { | |
zval_ptr_dtor(c); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to import %s::%s", dce->name, key); | |
} | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_consts, 4, dce, c, key, key_len - 1); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_consts, 4, dce, c, key, key_len - 1); | |
} else { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Constant has invalid key name"); | |
} | |
@@ -227,7 +227,7 @@ | |
goto import_prop_skip; | |
} | |
} | |
- ZVAL_ADDREF(*p); | |
+ Z_ADDREF_P(*p); | |
if (zend_hash_add_or_update(&dce->default_properties, key, key_len, (void*)p, sizeof(zval*), NULL, action) == FAILURE) { | |
zval_ptr_dtor(p); | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to import %s->%s", dce->name, pname); | |
@@ -235,7 +235,7 @@ | |
if (!cname || strcmp(cname, "*") == 0) { | |
/* PUBLIC || PROTECTED */ | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_def_props, 4, dce, p, key, key_len - 1); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_def_props, 4, dce, p, key, key_len - 1); | |
} | |
} else { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property has invalid key name"); | |
Index: runkit_constants.c | |
=================================================================== | |
--- runkit_constants.c (revision 292782) | |
+++ runkit_constants.c (working copy) | |
@@ -68,10 +68,10 @@ | |
} | |
/* Process children of this child */ | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_consts, 4, ce, c, cname, cname_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_consts, 4, ce, c, cname, cname_len); | |
zend_hash_del(&ce->constants_table, cname, cname_len + 1); | |
- ZVAL_ADDREF(c); | |
+ Z_ADDREF_P(c); | |
if (zend_hash_add(&ce->constants_table, cname, cname_len + 1, c, sizeof(zval*), NULL) == FAILURE) { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error updating child class"); | |
return ZEND_HASH_APPLY_KEEP; | |
@@ -214,7 +214,7 @@ | |
return FAILURE; | |
} | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_consts, 4, ce, copyval, constname, constname_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_consts, 4, ce, copyval, constname, constname_len); | |
return SUCCESS; | |
#else | |
Index: runkit.c | |
=================================================================== | |
--- runkit.c (revision 292782) | |
+++ runkit.c (working copy) | |
@@ -382,7 +382,7 @@ | |
if (RUNKIT_G(replaced_internal_functions)) { | |
/* Restore internal functions */ | |
- zend_hash_apply_with_arguments(RUNKIT_G(replaced_internal_functions), php_runkit_restore_internal_functions, 1, RUNKIT_TSRMLS_C); | |
+ zend_hash_apply_with_arguments(RUNKIT_G(replaced_internal_functions) TSRMLS_CC, php_runkit_restore_internal_functions, 1, RUNKIT_TSRMLS_C); | |
zend_hash_destroy(RUNKIT_G(replaced_internal_functions)); | |
FREE_HASHTABLE(RUNKIT_G(replaced_internal_functions)); | |
RUNKIT_G(replaced_internal_functions) = NULL; | |
Index: php_runkit.h | |
=================================================================== | |
--- php_runkit.h (revision 292782) | |
+++ php_runkit.h (working copy) | |
@@ -147,8 +147,8 @@ | |
/* runkit_methods.c */ | |
int php_runkit_fetch_class(char *classname, int classname_len, zend_class_entry **pce TSRMLS_DC); | |
-int php_runkit_clean_children_methods(zend_class_entry *ce, int num_args, va_list args, zend_hash_key *hash_key); | |
-int php_runkit_update_children_methods(zend_class_entry *ce, int num_args, va_list args, zend_hash_key *hash_key); | |
+int php_runkit_clean_children_methods(zend_class_entry *ce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key); | |
+int php_runkit_update_children_methods(zend_class_entry *ce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key); | |
#ifdef ZEND_ENGINE_2 | |
int php_runkit_fetch_interface(char *classname, int classname_len, zend_class_entry **pce TSRMLS_DC); | |
#endif | |
@@ -166,7 +166,7 @@ | |
#define PHP_RUNKIT_HASH_EXISTS(hash,param) zend_u_hash_exists(hash, param##_type, (UChar *)param, param##_len + 1) | |
#define PHP_RUNKIT_HASH_KEY(hash_key) ((hash_key)->type == HASH_KEY_IS_UNICODE ? (hash_key)->u.unicode : (hash_key)->u.string) | |
#define PHP_RUNKIT_HASH_KEYLEN(hash_key) ((hash_key)->type == HASH_KEY_IS_UNICODE ? UBYTES((hash_key)->nKeyLength) : (hash_key)->nKeyLength) | |
- | |
+ | |
#elif PHP_MAJOR_VERSION >= 5 | |
#define PHP_RUNKIT_FUNCTION_ADD_REF(f) function_add_ref(f) | |
#define php_runkit_locate_scope(ce, fe, methodname, methodname_len) fe->common.scope | |
@@ -243,6 +243,7 @@ | |
}; | |
/* TODO: It'd be nice if objects and resources could make it across... */ | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
#define PHP_SANDBOX_CROSS_SCOPE_ZVAL_COPY_CTOR(pzv) \ | |
{ \ | |
switch (Z_TYPE_P(pzv)) { \ | |
@@ -255,7 +256,29 @@ | |
{ \ | |
HashTable *original_hashtable = Z_ARRVAL_P(pzv); \ | |
array_init(pzv); \ | |
- zend_hash_apply_with_arguments(original_hashtable, (apply_func_args_t)php_runkit_sandbox_array_deep_copy, 1, Z_ARRVAL_P(pzv) TSRMLS_CC); \ | |
+ zend_hash_apply_with_arguments(original_hashtable TSRMLS_CC, (apply_func_args_t)php_runkit_sandbox_array_deep_copy, 1, Z_ARRVAL_P(pzv) TSRMLS_CC); \ | |
+ break; \ | |
+ } \ | |
+ default: \ | |
+ zval_copy_ctor(pzv); \ | |
+ } \ | |
+ Z_SET_REFCOUNT_P(pzv, 1); \ | |
+ Z_UNSET_ISREF_P(pzv); \ | |
+} | |
+#else | |
+#define PHP_SANDBOX_CROSS_SCOPE_ZVAL_COPY_CTOR(pzv) \ | |
+{ \ | |
+ switch (Z_TYPE_P(pzv)) { \ | |
+ case IS_RESOURCE: \ | |
+ case IS_OBJECT: \ | |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to translate resource, or object variable to current context."); \ | |
+ ZVAL_NULL(pzv); \ | |
+ break; \ | |
+ case IS_ARRAY: \ | |
+ { \ | |
+ HashTable *original_hashtable = Z_ARRVAL_P(pzv); \ | |
+ array_init(pzv); \ | |
+ zend_hash_apply_with_arguments(original_hashtable TSRMLS_CC, (apply_func_args_t)php_runkit_sandbox_array_deep_copy, 1, Z_ARRVAL_P(pzv) TSRMLS_CC); \ | |
break; \ | |
} \ | |
default: \ | |
@@ -264,6 +287,7 @@ | |
(pzv)->refcount = 1; \ | |
(pzv)->is_ref = 0; \ | |
} | |
+#endif | |
#endif /* PHP_RUNKIT_SANDBOX */ | |
#ifdef PHP_RUNKIT_MANIPULATION | |
Index: runkit_classes.c | |
=================================================================== | |
--- runkit_classes.c (revision 292782) | |
+++ runkit_classes.c (working copy) | |
@@ -32,7 +32,7 @@ | |
return ZEND_HASH_APPLY_KEEP; | |
} | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, function_name, function_name_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_clean_children_methods, 4, ancestor_class, ce, function_name, function_name_len); | |
PHP_RUNKIT_DEL_MAGIC_METHOD(ce, fe); | |
@@ -79,7 +79,7 @@ | |
return ZEND_HASH_APPLY_KEEP; | |
} | |
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, fe, function_name, function_name_len); | |
+ zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, fe, function_name, function_name_len); | |
PHP_RUNKIT_FUNCTION_ADD_REF(fe); | |
Index: runkit_sandbox.c | |
=================================================================== | |
--- runkit_sandbox.c (revision 292782) | |
+++ runkit_sandbox.c (working copy) | |
@@ -356,7 +356,7 @@ | |
HashPosition pos; | |
zval **tmpzval; | |
- if (!zend_is_callable(func_name, IS_CALLABLE_CHECK_NO_ACCESS, &name)) { | |
+ if (!zend_is_callable(func_name, IS_CALLABLE_CHECK_NO_ACCESS, &name TSRMLS_CC)) { | |
php_error_docref1(NULL TSRMLS_CC, name, E_WARNING, "Function not defined"); | |
if (name) { | |
efree(name); | |
@@ -471,7 +471,7 @@ | |
op_array = zend_compile_file(&file_handle, type TSRMLS_CC); | |
zend_destroy_file_handle(&file_handle TSRMLS_CC); | |
} else { | |
- zend_file_handle_dtor(&file_handle); | |
+ zend_file_handle_dtor(&file_handle TSRMLS_CC); | |
RETVAL_TRUE; | |
already_included = 1; | |
} | |
@@ -730,7 +730,11 @@ | |
/* ZE expects refcount == 0 for unowned values */ | |
INIT_PZVAL(return_value); | |
PHP_SANDBOX_CROSS_SCOPE_ZVAL_COPY_CTOR(return_value); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_DELREF(return_value); | |
+#else | |
return_value->refcount--; | |
+#endif | |
return return_value; | |
} else { | |
@@ -803,7 +807,11 @@ | |
member_copy = *member; | |
member = &member_copy; | |
zval_copy_ctor(member); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_SET_REFCOUNT_P(member, 1); | |
+#else | |
member->refcount = 1; | |
+#endif | |
convert_to_string(member); | |
} | |
@@ -877,7 +885,11 @@ | |
member_copy = *member; | |
member = &member_copy; | |
zval_copy_ctor(member); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_SET_REFCOUNT_P(member, 1); | |
+#else | |
member->refcount = 1; | |
+#endif | |
convert_to_string(member); | |
} | |
@@ -925,7 +937,7 @@ | |
TSRMLS_FETCH(); | |
if (!objval->output_handler || | |
- !zend_is_callable(objval->output_handler, IS_CALLABLE_CHECK_NO_ACCESS, NULL)) { | |
+ !zend_is_callable(objval->output_handler, IS_CALLABLE_CHECK_NO_ACCESS, NULL TSRMLS_CC)) { | |
/* No hander, or invalid handler, pass up the line... */ | |
bytes_written = PHPWRITE(str, str_length); | |
@@ -987,7 +999,7 @@ | |
TSRMLS_FETCH(); | |
if (!objval->output_handler || | |
- !zend_is_callable(objval->output_handler, IS_CALLABLE_CHECK_NO_ACCESS, NULL)) { | |
+ !zend_is_callable(objval->output_handler, IS_CALLABLE_CHECK_NO_ACCESS, NULL TSRMLS_CC)) { | |
/* No hander, or invalid handler, pass up the line... */ | |
if (php_runkit_sandbox_original_sapi.flush) { | |
php_runkit_sandbox_original_sapi.flush(server_context); | |
@@ -1097,11 +1109,11 @@ | |
/* {{{ php_runkit_sandbox_sapi_header_handler | |
* Ignore headers when in a subrequest | |
*/ | |
-static int php_runkit_sandbox_sapi_header_handler(sapi_header_struct *sapi_header,sapi_headers_struct *sapi_headers TSRMLS_DC) | |
+static int php_runkit_sandbox_sapi_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers TSRMLS_DC) | |
{ | |
if (!RUNKIT_G(current_sandbox)) { | |
/* Not in a sandbox use SAPI's actual handler */ | |
- return php_runkit_sandbox_original_sapi.header_handler(sapi_header, sapi_headers TSRMLS_CC); | |
+ return php_runkit_sandbox_original_sapi.header_handler(sapi_header, op, sapi_headers TSRMLS_CC); | |
} | |
/* Otherwise ignore headers -- TODO: Provide a way for the calling scope to receive these a la output handler */ | |
@@ -1392,14 +1404,19 @@ | |
zval callback_copy = *callback; | |
zval_copy_ctor(&callback_copy); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_UNSET_ISREF(callback_copy); | |
+ Z_SET_REFCOUNT(callback_copy, 1); | |
+#else | |
callback_copy.is_ref = 0; | |
callback_copy.refcount = 1; | |
+#endif | |
callback_is_true = zval_is_true(&callback_copy); | |
zval_dtor(&callback_copy); | |
} | |
if (callback && callback_is_true && | |
- !zend_is_callable(callback, IS_CALLABLE_CHECK_NO_ACCESS, &name)) { | |
+ !zend_is_callable(callback, IS_CALLABLE_CHECK_NO_ACCESS, &name TSRMLS_CC)) { | |
php_error_docref1(NULL TSRMLS_CC, name, E_WARNING, "Second argument (%s) is expected to be a valid callback", name); | |
if (name) { | |
efree(name); | |
@@ -1413,8 +1430,13 @@ | |
if (objval->output_handler && return_value_used) { | |
*return_value = *objval->output_handler; | |
zval_copy_ctor(return_value); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_SET_REFCOUNT_P(return_value, 1); | |
+ Z_UNSET_ISREF_P(return_value); | |
+#else | |
return_value->refcount = 1; | |
return_value->is_ref = 0; | |
+#endif | |
} else { | |
RETVAL_FALSE; | |
} | |
@@ -1430,14 +1452,27 @@ | |
if (callback && callback_is_true) { | |
zval *cb = callback; | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ if (Z_ISREF_P(callback)) { | |
+#else | |
if (callback->is_ref) { | |
+#endif | |
MAKE_STD_ZVAL(cb); | |
*cb = *callback; | |
zval_copy_ctor(cb); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_SET_REFCOUNT_P(cb, 0); | |
+ Z_UNSET_ISREF_P(cb); | |
+#else | |
cb->refcount = 0; | |
cb->is_ref = 0; | |
+#endif | |
} | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_ADDREF_P(cb); | |
+#else | |
cb->refcount++; | |
+#endif | |
objval->output_handler = cb; | |
} | |
} | |
@@ -1463,6 +1498,21 @@ | |
convert_to_boolean(©val); \ | |
objval->name = Z_BVAL(copyval) ? 1 : 0; \ | |
} | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+#define PHP_RUNKIT_SANDBOX_SETTING_BOOL_RD(name) \ | |
+PHP_RUNKIT_SANDBOX_SETTING_GETTER(name) \ | |
+{ \ | |
+ zval *retval; \ | |
+\ | |
+ ALLOC_ZVAL(retval); \ | |
+ Z_TYPE_P(retval) = IS_BOOL; \ | |
+ Z_LVAL_P(retval) = objval->name; \ | |
+ Z_SET_REFCOUNT_P(retval, 0); \ | |
+ Z_UNSET_ISREF_P(retval); \ | |
+\ | |
+ return retval; \ | |
+} | |
+#else | |
#define PHP_RUNKIT_SANDBOX_SETTING_BOOL_RD(name) \ | |
PHP_RUNKIT_SANDBOX_SETTING_GETTER(name) \ | |
{ \ | |
@@ -1476,6 +1526,7 @@ | |
\ | |
return retval; \ | |
} | |
+#endif | |
#define PHP_RUNKIT_SANDBOX_SETTING_BOOL_RW(name) \ | |
PHP_RUNKIT_SANDBOX_SETTING_BOOL_WR(name) \ | |
PHP_RUNKIT_SANDBOX_SETTING_BOOL_RD(name) | |
@@ -1491,7 +1542,7 @@ | |
PHP_RUNKIT_SANDBOX_SETTING_SETTER(output_handler) | |
{ | |
- if (!zend_is_callable(value, IS_CALLABLE_CHECK_NO_ACCESS, NULL)) { | |
+ if (!zend_is_callable(value, IS_CALLABLE_CHECK_NO_ACCESS, NULL TSRMLS_CC)) { | |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "output_handler is not a valid callback is expected to be a valid callback"); | |
} | |
@@ -1499,7 +1550,11 @@ | |
zval_ptr_dtor(&objval->output_handler); | |
} | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_ADDREF(value); | |
+#else | |
value->refcount++; | |
+#endif | |
objval->output_handler = value; | |
} | |
@@ -1514,7 +1569,11 @@ | |
} else { | |
ZVAL_LONG(retval, objval->parent_scope); | |
} | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_SET_REFCOUNT_P(retval, 0); | |
+#else | |
retval->refcount = 0; | |
+#endif | |
return retval; | |
} | |
@@ -1620,7 +1679,11 @@ | |
member_copy = *member; | |
member = &member_copy; | |
zval_copy_ctor(member); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_SET_REFCOUNT_P(member, 1); | |
+#else | |
member->refcount = 1; | |
+#endif | |
convert_to_string(member); | |
} | |
@@ -1656,7 +1719,11 @@ | |
member_copy = *member; | |
member = &member_copy; | |
zval_copy_ctor(member); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_SET_REFCOUNT_P(member, 1); | |
+#else | |
member->refcount = 1; | |
+#endif | |
convert_to_string(member); | |
} | |
@@ -1692,7 +1759,11 @@ | |
member_copy = *member; | |
member = &member_copy | |
zval_copy_ctor(member); | |
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3) || (PHP_MAJOR_VERSION >= 6) | |
+ Z_SET_REFCOUNT_P(member, 1); | |
+#else | |
member->refcount = 1; | |
+#endif | |
convert_to_string(member); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment