Welcome Guest, Not a member yet? Register   Sign In
Everything seems to work, except $_GET
#1

[eluser]skunkbad[/eluser]
After upgrading a site on my local machine, everything seems to work, except if I add a query string to a URL, the home page is served, even when the query string was added to a URL for a different page.

Commenting the following out of URI.php is a fix, but why?

Code:
// Arguments exist, it must be a command line request
/*if ( ! empty($_SERVER['argv']))
{
    $this->uri_string = $this->_parse_cli_args();
    return;
}*/
#2

[eluser]skunkbad[/eluser]
Since nobody has responded, I'd say that URI.php incorrectly assumes that $_SERVER['argv'] is only set when there is a command line request. This is a dev server (xampp on win7 64bit), but I don't think it should matter.
#3

[eluser]Adam[/eluser]
Yep this is a bug. It should be:

Code:
if (php_sapi_name() === 'php')
{
    // This is a "command line request"
    // Side-note - why the heck are we detecting the SAPI type in the URI object?
    $this->uri_string = $this->_parse_cli_args();
    return;
}
#4

[eluser]skunkbad[/eluser]
[quote author="Adam" date="1307542655"]Yep this is a bug. It should be:

Code:
if (php_sapi_name() === 'php')
{
    // This is a "command line request"
    // Side-note - why the heck are we detecting the SAPI type in the URI object?
    $this->uri_string = $this->_parse_cli_args();
    return;
}
[/quote]

I had asked this question back when 2.0 was new. 2.0.2 now has the following code:

Code:
// Is the request coming from the command line?
if (defined('STDIN'))
{
      $this->_set_uri_string($this->_parse_cli_args());
      return;
}

As far as I can tell, the php manual makes it clear that php_sapi_name() isn't reliable between server types, so you're method may only work on certain servers.
#5

[eluser]Adam[/eluser]
[quote author="skunkbad" date="1307582771"]As far as I can tell, the php manual makes it clear that php_sapi_name() isn't reliable between server types, so you're method may only work on certain servers.[/quote]

No, the PHP manual does not say that; it's a perfectly acceptable way to determine if the script is being executed from the command line.

* http://php.net/php_sapi_name
* https://github.com/search?type=Code&lang..._sapi_name
#6

[eluser]skunkbad[/eluser]
[quote author="Adam" date="1307635034"][quote author="skunkbad" date="1307582771"]As far as I can tell, the php manual makes it clear that php_sapi_name() isn't reliable between server types, so you're method may only work on certain servers.[/quote]

No, the PHP manual does not say that; it's a perfectly acceptable way to determine if the script is being executed from the command line.

* http://php.net/php_sapi_name
* https://github.com/search?type=Code&lang..._sapi_name[/quote]

Not arguing, but I got the impression that it may not be reliable based on the description:

Quote:Returns a lowercase string that describes the type of interface (the Server API, SAPI) that PHP is using. For example, in CLI PHP this string will be "cli" whereas with Apache it may have several different values depending on the exact SAPI used. Possible values are listed below.

Maybe I was just reading that too fast. I think what it is saying is that Apache may return several different values, not CLI PHP. What do you think of the way the CI team handled it in 2.0.2?




Theme © iAndrew 2016 - Forum software by © MyBB