Skip to content

Commit da7d94c

Browse files
committed
Merge branch 'PHP-5.6'
Conflicts: ext/soap/soap.c ext/standard/basic_functions.c ext/zlib/zlib.c
2 parents 5e7fd50 + adc4265 commit da7d94c

File tree

9 files changed

+25
-29
lines changed

9 files changed

+25
-29
lines changed

Zend/zend_compile.c

+14
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,7 @@ static zend_bool zend_try_ct_eval_class_const(zval *zv, zend_string *class_name,
12291229

12301230
return 0;
12311231
}
1232+
/* }}} */
12321233

12331234
void zend_init_list(void *result, void *item) /* {{{ */
12341235
{
@@ -1309,6 +1310,19 @@ void zend_do_extended_fcall_end(void) /* {{{ */
13091310
}
13101311
/* }}} */
13111312

1313+
zend_bool zend_is_auto_global_str(char *name, size_t len) /* {{{ */ {
1314+
zend_auto_global *auto_global;
1315+
1316+
if ((auto_global = zend_hash_str_find_ptr(CG(auto_globals), name, len)) != NULL) {
1317+
if (auto_global->armed) {
1318+
auto_global->armed = auto_global->auto_global_callback(auto_global->name);
1319+
}
1320+
return 1;
1321+
}
1322+
return 0;
1323+
}
1324+
/* }}} */
1325+
13121326
zend_bool zend_is_auto_global(zend_string *name) /* {{{ */
13131327
{
13141328
zend_auto_global *auto_global;

Zend/zend_compile.h

+1
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ typedef struct _zend_auto_global {
730730
ZEND_API int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback);
731731
ZEND_API void zend_activate_auto_globals(void);
732732
ZEND_API zend_bool zend_is_auto_global(zend_string *name);
733+
ZEND_API zend_bool zend_is_auto_global_str(char *name, size_t len);
733734
ZEND_API size_t zend_dirname(char *path, size_t len);
734735

735736
int zendlex(zend_parser_stack_elem *elem);

ext/filter/filter.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -534,17 +534,13 @@ static zval *php_filter_get_storage(zend_long arg)/* {{{ */
534534
break;
535535
case PARSE_SERVER:
536536
if (PG(auto_globals_jit)) {
537-
zend_string *name = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
538-
zend_is_auto_global(name);
539-
zend_string_release(name);
537+
zend_is_auto_global_str(ZEND_STRL("_SERVER"));
540538
}
541539
array_ptr = &IF_G(server_array);
542540
break;
543541
case PARSE_ENV:
544542
if (PG(auto_globals_jit)) {
545-
zend_string *name = zend_string_init("_ENV", sizeof("_ENV") - 1, 0);
546-
zend_is_auto_global(name);
547-
zend_string_release(name);
543+
zend_is_auto_global_str(ZEND_STRL("_ENV"));
548544
}
549545
array_ptr = &IF_G(env_array) ? &IF_G(env_array) : &PG(http_globals)[TRACK_VARS_ENV];
550546
break;

ext/soap/soap.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,7 @@ PHP_METHOD(SoapServer, handle)
15681568
if (SG(request_info).request_body && 0 == php_stream_rewind(SG(request_info).request_body)) {
15691569
zval *server_vars, *encoding;
15701570
php_stream_filter *zf = NULL;
1571-
zend_string *server = zend_string_init("_SERVER", sizeof("_SERVER")-1, 0);
1571+
zend_string *server = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
15721572

15731573
zend_is_auto_global(server);
15741574
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
20892089

20902090
xmlDocDumpMemory(doc_return, &buf, &size);
20912091

2092-
server = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
2093-
zend_is_auto_global(server);
2094-
if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF &&
2092+
if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) &&
20952093
(agent_name = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT")-1)) != NULL &&
20962094
Z_TYPE_P(agent_name) == IS_STRING) {
20972095
if (strncmp(Z_STRVAL_P(agent_name), "Shockwave Flash", sizeof("Shockwave Flash")-1) == 0) {

ext/standard/basic_functions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4229,7 +4229,7 @@ PHP_FUNCTION(getopt)
42294229
/* Get argv from the global symbol table. We calculate argc ourselves
42304230
* in order to be on the safe side, even though it is also available
42314231
* from the symbol table. */
4232-
if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF &&
4232+
if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) &&
42334233
((args = zend_hash_str_find_ind(HASH_OF(&PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv")-1)) != NULL ||
42344234
(args = zend_hash_str_find_ind(&EG(symbol_table).ht, "argv", sizeof("argv")-1)) != NULL)
42354235
) {

ext/standard/browscap.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,8 @@ PHP_FUNCTION(get_browser)
462462
}
463463

464464
if (agent_name == NULL) {
465-
zend_string *key = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
466-
zend_is_auto_global(key);
467-
zend_string_release(key);
468-
if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF ||
469-
(http_user_agent = zend_hash_str_find(HASH_OF(&PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT")-1)) == NULL
465+
if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) ||
466+
(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
470467
) {
471468
php_error_docref(NULL, E_WARNING, "HTTP_USER_AGENT variable is not set, cannot determine user agent name");
472469
RETURN_FALSE;

ext/zlib/zlib.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ static int php_zlib_output_encoding(void)
8282
zval *enc;
8383

8484
if (!ZLIBG(compression_coding)) {
85-
zend_string *name = zend_string_init("_SERVER", sizeof("_SERVER") - 1, 0);
86-
zend_is_auto_global(name);
87-
zend_string_release(name);
88-
if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY &&
85+
if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) &&
8986
(enc = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_ACCEPT_ENCODING", sizeof("HTTP_ACCEPT_ENCODING") - 1))) {
9087
convert_to_string(enc);
9188
if (strstr(Z_STRVAL_P(enc), "gzip")) {

sapi/cli/php_cli.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,6 @@ static int do_cli(int argc, char **argv) /* {{{ */
661661
int lineno = 0;
662662
const char *param_error=NULL;
663663
int hide_argv = 0;
664-
zend_string *key;
665664

666665
zend_try {
667666

@@ -965,9 +964,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
965964
}
966965
}
967966

968-
key = zend_string_init("_SERVER", sizeof("_SERVER")-1, 0);
969-
zend_is_auto_global(key);
970-
zend_string_release(key);
967+
zend_is_auto_global_str(ZEND_STRL("_SERVER"));
971968

972969
PG(during_request_startup) = 0;
973970
switch (behavior) {

sapi/phpdbg/phpdbg_utils.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -516,11 +516,7 @@ PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable
516516
}
517517

518518
int phpdbg_is_auto_global(char *name, int len) {
519-
int ret;
520-
zend_string *str = zend_string_init(name, len, 0);
521-
ret = zend_is_auto_global(str);
522-
efree(str);
523-
return ret;
519+
return zend_is_auto_global_str(name, len);
524520
}
525521

526522
static int phpdbg_xml_array_element_dump(zval *zv, zend_string *key, zend_ulong num) {

0 commit comments

Comments
 (0)