diff options
-rw-r--r-- | Zend/zend_compile.c | 14 | ||||
-rw-r--r-- | Zend/zend_compile.h | 1 | ||||
-rw-r--r-- | ext/filter/filter.c | 8 | ||||
-rw-r--r-- | ext/soap/soap.c | 6 | ||||
-rw-r--r-- | ext/standard/basic_functions.c | 2 | ||||
-rw-r--r-- | ext/standard/browscap.c | 7 | ||||
-rw-r--r-- | ext/zlib/zlib.c | 5 | ||||
-rw-r--r-- | sapi/cli/php_cli.c | 5 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_utils.c | 6 |
9 files changed, 25 insertions, 29 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 90c7ec34b3..c9b67021f0 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1229,6 +1229,7 @@ static zend_bool zend_try_ct_eval_class_const(zval *zv, zend_string *class_name, return 0; } +/* }}} */ void zend_init_list(void *result, void *item) /* {{{ */ { @@ -1309,6 +1310,19 @@ void zend_do_extended_fcall_end(void) /* {{{ */ } /* }}} */ +zend_bool zend_is_auto_global_str(char *name, size_t len) /* {{{ */ { + zend_auto_global *auto_global; + + if ((auto_global = zend_hash_str_find_ptr(CG(auto_globals), name, len)) != NULL) { + if (auto_global->armed) { + auto_global->armed = auto_global->auto_global_callback(auto_global->name); + } + return 1; + } + return 0; +} +/* }}} */ + zend_bool zend_is_auto_global(zend_string *name) /* {{{ */ { zend_auto_global *auto_global; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 1104a29b82..0a4c146d28 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -730,6 +730,7 @@ typedef struct _zend_auto_global { ZEND_API int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback); ZEND_API void zend_activate_auto_globals(void); ZEND_API zend_bool zend_is_auto_global(zend_string *name); +ZEND_API zend_bool zend_is_auto_global_str(char *name, size_t len); ZEND_API size_t zend_dirname(char *path, size_t len); int zendlex(zend_parser_stack_elem *elem); diff --git a/ext/filter/filter.c b/ext/filter/filter.c index 85cfbf0913..9e2613257e 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -534,17 +534,13 @@ static zval *php_filter_get_storage(zend_long arg)/* {{{ */ break; case PARSE_SERVER: if (PG(auto_globals_jit)) { - zend_string *name = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0); - zend_is_auto_global(name); - zend_string_release(name); + zend_is_auto_global_str(ZEND_STRL("_SERVER")); } array_ptr = &IF_G(server_array); break; case PARSE_ENV: if (PG(auto_globals_jit)) { - zend_string *name = zend_string_init("_ENV", sizeof("_ENV") - 1, 0); - zend_is_auto_global(name); - zend_string_release(name); + zend_is_auto_global_str(ZEND_STRL("_ENV")); } array_ptr = &IF_G(env_array) ? &IF_G(env_array) : &PG(http_globals)[TRACK_VARS_ENV]; break; diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 4308f3885f..6792c325ac 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1568,7 +1568,7 @@ PHP_METHOD(SoapServer, handle) if (SG(request_info).request_body && 0 == php_stream_rewind(SG(request_info).request_body)) { zval *server_vars, *encoding; php_stream_filter *zf = NULL; - zend_string *server = zend_string_init("_SERVER", sizeof("_SERVER")-1, 0); + zend_string *server = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0); zend_is_auto_global(server); if ((server_vars = zend_hash_find(&EG(symbol_table).ht, server)) != NULL && @@ -2089,9 +2089,7 @@ static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeade xmlDocDumpMemory(doc_return, &buf, &size); - server = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0); - zend_is_auto_global(server); - if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF && + if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) && (agent_name = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT")-1)) != NULL && Z_TYPE_P(agent_name) == IS_STRING) { if (strncmp(Z_STRVAL_P(agent_name), "Shockwave Flash", sizeof("Shockwave Flash")-1) == 0) { diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 940c9e4141..dcd054fadb 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4229,7 +4229,7 @@ PHP_FUNCTION(getopt) /* Get argv from the global symbol table. We calculate argc ourselves * in order to be on the safe side, even though it is also available * from the symbol table. */ - if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF && + if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) && ((args = zend_hash_str_find_ind(HASH_OF(&PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv")-1)) != NULL || (args = zend_hash_str_find_ind(&EG(symbol_table).ht, "argv", sizeof("argv")-1)) != NULL) ) { diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index e88a09e883..217437ba8f 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -462,11 +462,8 @@ PHP_FUNCTION(get_browser) } if (agent_name == NULL) { - zend_string *key = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0); - zend_is_auto_global(key); - zend_string_release(key); - if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF || - (http_user_agent = zend_hash_str_find(HASH_OF(&PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT")-1)) == NULL + if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) || + (http_user_agent = zend_hash_str_find(Z_ARRVAL_P(&PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT")-1)) == NULL ) { php_error_docref(NULL, E_WARNING, "HTTP_USER_AGENT variable is not set, cannot determine user agent name"); RETURN_FALSE; diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 0b082048c0..67e67b114e 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -82,10 +82,7 @@ static int php_zlib_output_encoding(void) zval *enc; if (!ZLIBG(compression_coding)) { - zend_string *name = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0); - zend_is_auto_global(name); - zend_string_release(name); - if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && + if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) && (enc = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_ACCEPT_ENCODING", sizeof("HTTP_ACCEPT_ENCODING") - 1))) { convert_to_string(enc); if (strstr(Z_STRVAL_P(enc), "gzip")) { diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index ca0ea57fa7..8a8e113db0 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -661,7 +661,6 @@ static int do_cli(int argc, char **argv) /* {{{ */ int lineno = 0; const char *param_error=NULL; int hide_argv = 0; - zend_string *key; zend_try { @@ -965,9 +964,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ } } - key = zend_string_init("_SERVER", sizeof("_SERVER")-1, 0); - zend_is_auto_global(key); - zend_string_release(key); + zend_is_auto_global_str(ZEND_STRL("_SERVER")); PG(during_request_startup) = 0; switch (behavior) { diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c index 357905fa06..ecec950c1b 100644 --- a/sapi/phpdbg/phpdbg_utils.c +++ b/sapi/phpdbg/phpdbg_utils.c @@ -516,11 +516,7 @@ PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable } int phpdbg_is_auto_global(char *name, int len) { - int ret; - zend_string *str = zend_string_init(name, len, 0); - ret = zend_is_auto_global(str); - efree(str); - return ret; + return zend_is_auto_global_str(name, len); } static int phpdbg_xml_array_element_dump(zval *zv, zend_string *key, zend_ulong num) { |