Browse Source

Removed register_long_arrays ini option (and $HTTP_SESSION_VARS from ext/session)

experimental/lemon
Kalle Sommer Nielsen 16 years ago
parent
commit
a5304b138f
  1. 1
      NEWS
  2. 8
      Zend/tests/unset_cv05.phpt
  3. 2
      ext/filter/filter.c
  4. 15
      ext/session/session.c
  5. 15
      ext/session/tests/007.phpt
  6. 14
      ext/session/tests/008-php4.2.3.phpt
  7. 20
      ext/session/tests/009.phpt
  8. 5
      main/main.c
  9. 1
      main/php_globals.h
  10. 30
      main/php_variables.c
  11. 19
      php.ini-development
  12. 19
      php.ini-production

1
NEWS

@ -19,6 +19,7 @@
- Removed legacy features: (Kalle)
. define_syslog_variables ini option and its associated function.
. register_long_arrays ini option.
. y2k_compliance ini option.
?? ??? 20??, PHP 5.3.3

8
Zend/tests/unset_cv05.phpt

@ -1,7 +1,6 @@
--TEST--
unset() CV 5 (indirect unset() of global variable in session_start())
--INI--
register_long_arrays=1
session.auto_start=0
session.save_handler=files
--SKIPIF--
@ -12,14 +11,13 @@ include(dirname(__FILE__).'/../../ext/session/tests/skipif.inc');
?>
--FILE--
<?php
$HTTP_SESSION_VARS = "ok\n";
echo $HTTP_SESSION_VARS;
$_SESSION = "ok\n";
echo $_SESSION;
session_start();
echo $HTTP_SESSION_VARS;
echo $_SESSION;
echo "\nok\n";
?>
--EXPECTF--
Warning: Directive 'register_long_arrays' is deprecated in PHP %d.%d and greater in Unknown on line 0
ok
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at %sunset_cv05.php on line %d

2
ext/filter/filter.c

@ -537,7 +537,7 @@ static zval *php_filter_get_storage(long arg TSRMLS_DC)/* {{{ */
{
zval *array_ptr = NULL;
zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays));
zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals));
switch (arg) {
case PARSE_GET:

15
ext/session/session.c

@ -235,8 +235,7 @@ static void php_session_track_init(TSRMLS_D) /* {{{ */
{
zval *session_vars = NULL;
/* Unconditionally destroy existing arrays -- possible dirty data */
zend_delete_global_variable("HTTP_SESSION_VARS", sizeof("HTTP_SESSION_VARS")-1 TSRMLS_CC);
/* Unconditionally destroy existing array -- possible dirty data */
zend_delete_global_variable("_SESSION", sizeof("_SESSION")-1 TSRMLS_CC);
if (PS(http_session_vars)) {
@ -247,13 +246,7 @@ static void php_session_track_init(TSRMLS_D) /* {{{ */
array_init(session_vars);
PS(http_session_vars) = session_vars;
if (PG(register_long_arrays)) {
ZEND_SET_GLOBAL_VAR_WITH_LENGTH("HTTP_SESSION_VARS", sizeof("HTTP_SESSION_VARS"), PS(http_session_vars), 3, 1);
ZEND_SET_GLOBAL_VAR_WITH_LENGTH("_SESSION", sizeof("_SESSION"), PS(http_session_vars), 3, 1);
}
else {
ZEND_SET_GLOBAL_VAR_WITH_LENGTH("_SESSION", sizeof("_SESSION"), PS(http_session_vars), 2, 1);
}
ZEND_SET_GLOBAL_VAR_WITH_LENGTH("_SESSION", sizeof("_SESSION"), PS(http_session_vars), 2, 1);
}
/* }}} */
@ -1814,9 +1807,7 @@ static void php_register_var(zval** entry TSRMLS_DC)
} else {
convert_to_string_ex(entry);
if ((strcmp(Z_STRVAL_PP(entry), "HTTP_SESSION_VARS") != 0) &&
(strcmp(Z_STRVAL_PP(entry), "_SESSION") != 0)
) {
if (strcmp(Z_STRVAL_PP(entry), "_SESSION") != 0) {
PS_ADD_VARL(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry));
}
}

15
ext/session/tests/007.phpt

@ -3,7 +3,6 @@ bug compatibility: unset($c) with enabled register_globals
--SKIPIF--
<?php include('skipif.inc'); ?>
--INI--
register_long_arrays=1
session.use_cookies=0
session.cache_limiter=
register_globals=1
@ -21,39 +20,37 @@ session_id("abtest");
session_start();
session_destroy();
### Phase 2 $HTTP_SESSION_VARS["c"] does not contain any value
### Phase 2 $_SESSION["c"] does not contain any value
session_id("abtest");
session_register("c");
unset($c);
$c = 3.14;
session_write_close();
unset($HTTP_SESSION_VARS);
unset($_SESSION);
unset($c);
### Phase 3 $HTTP_SESSION_VARS["c"] is set
### Phase 3 $_SESSION["c"] is set
session_start();
var_dump($c);
var_dump($HTTP_SESSION_VARS);
var_dump($_SESSION);
unset($c);
$c = 2.78;
session_write_close();
unset($HTTP_SESSION_VARS);
unset($_SESSION);
unset($c);
### Phase 4 final
session_start();
var_dump($c);
var_dump($HTTP_SESSION_VARS);
var_dump($_SESSION);
session_destroy();
?>
--EXPECTF--
Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
Warning: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
Deprecated: Function session_register() is deprecated in %s on line %d
float(3.14)
array(1) {

14
ext/session/tests/008-php4.2.3.phpt

@ -5,7 +5,6 @@ bug compatibility: global is used albeit register_globals=0
if (version_compare(PHP_VERSION,"4.2.3-dev", "<")) die("skip this is for PHP >= 4.2.3");
?>
--INI--
register_long_arrays=1
session.use_cookies=0
session.cache_limiter=
register_globals=0
@ -27,7 +26,7 @@ session_id("abtest");
session_start();
session_destroy();
### Phase 2 $HTTP_SESSION_VARS["c"] does not contain any value
### Phase 2 $_SESSION["c"] does not contain any value
session_id("abtest");
session_register("c");
var_dump($c);
@ -36,29 +35,28 @@ $c = 3.14;
@session_write_close(); // this generates an E_WARNING which will be printed
// by $php_errormsg so we can use "@" here. ANY further message IS an error.
echo $php_errormsg."\n";
unset($HTTP_SESSION_VARS);
unset($_SESSION);
unset($c);
### Phase 3 $HTTP_SESSION_VARS["c"] is set
### Phase 3 $_SESSION["c"] is set
session_start();
var_dump($HTTP_SESSION_VARS);
var_dump($_SESSION);
unset($c);
$c = 2.78;
session_write_close();
unset($HTTP_SESSION_VARS);
unset($_SESSION);
unset($c);
### Phase 4 final
session_start();
var_dump($c);
var_dump($HTTP_SESSION_VARS);
var_dump($_SESSION);
session_destroy();
?>
--EXPECTF--
Warning: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
NULL
session_write_close(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively
array(1) {

20
ext/session/tests/009.phpt

@ -3,7 +3,6 @@ unset($_SESSION["name"]); should work with register_globals=off
--SKIPIF--
<?php include('skipif.inc'); ?>
--INI--
register_long_arrays=1
session.use_cookies=0
session.cache_limiter=
register_globals=0
@ -21,29 +20,28 @@ session_id("abtest");
session_start();
session_destroy();
### Phase 2 $HTTP_SESSION_VARS["c"] does not contain any value
### Phase 2 $_SESSION["c"] does not contain any value
session_id("abtest");
session_start();
var_dump($HTTP_SESSION_VARS);
$HTTP_SESSION_VARS["name"] = "foo";
var_dump($HTTP_SESSION_VARS);
var_dump($_SESSION);
$_SESSION["name"] = "foo";
var_dump($_SESSION);
session_write_close();
### Phase 3 $HTTP_SESSION_VARS["c"] is set
### Phase 3 $_SESSION["c"] is set
session_start();
var_dump($HTTP_SESSION_VARS);
unset($HTTP_SESSION_VARS["name"]);
var_dump($HTTP_SESSION_VARS);
var_dump($_SESSION);
unset($_SESSION["name"]);
var_dump($_SESSION);
session_write_close();
### Phase 4 final
session_start();
var_dump($HTTP_SESSION_VARS);
var_dump($_SESSION);
session_destroy();
?>
--EXPECT--
Warning: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
array(0) {
}
array(1) {

5
main/main.c

@ -459,7 +459,6 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("output_handler", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateString, output_handler, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("register_globals", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_globals, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("register_long_arrays", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_long_arrays, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("auto_globals_jit", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, auto_globals_jit, php_core_globals, core_globals)
#if PHP_SAFE_MODE
STD_PHP_INI_BOOLEAN("safe_mode", "1", PHP_INI_SYSTEM, OnUpdateBool, safe_mode, php_core_globals, core_globals)
@ -2056,14 +2055,13 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
struct {
const long error_level;
const char *phrase;
const char *directives[7]; /* Remember to change this if the number of directives change */
const char *directives[6]; /* Remember to change this if the number of directives change */
} directives[] = {
{
E_CORE_WARNING,
"Directive '%s' is deprecated in PHP 5.3 and greater",
{
"register_globals",
"register_long_arrays",
"safe_mode",
"magic_quotes_gpc",
"magic_quotes_runtime",
@ -2076,6 +2074,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
"Directive '%s' is no longer available in PHP",
{
"define_syslog_variables",
"register_long_arrays",
"zend.ze1_compatibility_mode",
NULL
}

1
main/php_globals.h

@ -123,7 +123,6 @@ struct _php_core_globals {
zend_bool expose_php;
zend_bool register_globals;
zend_bool register_long_arrays;
zend_bool register_argc_argv;
zend_bool auto_globals_jit;

30
main/php_variables.c

@ -653,20 +653,18 @@ int php_hash_environment(TSRMLS_D)
{
char *p;
unsigned char _gpc_flags[5] = {0, 0, 0, 0, 0};
zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays));
zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals));
struct auto_global_record {
char *name;
uint name_len;
char *long_name;
uint long_name_len;
zend_bool jit_initialization;
} auto_global_records[] = {
{ "_POST", sizeof("_POST"), "HTTP_POST_VARS", sizeof("HTTP_POST_VARS"), 0 },
{ "_GET", sizeof("_GET"), "HTTP_GET_VARS", sizeof("HTTP_GET_VARS"), 0 },
{ "_COOKIE", sizeof("_COOKIE"), "HTTP_COOKIE_VARS", sizeof("HTTP_COOKIE_VARS"), 0 },
{ "_SERVER", sizeof("_SERVER"), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), 1 },
{ "_ENV", sizeof("_ENV"), "HTTP_ENV_VARS", sizeof("HTTP_ENV_VARS"), 1 },
{ "_FILES", sizeof("_FILES"), "HTTP_POST_FILES", sizeof("HTTP_POST_FILES"), 0 },
{ "_POST", sizeof("_POST"), 0 },
{ "_GET", sizeof("_GET"), 0 },
{ "_COOKIE", sizeof("_COOKIE"), 0 },
{ "_SERVER", sizeof("_SERVER"), 1 },
{ "_ENV", sizeof("_ENV"), 1 },
{ "_FILES", sizeof("_FILES"), 0 },
};
size_t num_track_vars = sizeof(auto_global_records)/sizeof(struct auto_global_record);
size_t i;
@ -750,10 +748,6 @@ int php_hash_environment(TSRMLS_D)
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);
Z_ADDREF_P(PG(http_globals)[i]);
}
}
/* Create _REQUEST */
@ -800,11 +794,6 @@ 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);
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);
Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]);
}
return 0; /* don't rearm */
}
@ -827,11 +816,6 @@ 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);
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);
Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]);
}
return 0; /* don't rearm */
}

19
php.ini-development

@ -141,11 +141,6 @@
; Development Value: Off
; Production Value: Off
; register_long_arrays
; Default Value: On
; Development Value: Off
; Production Value: Off
; request_order
; Default Value: None
; Development Value: "GP"
@ -686,16 +681,6 @@ request_order = "GP"
; http://php.net/register-globals
register_globals = Off
; Determines whether the deprecated long $HTTP_*_VARS type predefined variables
; are registered by PHP or not. As they are deprecated, we obviously don't
; recommend you use them. They are on by default for compatibility reasons but
; they are not recommended on production servers.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/register-long-arrays
register_long_arrays = Off
; This directive determines whether PHP registers $argv & $argc each time it
; runs. $argv contains an array of all the arguments passed to PHP when a script
; is invoked. $argc contains an integer representing the number of arguments
@ -714,8 +699,8 @@ register_argc_argv = Off
; When enabled, the SERVER and ENV variables are created when they're first
; used (Just In Time) instead of when the script starts. If these variables
; are not used within a script, having this directive on will result in a
; performance gain. The PHP directives register_globals, register_long_arrays,
; and register_argc_argv must be disabled for this directive to have any affect.
; performance gain. The PHP directives register_globals and register_argc_argv
; must be disabled for this directive to have any affect.
; http://php.net/auto-globals-jit
auto_globals_jit = On

19
php.ini-production

@ -141,11 +141,6 @@
; Development Value: Off
; Production Value: Off
; register_long_arrays
; Default Value: On
; Development Value: Off
; Production Value: Off
; request_order
; Default Value: None
; Development Value: "GP"
@ -686,16 +681,6 @@ request_order = "GP"
; http://php.net/register-globals
register_globals = Off
; Determines whether the deprecated long $HTTP_*_VARS type predefined variables
; are registered by PHP or not. As they are deprecated, we obviously don't
; recommend you use them. They are on by default for compatibility reasons but
; they are not recommended on production servers.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/register-long-arrays
register_long_arrays = Off
; This directive determines whether PHP registers $argv & $argc each time it
; runs. $argv contains an array of all the arguments passed to PHP when a script
; is invoked. $argc contains an integer representing the number of arguments
@ -714,8 +699,8 @@ register_argc_argv = Off
; When enabled, the SERVER and ENV variables are created when they're first
; used (Just In Time) instead of when the script starts. If these variables
; are not used within a script, having this directive on will result in a
; performance gain. The PHP directives register_globals, register_long_arrays,
; and register_argc_argv must be disabled for this directive to have any affect.
; performance gain. The PHP directives register_globals and register_argc_argv
; must be disabled for this directive to have any affect.
; http://php.net/auto-globals-jit
auto_globals_jit = On

Loading…
Cancel
Save