summaryrefslogtreecommitdiff
path: root/main/php_variables.c
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2010-02-07 22:19:53 +0100
committerSean Finney <seanius@debian.org>2010-02-07 22:27:07 +0100
commitc852c28a88fccf6e34a2cb091fdfa72bce2b59c7 (patch)
tree91f01b0d06916c78262404096bfd466b8e95e5b5 /main/php_variables.c
parent176cbd0bc99e20bb21f92f0b72df728eafc1e2ce (diff)
parent0fab6db7cac8d2be99579dd049f812a8ff98e74f (diff)
downloadphp-c852c28a88fccf6e34a2cb091fdfa72bce2b59c7.tar.gz
Merge branch 'upstream-experimental' into upstream-sid
Diffstat (limited to 'main/php_variables.c')
-rw-r--r--main/php_variables.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/main/php_variables.c b/main/php_variables.c
index c74409587..83b6a94dd 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_variables.c 272374 2008-12-31 11:17:49Z sebastian $ */
+/* $Id: php_variables.c 272370 2008-12-31 11:15:49Z sebastian $ */
#include <stdio.h>
#include "php.h"
@@ -69,10 +69,13 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
HashTable *symtable1 = NULL;
assert(var_name != NULL);
-
+
if (track_vars_array) {
symtable1 = Z_ARRVAL_P(track_vars_array);
} else if (PG(register_globals)) {
+ if (!EG(active_symbol_table)) {
+ zend_rebuild_symbol_table(TSRMLS_C);
+ }
symtable1 = EG(active_symbol_table);
}
if (!symtable1) {
@@ -135,11 +138,12 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
if (track_vars_array) {
ht = Z_ARRVAL_P(track_vars_array);
+ zend_hash_del(ht, var, var_len + 1);
} else if (PG(register_globals)) {
ht = EG(active_symbol_table);
+ zend_hash_del(ht, var, var_len + 1);
}
- zend_hash_del(ht, var, var_len + 1);
zval_dtor(val);
/* do not output the error message to the screen,
@@ -523,14 +527,14 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
Z_TYPE_P(argc) = IS_LONG;
if (PG(register_globals) || SG(request_info).argc) {
- arr->refcount++;
- argc->refcount++;
+ Z_ADDREF_P(arr);
+ Z_ADDREF_P(argc);
zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL);
zend_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL);
}
if (track_vars_array) {
- arr->refcount++;
- argc->refcount++;
+ Z_ADDREF_P(arr);
+ Z_ADDREF_P(argc);
zend_hash_update(Z_ARRVAL_P(track_vars_array), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL);
zend_hash_update(Z_ARRVAL_P(track_vars_array), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL);
}
@@ -619,13 +623,13 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC)
|| (key_type == HASH_KEY_IS_LONG && zend_hash_index_find(dest, num_key, (void **)&dest_entry) != SUCCESS)
|| Z_TYPE_PP(dest_entry) != IS_ARRAY
) {
- (*src_entry)->refcount++;
+ Z_ADDREF_PP(src_entry);
if (key_type == HASH_KEY_IS_STRING) {
/* if register_globals is on and working with main symbol table, prevent overwriting of GLOBALS */
if (!globals_check || string_key_len != sizeof("GLOBALS") || memcmp(string_key, "GLOBALS", sizeof("GLOBALS") - 1)) {
zend_hash_update(dest, string_key, string_key_len, src_entry, sizeof(zval *), NULL);
} else {
- (*src_entry)->refcount--;
+ Z_DELREF_PP(src_entry);
}
} else {
zend_hash_index_update(dest, num_key, src_entry, sizeof(zval *), NULL);
@@ -744,11 +748,11 @@ int php_hash_environment(TSRMLS_D)
INIT_PZVAL(PG(http_globals)[i]);
}
- PG(http_globals)[i]->refcount++;
+ Z_ADDREF_P(PG(http_globals)[i]);
zend_hash_update(&EG(symbol_table), auto_global_records[i].name, auto_global_records[i].name_len, &PG(http_globals)[i], sizeof(zval *), NULL);
if (PG(register_long_arrays)) {
zend_hash_update(&EG(symbol_table), auto_global_records[i].long_name, auto_global_records[i].long_name_len, &PG(http_globals)[i], sizeof(zval *), NULL);
- PG(http_globals)[i]->refcount++;
+ Z_ADDREF_P(PG(http_globals)[i]);
}
}
@@ -773,8 +777,8 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS
if (zend_hash_find(&EG(symbol_table), "argc", sizeof("argc"), (void**)&argc) == SUCCESS &&
zend_hash_find(&EG(symbol_table), "argv", sizeof("argv"), (void**)&argv) == SUCCESS) {
- (*argc)->refcount++;
- (*argv)->refcount++;
+ Z_ADDREF_PP(argc);
+ Z_ADDREF_PP(argv);
zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"), argv, sizeof(zval *), NULL);
zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argc", sizeof("argc"), argc, sizeof(zval *), NULL);
}
@@ -795,11 +799,11 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS
}
zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL);
- PG(http_globals)[TRACK_VARS_SERVER]->refcount++;
+ Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]);
if (PG(register_long_arrays)) {
zend_hash_update(&EG(symbol_table), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL);
- PG(http_globals)[TRACK_VARS_SERVER]->refcount++;
+ Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]);
}
return 0; /* don't rearm */
@@ -821,11 +825,11 @@ static zend_bool php_auto_globals_create_env(char *name, uint name_len TSRMLS_DC
}
zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL);
- PG(http_globals)[TRACK_VARS_ENV]->refcount++;
+ Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]);
if (PG(register_long_arrays)) {
zend_hash_update(&EG(symbol_table), "HTTP_ENV_VARS", sizeof("HTTP_ENV_VARS"), &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL);
- PG(http_globals)[TRACK_VARS_ENV]->refcount++;
+ Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]);
}
return 0; /* don't rearm */
@@ -841,7 +845,13 @@ static zend_bool php_auto_globals_create_request(char *name, uint name_len TSRML
array_init(form_variables);
INIT_PZVAL(form_variables);
- for (p = PG(variables_order); p && *p; p++) {
+ if(PG(request_order) != NULL) {
+ p = PG(request_order);
+ } else {
+ p = PG(variables_order);
+ }
+
+ for (; p && *p; p++) {
switch (*p) {
case 'g':
case 'G':