Welcome Guest, Not a member yet? Register   Sign In
Bug in Router
#1

[eluser]dignick[/eluser]
This bug exhibits itself when you have the default route specified in routes but that default route does not exist, and you are trying to access a controller in a subdirectory based on the default route. I've only discovered it because I've not yet set up the main page and I'm developing a sub-page first. An example will explain this better.

Code:
$route['default_route'] = 'main';

controllers/main.php does not exist, but controllers/admin/main.php does. The index method exists in admin/main.php.

Visiting index.php/admin will present a 404 error. If controllers/main.php is created, index.php/admin will now work.

This is happening because the following process occurs in Router:

in _set_routing()
$this->_parse_routes() (line 120)
$this->_set_request($this->uri->segments) (line 332)
$segments = $this->_validate_request($segments) (line 177)

Route is correctly detected on lines 254 and 255. Routing is now complete, but the process continues. The return array is empty as the /admin has been sliced out.

returns to _set_request()
$this->_set_default_controller() (line 181)
$this->_set_request(array($this->default_controller, 'index')) (line 153)
$segments = $this->_validate_request($segments) (line 177)

Route cannot be validated now. 404 occurs.

This cyclic behaviour is not ideal. Is _validate_request supposed to validate the request or determine the routing?! It's not clear, but in this case it does determine the routing and gets it right, but that means that the array it returns has been modified so its done more than just validation, so the remaining process fails.

This all seems a bit messy. I think I'll have to re-write some of this class as I need this working. I would also like to be able to set a different default controller for each sub directory. I will post results if I do this. Otherwise, has this bug been recognised already? Should I post this as a bug report?


Messages In This Thread
Bug in Router - by El Forum - 03-20-2011, 05:08 PM
Bug in Router - by El Forum - 03-20-2011, 11:26 PM
Bug in Router - by El Forum - 03-21-2011, 04:45 AM
Bug in Router - by El Forum - 03-21-2011, 05:46 AM
Bug in Router - by El Forum - 03-21-2011, 07:44 AM
Bug in Router - by El Forum - 03-21-2011, 10:44 AM
Bug in Router - by El Forum - 03-21-2011, 11:11 AM
Bug in Router - by El Forum - 04-15-2011, 12:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB