FAQ
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.

Search Discussions

  • Ángel González at May 22, 2014 at 9:28 pm

    On 22/05/14 23:01, Gary Mort wrote:
    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.
  • Ferenc Kovacs at Jun 3, 2014 at 7:46 am

    On Thu, May 22, 2014 at 11:01 PM, Gary Mort wrote:

    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.


    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
    could you fill a bug at https://bugs.php.net/ ?

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedMay 22, '14 at 9:01p
activeJun 3, '14 at 7:46a
posts3
users3
websitephp.net

People

Translate

site design / logo © 2022 Grokbase