php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #66218
Patch reflection.patch revision 2013-12-02 16:02 UTC by remi@php.net
revision 2013-12-02 14:13 UTC by remi@php.net
revision 2013-12-02 13:34 UTC by remi
Patch ReflectionExtension_bug66218.phpt revision 2013-12-02 14:41 UTC by remi@php.net
Patch bug66218.phpt revision 2013-12-02 13:42 UTC by remi@php.net

Patch reflection.patch for Reflection related Bug #66218

Patch version 2013-12-02 14:13 UTC

Return to Bug #66218 | Download this patch
This patch is obsolete

Obsoleted by patches:

This patch renders other patches obsolete

Obsolete patches:

Patch Revisions: 2013-12-02 16:02 UTC | 2013-12-02 14:13 UTC | 2013-12-02 13:34 UTC

Developer: remi@php.net



  diff -up php-5.5.7RC1/ext/reflection/php_reflection.c.prev php-5.5.7RC1/ext/reflection/php_reflection.c
  --- php-5.5.7RC1/ext/reflection/php_reflection.c.prev	2013-12-02 14:32:21.349858888 +0100
 +++ php-5.5.7RC1/ext/reflection/php_reflection.c	2013-12-02 14:14:55.649633295 +0100
 @@ -1105,29 +1105,25 @@ static void _extension_string(string *st
 +++ php-5.5.7RC1/ext/reflection/php_reflection.c	2013-12-02 15:11:13.073610775 +0100
 @@ -1105,29 +1105,26 @@ static void _extension_string(string *st
   		string_free(&str_constants);
   	}
   
  -	if (module->functions && module->functions->fname) {
 -		zend_function *fptr;
 +	{
 +		HashPosition iterator;
  		zend_function *fptr;
  -		const zend_function_entry *func = module->functions;
  -
  -		string_printf(str, "\n  - Functions {\n");
 -
 +		int first = 1;
  
  -		/* Is there a better way of doing this? */
  -		while (func->fname) {
  -			int fname_len = strlen(func->fname);
  -			char *lc_name = zend_str_tolower_dup(func->fname, fname_len);
Line 20 (now 23), was 21 lines, now 17 lines

  -				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Internal error: Cannot find extension function %s in global function table", func->fname);
  -				func++;
  -				efree(lc_name);
  -				continue;
 +	{
 +		HashPosition iterator;
 +		zend_internal_function *fptr;
 +		int first = 1;
 +
  +		zend_hash_internal_pointer_reset_ex(CG(function_table), &iterator);
  +		while (zend_hash_get_current_data_ex(CG(function_table), (void **) &fptr, &iterator) == SUCCESS) {
 +			if (fptr->module == module) {
 +			if (fptr->common.type==ZEND_INTERNAL_FUNCTION
 +				&& fptr->internal_function.module == module) {
  +				if (first) {
  +					string_printf(str, "\n  - Functions {\n");
  +					first = 0;
  +				}
 +				_function_string(str, (zend_function *)fptr, NULL, "    " TSRMLS_CC);
 +				_function_string(str, fptr, NULL, "    " TSRMLS_CC);
   			}
  -
  -			_function_string(str, fptr, NULL, "    " TSRMLS_CC);
  -			efree(lc_name);


  -		string_printf(str, "%s  }\n", indent);
   	}
   
   	{
 @@ -5264,6 +5260,9 @@ ZEND_METHOD(reflection_extension, getFun
 @@ -5264,6 +5261,9 @@ ZEND_METHOD(reflection_extension, getFun
   {
   	reflection_object *intern;
   	zend_module_entry *module;
  +	HashPosition iterator;
  +	zval *function;
 +	zend_internal_function *fptr;
 +	zend_function *fptr;
   
   	if (zend_parse_parameters_none() == FAILURE) {
   		return;
 @@ -5271,29 +5270,14 @@ ZEND_METHOD(reflection_extension, getFun
 @@ -5271,29 +5271,15 @@ ZEND_METHOD(reflection_extension, getFun
   	GET_REFLECTION_OBJECT_PTR(module);
   
   	array_init(return_value);
  -	if (module->functions) {


  -			}
  -
  +	zend_hash_internal_pointer_reset_ex(CG(function_table), &iterator);
  +	while (zend_hash_get_current_data_ex(CG(function_table), (void **) &fptr, &iterator) == SUCCESS) {
 +		if (fptr->module == module) {
 +		if (fptr->common.type==ZEND_INTERNAL_FUNCTION
 +			&& fptr->internal_function.module == module) {
   			ALLOC_ZVAL(function);
 -			reflection_function_factory(fptr, NULL, function TSRMLS_CC);
  			reflection_function_factory(fptr, NULL, function TSRMLS_CC);
  -			add_assoc_zval_ex(return_value, func->fname, fname_len+1, function);
  -			func++;
  -			efree(lc_name);
 +			reflection_function_factory((zend_function *)fptr, NULL, function TSRMLS_CC);
 +			add_assoc_zval(return_value, fptr->function_name, function);
 +			add_assoc_zval(return_value, fptr->common.function_name, function);
   		}
  +		zend_hash_move_forward_ex(CG(function_table), &iterator);
   	}
   }
   /* }}} */
  diff -up php-5.5.7RC1/Zend/zend_builtin_functions.c.prev php-5.5.7RC1/Zend/zend_builtin_functions.c
  --- php-5.5.7RC1/Zend/zend_builtin_functions.c.prev	2013-12-02 11:29:44.399427824 +0100
 +++ php-5.5.7RC1/Zend/zend_builtin_functions.c	2013-12-02 13:29:17.345953312 +0100
 @@ -2442,36 +2442,48 @@ ZEND_FUNCTION(extension_loaded)
 +++ php-5.5.7RC1/Zend/zend_builtin_functions.c	2013-12-02 15:08:21.889226383 +0100
 @@ -2442,36 +2442,49 @@ ZEND_FUNCTION(extension_loaded)
      Returns an array with the names of functions belonging to the named extension */
   ZEND_FUNCTION(get_extension_funcs)
   {
  -	char *extension_name;


   	zend_module_entry *module;
  -	const zend_function_entry *func;
  -
  +	HashPosition iterator;
 +	zend_internal_function *zif;
 +	zend_function *zif;
   	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &extension_name, &extension_name_len) == FAILURE) {
   		return;
   	}
  -


  -		func = builtin_functions;
  +		array = 0;
  +	}
  +	while (zend_hash_get_current_data_ex(CG(function_table), (void **) &zif, &iterator) == SUCCESS) {
 +		if (zif->module == module) {
 +		if (zif->common.type==ZEND_INTERNAL_FUNCTION
 +			&& zif->internal_function.module == module) {
  +			if (!array) {
  +				array_init(return_value);
  +				array = 1;
  +			}
 +			add_next_index_string(return_value, zif->function_name, 1);
 +			add_next_index_string(return_value, zif->common.function_name, 1);
  +		}
  +		zend_hash_move_forward_ex(CG(function_table), &iterator);
   	}
   
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 21:01:29 2024 UTC