Welcome Guest, Not a member yet? Register   Sign In
URI class, _fetch_uri_string and $_GET issue
#1

[eluser]WanWizard[/eluser]
In the _fetch_uri_string() method of the URI class, URI detection starts with
Code:
// If the URL has a question mark then it's simplest to just
// build the URI string from the zero index of the $_GET array.
// This avoids having to deal with $_SERVER variables, which
// can be unreliable in some environments
if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '')
{
    $this->uri_string = key($_GET);
    return;
}

Can someone explain what the point is of this code?

I assume it's a 'hack' to get AUTO to work in CGI environments, where the question mark after index.php is required, but it breaks all other installations that want to use the query string. If you have a URL like
Quote:http://example.org/controller/method/parm?var=value
this code kicks in, and assumes the URI string is equal to 'var'. As soon as you add a second variable to the query string, problem is solved again, thanks to the 'count($_GET) == 1'.


Anyone of the Ellislab's team that can explain the reasoning behind this piece of code, so we can see if we can find a more bulletproof solution?

We really need to get proper support for query strings in CI, most API's require it, it is rediculous that everyone has to hack their way around it.




Theme © iAndrew 2016 - Forum software by © MyBB