Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#104 PHP5:$_SERVER, $_ENV and $_REQUEST is NULL in cached scripts

open
nobody
None
9
2004-08-13
2004-07-15
No

Perhaps its just me, but the superglobal $_REQUEST
isn't populated in a cached script.

I'm trying this with PHP 5.0.0 and Turck-MMCache
2.4.7-CVS on my SuSE 9.0-box atm. AFAIR it worked fine
with PHP 4.3.x and Turck-MMCache 2.4.6. I'm not sure
about PHP 4 with 2.4.7-CVS.

Discussion

    • summary: $_REQUEST is null in cached scripts (PHP 5 with 2.4.7-CVS) --> $_REQUEST is NULL in cached scripts (PHP 5 with 2.4.7-CVS)
     
    • priority: 5 --> 9
     
  • tmgh141242
    tmgh141242
    2004-07-15

    Logged In: YES
    user_id=774892

    i meet the same problem.i find the codes:
    static char* build_key(const char* key, int key_len, int *xlen
    TSRMLS_DC) {
    int len = strlen(MMCG(hostname));
    if (len > 0) {
    char* xkey;
    *xlen = len + key_len + 1;
    xkey = emalloc((*xlen)+1);
    memcpy(xkey, MMCG(hostname), len);
    xkey[len] = ':';
    memcpy(xkey+len+1, key, key_len+1);
    return xkey;
    } else {
    *xlen = key_len;
    return (char*)key;
    }
    }
    when i use php5 the hostname cannot be get.
    maybe someone can tell me how to fix it.

     
  • tmgh141242
    tmgh141242
    2004-07-15

    Logged In: YES
    user_id=774892

    i have solved this problem:
    set register_long_arrays = On in php.ini and mmcache works
    great!
    windows2003+php5+apache2.0.51-dev

     
  • Xuefer
    Xuefer
    2004-07-15

    Logged In: YES
    user_id=185131

    ever tested without mmcache?

     
  • tmgh141242
    tmgh141242
    2004-07-15

    Logged In: YES
    user_id=774892

    without mmcache and register_long_arrays = Off,php5 works
    right.maybe someone can fix this bug for mmcache.

     
  • Logged In: YES
    user_id=802198

    This bug is obviously related to
    http://bugs.php.net/bug.php?id=29176.

    xuefer wrote:
    > ever tested without mmcache?
    Yep, it worked fine, then.

    tmgh141242 wrote:
    > i have solved this problem:
    > set register_long_arrays = On in php.ini and mmcache works
    > great!
    That did it. Thanks for that workaround :-)

     
  • Xuefer
    Xuefer
    2004-07-16

    Logged In: YES
    user_id=185131

    try:
    register_long_arrays=Off
    auto_global_jit=Off

    if it's ok
    to fix this bug for mmcache would require mmcache "touch"
    $_SERVER and other JustInTime auto global variables

    the jit seems done in Zend compiling time, not executing time
    but mmcache cached opcodes, witout triggering jit.
    any other opcode cacher will have same problem if it hasn't
    take care of this php5 performance feature

     
  • Xuefer
    Xuefer
    2004-07-16

    Logged In: YES
    user_id=185131

    try:
    register_long_arrays=Off
    auto_global_jit=Off

    if it's ok
    to fix this bug for mmcache would require mmcache "touch"
    $_SERVER and other JustInTime auto global variables

    the jit seems done in Zend compiling time, not executing time
    but mmcache cached opcodes, witout triggering jit.
    any other opcode cacher will have same problem if it hasn't
    take care of this php5 performance feature

     
  • Xuefer
    Xuefer
    2004-07-16

    Logged In: YES
    user_id=185131

    erh? i and my browser didn't post twice -_-

     
  • tmgh141242
    tmgh141242
    2004-07-16

    Logged In: YES
    user_id=774892

    register_long_arrays=Off
    auto_global_jit=Off
    the same problem occured!

     
  • tmgh141242
    tmgh141242
    2004-07-16

    Logged In: YES
    user_id=774892

    php_variables.c:
    void php_startup_auto_globals(TSRMLS_D)
    {
    zend_register_auto_global("_GET", sizeof("_GET")-1,
    NULL TSRMLS_CC);
    zend_register_auto_global("_POST", sizeof("_POST")-
    1, NULL TSRMLS_CC);
    zend_register_auto_global("_COOKIE", sizeof
    ("_COOKIE")-1, NULL TSRMLS_CC);
    zend_register_auto_global("_SERVER", sizeof
    ("_SERVER")-1, php_auto_globals_create_server TSRMLS_CC);
    zend_register_auto_global("_ENV", sizeof("_ENV")-1,
    php_auto_globals_create_env TSRMLS_CC);
    zend_register_auto_global("_REQUEST", sizeof
    ("_REQUEST")-1, php_auto_globals_create_request
    TSRMLS_CC);
    zend_register_auto_global("_FILES", sizeof("_FILES")-
    1, NULL TSRMLS_CC);
    }
    but the
    php_auto_globals_create_server ,php_auto_globals_create_en
    v ,php_auto_globals_create_request are related to
    register_long_arrays.below is php_auto_globals_create_server:
    static zend_bool php_auto_globals_create_server(char
    *name, uint name_len TSRMLS_DC)
    {
    php_register_server_variables(TSRMLS_C);

    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++;

    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++;
    }

    return 0; /* don't rearm */
    }

    how to fix mmcache.c?i don't know.maybe someone can do it.

     
  • tmgh141242
    tmgh141242
    2004-07-16

    Logged In: YES
    user_id=774892

    so if set register_long_arrays=off,there seems no way to get
    $_SERVER,$_ENV,$_REQUEST.but the
    $_COOKIE,$_POST,$_GET and $_FILES can be got rightly.
    it seems to be php5's one thing.

     
  • Xuefer
    Xuefer
    2004-07-16

    Logged In: YES
    user_id=185131

    seens not true
    jit=just in time creating the auto global array
    when u have $_REQUEST in your script, Zend/compile.c will
    trigger the jit

    zend_bool jit_initialization = (PG(auto_globals_jit) && !PG
    (register_globals) && !PG(register_long_arrays) && !PG
    (register_argc_argv));

    forgive my mistake
    it's auto_globals_jit
    not auto_global_jit

     
  • tmgh141242
    tmgh141242
    2004-07-16

    Logged In: YES
    user_id=774892

    yes!it works perfect!
    can you tell me why php5 set auto_globals_jit=1?
    thanks very much.

     
  • Xuefer
    Xuefer
    2004-07-16

    Logged In: YES
    user_id=185131

    it's not "why it set"
    it's a new feature for performance
    most(some?) script don't need those variables

     
    • summary: $_REQUEST is NULL in cached scripts (PHP 5 with 2.4.7-CVS) --> PHP5:$_SERVER, $_ENV and $_REQUEST is NULL in cached scripts
     
  • Logged In: YES
    user_id=802198

    Can't a workaround be coded, when auto_globals_jit is turned
    on? Perhaps by triggering the jit right before a request to
    $_REQUEST, $_ENV or $_SERVER?

    > most(some?) script don't need those variables
    Well, at least phpMyAdmin and any other script using
    HTTP_AUTH would fail and vBulletin (very popular) is using
    $_SERVER and especially $_REQUEST scriptwide.

     
  • tmgh141242
    tmgh141242
    2004-08-18

    Logged In: YES
    user_id=774892

    yes,i think this also:"Well, at least phpMyAdmin and any other
    script using
    HTTP_AUTH would fail and vBulletin (very popular) is using
    $_SERVER and especially $_REQUEST scriptwide."

     
  • Logged In: NO

    this is only the case when register_long_arrays is off