Skip to content

Commit febee11

Browse files
committed
Removed register_globals
1 parent bae9248 commit febee11

45 files changed

Lines changed: 122 additions & 447 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

INSTALL

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -716,14 +716,6 @@ CGI environment and recommended modifications in php.ini
716716
the web server not from the administration server. Use the command
717717
line as root user and start it manually - you will see there are no
718718
CGI-like environment variables.
719-
720-
Simply change your scripts to get CGI variables in the correct way for
721-
PHP 4.x by using the superglobal $_SERVER. If you have older scripts
722-
which use $HTTP_HOST, etc., you should turn on register_globals in
723-
php.ini and change the variable order too (important: remove "E" from
724-
it, because you do not need the environment here):
725-
variables_order = "GPCS"
726-
register_globals = On
727719
__________________________________________________________________
728720

729721
Special use for error pages or self-made directory listings (PHP >= 4.3.3)
@@ -1532,7 +1524,7 @@ The configuration file
15321524
; Boolean values can be set to either:
15331525
; true, on, yes
15341526
; or false, off, no, none
1535-
register_globals = off
1527+
html_errors = off
15361528
track_errors = yes
15371529

15381530
; you can enclose strings in double-quotes

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
time are allocated in a single copy and never changed. (Dmitry)
1313
- Added an optimization which saves memory and emalloc/efree calls for empty
1414
HashTables (Stas, Dmitry)
15+
1516
- Added Tokyo Cabinet abstract DB support to ext/dba. (Michael Maclean)
1617
- Added Jenkins's one-at-a-time hash support to ext/hash. (Martin Jansen)
1718
- Added FNV-1 hash support to ext/hash. (Michael Maclean)
@@ -30,6 +31,7 @@
3031

3132
- Removed legacy features: (Kalle)
3233
. define_syslog_variables ini option and its associated function.
34+
. register_globals.
3335
. register_long_arrays ini option.
3436
. y2k_compliance ini option.
3537

README.input_filter

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ A simple implementation might look like the following. This stores the
1919
original raw user data and adds a my_get_raw() function while the normal
2020
$_POST, $_GET and $_COOKIE arrays are only populated with stripped
2121
data. In this simple example all I am doing is calling strip_tags() on
22-
the data. If register_globals is turned on, the default globals that
23-
are created will be stripped ($foo) while a $RAW_foo is created with the
24-
original user input.
22+
the data.
2523

2624
ZEND_BEGIN_MODULE_GLOBALS(my_input_filter)
2725
zval *post_array;
@@ -155,8 +153,6 @@ PHP_FUNCTION(my_get_raw)
155153
int var_len;
156154
zval **tmp;
157155
zval *array_ptr = NULL;
158-
HashTable *hash_ptr;
159-
char *raw_var;
160156

161157
if(zend_parse_parameters(2 TSRMLS_CC, "ls", &arg, &var, &var_len) == FAILURE) {
162158
return;
@@ -174,23 +170,15 @@ PHP_FUNCTION(my_get_raw)
174170
break;
175171
}
176172

177-
if(!array_ptr) RETURN_FALSE;
178-
179-
/*
180-
* I'm changing the variable name here because when running with register_globals on,
181-
* the variable will end up in the global symbol table
182-
*/
183-
raw_var = emalloc(var_len+5); /* RAW_ and a \0 */
184-
strcpy(raw_var, "RAW_");
185-
strlcat(raw_var,var,var_len+5);
186-
hash_ptr = HASH_OF(array_ptr);
173+
if(!array_ptr) {
174+
RETURN_FALSE;
175+
}
187176

188-
if(zend_hash_find(hash_ptr, raw_var, var_len+5, (void **)&tmp) == SUCCESS) {
177+
if(zend_hash_find(HASH_OF(array_ptr), var, var_len+5, (void **)&tmp) == SUCCESS) {
189178
*return_value = **tmp;
190179
zval_copy_ctor(return_value);
191180
} else {
192181
RETVAL_FALSE;
193182
}
194-
efree(raw_var);
195183
}
196184

Zend/tests/unset_cv06.phpt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,20 @@ unset() CV 6 (indirect unset() of global variable in session_unset())
33
--SKIPIF--
44
<?php include(dirname(__FILE__).'/../../ext/session/tests/skipif.inc'); ?>
55
--INI--
6-
register_globals=1
76
session.auto_start=0
87
session.save_handler=files
98
--FILE--
109
<?php
11-
$x = "1\n";
1210
session_start();
13-
echo $x;
14-
session_register('x');
15-
$_SESSION['x'] = "2\n";
16-
echo $x;
11+
$_SESSION['x'] = "1\n";
12+
echo $_SESSION['x'];
13+
1714
session_unset();
18-
echo $x;
15+
echo $_SESSION['x'];
1916
echo "ok\n";
2017
?>
2118
--EXPECTF--
22-
Warning: Directive 'register_globals' is deprecated in PHP %d.%d and greater in Unknown on line 0
2319
1
2420

25-
Deprecated: Function session_register() is deprecated in %s on line %d
26-
2
27-
28-
Notice: Undefined variable: x in %sunset_cv06.php on line %d
21+
Notice: Undefined index: x in %sunset_cv06.php on line %d
2922
ok

ext/filter/filter.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,6 @@ static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int
450450
orig_var = estrdup(var);
451451

452452
/* Store the RAW variable internally */
453-
/* FIXME: Should not use php_register_variable_ex as that also registers
454-
* globals when register_globals is turned on */
455453
Z_STRLEN(raw_var) = val_len;
456454
Z_STRVAL(raw_var) = estrndup(*val, val_len);
457455
Z_TYPE(raw_var) = IS_STRING;
@@ -461,8 +459,6 @@ static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int
461459

462460
if (val_len) {
463461
/* Register mangled variable */
464-
/* FIXME: Should not use php_register_variable_ex as that also registers
465-
* globals when register_globals is turned on */
466462
Z_STRLEN(new_var) = val_len;
467463
Z_TYPE(new_var) = IS_STRING;
468464

@@ -537,7 +533,6 @@ static zval *php_filter_get_storage(long arg TSRMLS_DC)/* {{{ */
537533

538534
{
539535
zval *array_ptr = NULL;
540-
zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals));
541536

542537
switch (arg) {
543538
case PARSE_GET:
@@ -550,13 +545,13 @@ static zval *php_filter_get_storage(long arg TSRMLS_DC)/* {{{ */
550545
array_ptr = IF_G(cookie_array);
551546
break;
552547
case PARSE_SERVER:
553-
if (jit_initialization) {
548+
if (PG(auto_globals_jit)) {
554549
zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
555550
}
556551
array_ptr = IF_G(server_array);
557552
break;
558553
case PARSE_ENV:
559-
if (jit_initialization) {
554+
if (PG(auto_globals_jit)) {
560555
zend_is_auto_global("_ENV", sizeof("_ENV")-1 TSRMLS_CC);
561556
}
562557
array_ptr = IF_G(env_array);

ext/mbstring/mb_gpc.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ MBSTRING_API SAPI_TREAT_DATA_FUNC(mbstr_treat_data)
151151

152152
info.data_type = arg;
153153
info.separator = separator;
154-
info.force_register_globals = 0;
155154
info.report_errors = 0;
156155
info.to_encoding = MBSTRG(internal_encoding);
157156
info.to_language = MBSTRG(language);
@@ -210,13 +209,6 @@ enum mbfl_no_encoding _php_mb_encoding_handler_ex(const php_mb_encoding_handler_
210209
mbfl_string_init_set(&resvar, info->to_language, info->to_encoding);
211210
mbfl_string_init_set(&resval, info->to_language, info->to_encoding);
212211

213-
/* register_globals stuff
214-
* XXX: this feature is going to be deprecated? */
215-
216-
if (info->force_register_globals && !(prev_rg_state = PG(register_globals))) {
217-
zend_alter_ini_entry("register_globals", sizeof("register_globals"), "1", sizeof("1")-1, PHP_INI_PERDIR, PHP_INI_STAGE_RUNTIME);
218-
}
219-
220212
if (!res || *res == '\0') {
221213
goto out;
222214
}
@@ -346,11 +338,6 @@ enum mbfl_no_encoding _php_mb_encoding_handler_ex(const php_mb_encoding_handler_
346338
}
347339

348340
out:
349-
/* register_global stuff */
350-
if (info->force_register_globals && !prev_rg_state) {
351-
zend_alter_ini_entry("register_globals", sizeof("register_globals"), "0", sizeof("0")-1, PHP_INI_PERDIR, PHP_INI_STAGE_RUNTIME);
352-
}
353-
354341
if (convd != NULL) {
355342
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
356343
mbfl_buffer_converter_delete(convd);
@@ -376,7 +363,6 @@ SAPI_POST_HANDLER_FUNC(php_mb_post_handler)
376363

377364
info.data_type = PARSE_POST;
378365
info.separator = "&";
379-
info.force_register_globals = 0;
380366
info.report_errors = 0;
381367
info.to_encoding = MBSTRG(internal_encoding);
382368
info.to_language = MBSTRG(language);

ext/mbstring/mb_gpc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
typedef struct _php_mb_encoding_handler_info_t {
3333
int data_type;
3434
const char *separator;
35-
unsigned int force_register_globals: 1;
3635
unsigned int report_errors: 1;
3736
enum mbfl_no_language to_language;
3837
enum mbfl_no_encoding to_encoding;

ext/mbstring/mbstring.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,6 @@ PHP_FUNCTION(mb_parse_str)
18961896

18971897
info.data_type = PARSE_STRING;
18981898
info.separator = PG(arg_separator).input;
1899-
info.force_register_globals = (track_vars_array == NULL);
19001899
info.report_errors = 1;
19011900
info.to_encoding = MBSTRG(current_internal_encoding);
19021901
info.to_language = MBSTRG(language);

ext/mbstring/tests/mb_parse_str.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ mb_parse_str()
44
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
55
--INI--
66
arg_separator.input=&
7-
register_globals=0
87
--FILE--
98
<?php
109
$queries = array(

ext/mbstring/tests/mb_parse_str02.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ mb_parse_str() test 2
44
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
55
--INI--
66
arg_separator.input=&#
7-
register_globals=0
87
--FILE--
98
<?php
109
$queries = array(

0 commit comments

Comments
 (0)