zeev Sun Mar 2 08:35:01 2003 EDT Modified files: /php4/ext/standard info.c /php4/main php_variables.c Log: - Optimize $_REQUEST - Fix phpinfo() Index: php4/ext/standard/info.c diff -u php4/ext/standard/info.c:1.227 php4/ext/standard/info.c:1.228 --- php4/ext/standard/info.c:1.227 Sun Feb 2 13:50:42 2003 +++ php4/ext/standard/info.c Sun Mar 2 08:35:01 2003 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: info.c,v 1.227 2003/02/02 18:50:42 sebastian Exp $ */ +/* $Id: info.c,v 1.228 2003/03/02 13:35:01 zeev Exp $ */ #include "php.h" #include "php_ini.h" @@ -98,6 +98,8 @@ uint string_len; ulong num_key; char *elem_esc = NULL; + + zend_is_auto_global(name, name_length TSRMLS_CC); if (zend_hash_find(&EG(symbol_table), name, name_length+1, (void **) &data)!=FAILURE && (Z_TYPE_PP(data)==IS_ARRAY)) { Index: php4/main/php_variables.c diff -u php4/main/php_variables.c:1.52 php4/main/php_variables.c:1.53 --- php4/main/php_variables.c:1.52 Sun Mar 2 05:19:15 2003 +++ php4/main/php_variables.c Sun Mar 2 08:35:01 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_variables.c,v 1.52 2003/03/02 10:19:15 zeev Exp $ */ +/* $Id: php_variables.c,v 1.53 2003/03/02 13:35:01 zeev Exp $ */ #include <stdio.h> #include "php.h" @@ -492,7 +492,7 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS_DC); static zend_bool php_auto_globals_create_env(char *name, uint name_len TSRMLS_DC); - +static zend_bool php_auto_globals_create_request(char *name, uint name_len TSRMLS_DC); /* {{{ php_hash_environment */ @@ -503,7 +503,6 @@ zend_bool have_variables_order; zval *dummy_track_vars_array = NULL; zend_bool initialized_dummy_track_vars_array=0; - int i; zend_bool jit_initialization = (!PG(register_globals) && !PG(register_long_arrays)); char *variables_order; struct auto_global_record { @@ -521,7 +520,9 @@ { "_FILES", sizeof("_FILES"), "HTTP_FILES_GLOBALS", sizeof("HTTP_FILES_GLOBALS"), 0 }, }; size_t num_track_vars = sizeof(auto_global_records)/sizeof(struct auto_global_record); + size_t i; + /* jit_initialization = 0; */ for (i=0; i<num_track_vars; i++) { PG(http_globals)[i] = NULL; } @@ -614,31 +615,8 @@ } /* Create _REQUEST */ - { - zval *form_variables; - - ALLOC_ZVAL(form_variables); - array_init(form_variables); - INIT_PZVAL(form_variables); - - for (p=variables_order; p && *p; p++) { - switch (*p) { - case 'g': - case 'G': - zend_hash_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_GET]), (void (*)(void *pData)) zval_add_ref, NULL, sizeof(zval *), 1); - break; - case 'p': - case 'P': - zend_hash_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_POST]), (void (*)(void *pData)) zval_add_ref, NULL, sizeof(zval *), 1); - break; - case 'c': - case 'C': - zend_hash_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_COOKIE]), (void (*)(void *pData)) zval_add_ref, NULL, sizeof(zval *), 1); - break; - } - } - - zend_hash_update(&EG(symbol_table), "_REQUEST", sizeof("_REQUEST"), &form_variables, sizeof(zval *), NULL); + if (!jit_initialization) { + php_auto_globals_create_request("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC); } return SUCCESS; @@ -681,16 +659,55 @@ } +static zend_bool php_auto_globals_create_request(char *name, uint name_len TSRMLS_DC) +{ + zval *form_variables; + char *variables_order; + char *p; + + if (PG(variables_order)) { + variables_order = PG(variables_order); + } else { + variables_order = PG(gpc_order); + } + + ALLOC_ZVAL(form_variables); + array_init(form_variables); + INIT_PZVAL(form_variables); + + for (p=variables_order; p && *p; p++) { + switch (*p) { + case 'g': + case 'G': + zend_hash_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_GET]), (void (*)(void *pData)) zval_add_ref, NULL, sizeof(zval *), 1); + break; + case 'p': + case 'P': + zend_hash_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_POST]), (void (*)(void *pData)) zval_add_ref, NULL, sizeof(zval *), 1); + break; + case 'c': + case 'C': + zend_hash_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_COOKIE]), (void (*)(void *pData)) zval_add_ref, NULL, sizeof(zval *), 1); + break; + } + } + + zend_hash_update(&EG(symbol_table), "_REQUEST", sizeof("_REQUEST"), &form_variables, sizeof(zval *), NULL); + return 0; +} + + void php_startup_auto_globals(TSRMLS_D) { zend_bool cb = (!PG(register_globals) && !PG(register_long_arrays)); + /*cb = 0;*/ zend_register_auto_global("_GET", sizeof("_GET")-1, NULL TSRMLS_CC); zend_register_auto_global("_POST", sizeof("_POST")-1, NULL TSRMLS_CC); zend_register_auto_global("_COOKIE", sizeof("_COOKIE")-1, NULL TSRMLS_CC); zend_register_auto_global("_SERVER", sizeof("_SERVER")-1, cb?php_auto_globals_create_server:NULL TSRMLS_CC); zend_register_auto_global("_ENV", sizeof("_ENV")-1, cb?php_auto_globals_create_env:NULL TSRMLS_CC); - zend_register_auto_global("_REQUEST", sizeof("_REQUEST")-1, NULL TSRMLS_CC); + zend_register_auto_global("_REQUEST", sizeof("_REQUEST")-1, cb?php_auto_globals_create_request:NULL TSRMLS_CC); } /*
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php