You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by Michael Schmitz <Mi...@tietoenator.com> on 2007/08/01 09:07:05 UTC

Re: $_ENV vs $_SERVER in LoggerOptionConverter

Hello all,

>>>>> "Knut" == Knut Urdalen <kn...@php.no> writes:

    Knut> Christian Hammers wrote:
    >> if (defined($key)) {
    >> return (string)constant($key);
    >> -        } elseif (isset($_ENV[$key])) {
    >> -            return (string)$_ENV[$key];
    >> +        } elseif (isset($_SERVER[$key])) {
    >> +            return (string)$_SERVER[$key];
    >> } else {
    >> return $def;
    >> }
    >> 
    Knut> Hi,

    Knut> I think it's safe to add the $_SERVER variable here, and
    Knut> check it before $_ENV. But still keep $_ENV like this:

    Knut>          if (defined($key)) {
    Knut>              return (string)constant($key);
    Knut> +        } elseif (isset($_SERVER[$key])) {
    Knut> +            return (string)$_SERVER[$key];
    Knut>          } elseif (isset($_ENV[$key])) {
    Knut>              return (string)$_ENV[$key];
    Knut>          } else {
    Knut>              return $def;
    Knut>          }

    Knut> Do you agree?

As regards $_ENV superglobal, depending on php.ini (parameter
variables_order) this variable may or may not be prefilled. In my
opinion we should not to much on php.ini and therefore should use
getenv() instead of at least in addition to $_ENV.

Regards,
Michael.

Re: $_ENV vs $_SERVER in LoggerOptionConverter

Posted by Michael Schmitz <Mi...@tietoenator.com>.
>>>>> "Knut" == Knut Urdalen <kn...@php.no> writes:

    Knut> Michael Schmitz wrote:
    >> As regards $_ENV superglobal, depending on php.ini (parameter
    >> variables_order) this variable may or may not be prefilled. In my
    >> opinion we should not to much on php.ini and therefore should use
    >> getenv() instead of at least in addition to $_ENV.

    Knut> One thing about getenv(). I remember running into a
    Knut> performance issue regarding getenv() and PEAR::Date
    Knut> earlier. My code produced quite a lot of Date-objects and
    Knut> PEAR::Date fetching the timezone information each time. So
    Knut> I'm a bit worried that adding getenv() here could reduce
    Knut> performance. I don't have the time to write a benchmark test
    Knut> right now, but I just wanted to mention it.

Ok, this might indeed be a problem, but if we call getenv() only if
neither $_SERVER nor $_ENV contains whatever we're looking for,
performance should no degrade.

Re: $_ENV vs $_SERVER in LoggerOptionConverter

Posted by Knut Urdalen <kn...@php.no>.
Michael Schmitz wrote:
> As regards $_ENV superglobal, depending on php.ini (parameter
> variables_order) this variable may or may not be prefilled. In my
> opinion we should not to much on php.ini and therefore should use
> getenv() instead of at least in addition to $_ENV.
One thing about getenv(). I remember running into a performance issue 
regarding getenv() and PEAR::Date earlier. My code produced quite a lot 
of Date-objects and PEAR::Date fetching the timezone information each 
time. So I'm a bit worried that adding getenv() here could reduce 
performance. I don't have the time to write a benchmark test right now, 
but I just wanted to mention it.

Knut