# filter_input and auto_globals_jit

- Thread: https://externals.io/message/74434
- Original archive: https://news-web.php.net/php.internals/74434
- Started by Gary Mort on 2014-05-22T21:01:42+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #74434 — Gary Mort — 2014-05-22T21:01:42+00:00

URL: https://externals.io/message/74434#74434

Here is an oddity which I'm not sure how this is supposed to work.

If you have auto_globals_jit enables then not only are super global 
variables not initialized unless they are called, the underlying data 
storage for the original data[used by filter_input] will not be populated.

As I read filter.c, there seems to be a weird schism on how it deals 
with this.
https://github.com/php/php-src/blob/master/ext/filter/filter.c#L526

For `INPUT_SERVER` and `INPUT_ENV` it seems as if filter will make sure to 
initialize the data, example:
	if (PG(auto_globals_jit)) {
				zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
			}

For INPUT_POST, INPUT_GET, and `INPUT_COOKIE` however there is no safety net.

For example, with Just in Time:
test.php?var=test

$before = filter_input(INPUT_GET);  // $before = null
$var = $_GET('test'); 		// $var = 'test'
$after = filter_input(INPUT_GET);	// $after = 'test'


So the question is, is this by design?  In which case I'll update the 
docs.  Or is this an oversight?  In which case I'll open a bug and 
submit a patch.

---

## #74435 — keisial@gmail.com — 2014-05-22T21:28:01+00:00

URL: https://externals.io/message/74434#74435 · In reply to: #74434

> Here is an oddity which I'm not sure how this is supposed to work.
>
> If you have auto_globals_jit enables then not only are super global 
> variables not initialized unless they are called, the underlying data 
> storage for the original data[used by filter_input] will not be 
> populated.

> So the question is, is this by design?  In which case I'll update the 
> docs.  Or is this an oversight?  In which case I'll open a bug and 
> submit a patch.
Looks like a bug. After all, filter_input *is* using the variables.

---

## #74703 — Ferenc Kovacs — 2014-06-03T07:46:19+00:00

URL: https://externals.io/message/74434#74703 · In reply to: #74434

> Here is an oddity which I'm not sure how this is supposed to work.
>
> If you have auto_globals_jit enables then not only are super global
> variables not initialized unless they are called, the underlying data
> storage for the original data[used by filter_input] will not be populated.
>
> As I read filter.c, there seems to be a weird schism on how it deals with
> this.
> https://github.com/php/php-src/blob/master/ext/filter/filter.c#L526
>
> For `INPUT_SERVER` and `INPUT_ENV` it seems as if filter will make sure to
> initialize the data, example:
>         if (PG(auto_globals_jit)) {
>                                 zend_is_auto_global("_SERVER",
> sizeof("_SERVER")-1 TSRMLS_CC);
>                         }
>
> For INPUT_POST, INPUT_GET, and `INPUT_COOKIE` however there is no safety net.
>
> For example, with Just in Time:
> test.php?var=test
>
> $before = filter_input(INPUT_GET);  // $before = null
> $var = $_GET('test');           // $var = 'test'
> $after = filter_input(INPUT_GET);       // $after = 'test'
>
>
> So the question is, is this by design?  In which case I'll update the
> docs.  Or is this an oversight?  In which case I'll open a bug and submit a
> patch.
>
>
> --
> 
> 
>
>
could you fill a bug at https://bugs.php.net/ ?

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu
