# $_SERVER registration issue

- Thread: https://externals.io/message/77
- Original archive: https://news-web.php.net/php.internals/77
- Started by Andrei Zmievski on 2003-03-17T21:51:21+00:00
- Messages: 6
- 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

---

## #78 — Sterling Hughes — 2003-03-17T21:41:52+00:00

URL: https://externals.io/message/77#78 · In reply to: #77

> Today I tried to run PHP-GTK with ZE2 changes against current CVS and it
> segfaulted. I traced it to the fact that
> PG(http_globals)[TRACK_SERVER_VARS] is no longer available if $_SERVER
> is not present in the PHP code, due to the changes Zeev (I think) made
> in order to improve efficiency. I don't quite agree with the way it
> works right now. My extension needs access to the $_SERVER['argv'] and
> $_SERVER['argc'] variables internally, even if the user code doesn't.
> How am I supposed to retrieve those variable if they aren't even
> registered?
> 

We should add internal constructors for accessing these variables.

-Sterling

> -Andrei                                       http://www.gravitonic.com/
> * "UNIX, isn't that some archaic form of DOS?" - our job applicant *
-- 
"First they ignore you, then they laugh at you,  
 then they fight you, then you win."  
    - Gandhi

---

## #79 — Sterling Hughes — 2003-03-17T21:42:03+00:00

URL: https://externals.io/message/77#79 · In reply to: #77

> Today I tried to run PHP-GTK with ZE2 changes against current CVS and it
> segfaulted. I traced it to the fact that
> PG(http_globals)[TRACK_SERVER_VARS] is no longer available if $_SERVER
> is not present in the PHP code, due to the changes Zeev (I think) made
> in order to improve efficiency. I don't quite agree with the way it
> works right now. My extension needs access to the $_SERVER['argv'] and
> $_SERVER['argc'] variables internally, even if the user code doesn't.
> How am I supposed to retrieve those variable if they aren't even
> registered?
> 

We should add internal constructors for accessing these variables.

-Sterling

> -Andrei                                       http://www.gravitonic.com/
> * "UNIX, isn't that some archaic form of DOS?" - our job applicant *
-- 
"First they ignore you, then they laugh at you,  
 then they fight you, then you win."  
    - Gandhi

---

## #77 — Andrei Zmievski — 2003-03-17T21:51:21+00:00

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

Today I tried to run PHP-GTK with ZE2 changes against current CVS and it
segfaulted. I traced it to the fact that
PG(http_globals)[TRACK_SERVER_VARS] is no longer available if $_SERVER
is not present in the PHP code, due to the changes Zeev (I think) made
in order to improve efficiency. I don't quite agree with the way it
works right now. My extension needs access to the $_SERVER['argv'] and
$_SERVER['argc'] variables internally, even if the user code doesn't.
How am I supposed to retrieve those variable if they aren't even
registered?

-Andrei                                       http://www.gravitonic.com/
* "UNIX, isn't that some archaic form of DOS?" - our job applicant *

---

## #81 — Andi Gutmans — 2003-03-18T05:16:49+00:00

URL: https://externals.io/message/77#81 · In reply to: #77

At 04:51 PM 3/17/2003 -0500, Andrei Zmievski wrote:
>Today I tried to run PHP-GTK with ZE2 changes against current CVS and it
>segfaulted. I traced it to the fact that
>PG(http_globals)[TRACK_SERVER_VARS] is no longer available if $_SERVER
>is not present in the PHP code, due to the changes Zeev (I think) made
>in order to improve efficiency. I don't quite agree with the way it
>works right now. My extension needs access to the $_SERVER['argv'] and
>$_SERVER['argc'] variables internally, even if the user code doesn't.
>How am I supposed to retrieve those variable if they aren't even
>registered?

Just out of curiosity (I don't think it's a long term fix) but does 
eval_string()'ing a string with $_SERVER['argv'] solve the problem?

Andi

---

## #82 — Zeev Suraski — 2003-03-18T08:36:51+00:00

URL: https://externals.io/message/77#82 · In reply to: #77

At 23:51 17/03/2003, Andrei Zmievski wrote:
>Today I tried to run PHP-GTK with ZE2 changes against current CVS and it
>segfaulted. I traced it to the fact that
>PG(http_globals)[TRACK_SERVER_VARS] is no longer available if $_SERVER
>is not present in the PHP code, due to the changes Zeev (I think) made
>in order to improve efficiency. I don't quite agree with the way it
>works right now.

Well, it works well though :)  All you have to do is hint PHP that you're 
going to touch it, and it will be available for you immediately.  To do 
that, simply call:

zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);

and you're done.  ext/standard/info.c already makes use of this.

Zeev

---

## #83 — Andrei Zmievski — 2003-03-18T14:05:26+00:00

URL: https://externals.io/message/77#83 · In reply to: #82

> Well, it works well though :)  All you have to do is hint PHP that you're 
> going to touch it, and it will be available for you immediately.  To do 
> that, simply call:
> 
> zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
> 
> and you're done.  ext/standard/info.c already makes use of this.

Thanks, that worked.

-Andrei                                       http://www.gravitonic.com/

When we eliminate the impossible, whatever remains,
however improbable, must be true. -- Sherlock Holmes
