$_SERVER registration issue

php.internals

Andrei Zmievski

23 years ago
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 *

Sterling Hughes

23 years ago
On Mon, 2003-03-17 at 16:51, 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? >
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

Sterling Hughes

23 years ago
On Mon, 2003-03-17 at 16:51, 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? >
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

Andi Gutmans

23 years ago
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

Zeev Suraski

23 years ago
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

Andrei Zmievski

23 years ago
On Tue, 18 Mar 2003, Zeev Suraski wrote:
> 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