Bug Report #1282
Router::$current_uri incorrect after Rouing::setup() completes
| Status: | Closed | Start date: | ||
|---|---|---|---|---|
| Priority: | High | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | Libraries | |||
| Target version: | 2.4 | |||
| Resolution: | fixed | Points: |
Description
When using the default route, the Router::setup() assigns the routed path to $current_uri.
While this may be needed for internal functionality of some sort, it means that after this change, $current_uri no longer returns the data as specified in the docs for the default route.
A simple correction would be to set the $current_uri back to an empty string once all required uses of it in Router::setup() have completed.
(patch file included)
Associated revisions
Organize logic and set Router::$current_uri === '' during default route. Fixes #1282
History
Updated by Chris Bandy almost 3 years ago
A temporary workaround to detect the default route is to test if Router::$segments is empty.
Updated by Jeremy Bush over 2 years ago
- Status changed from New to Closed
- Resolution set to wontfix
There's no really correct answer to this. I feel that $current_uri should be set to the routed URI in the case of the default route. I'd recommend doing as cbandy has described above.
Updated by Chris Bandy over 2 years ago
system.routing event:
$current_urimatches the request$routed_urimatches the called controller + method
$segmentsis an array matching$current_uri,
implode('/', $segments) === $current_uri AND $segments === explode('/', $current_uri)
$rsegmentsis an array matching$routed_uri
implode('/', $rsegments) === $routed_uri AND $rsegments === explode('/', $routed_uri)
$controller === $rsegments[0]$method === $rsegments[1]
Currently, items 1 and 3 are broken for the default route.
AFAIK, the default route is use only for a request made to the front controller. I don't think Router should throw away the requested URI in the case of the default route.
Updated by David Dixon over 2 years ago
- Status changed from Closed to Feedback
- Assignee set to Jeremy Bush
I agree, the default route needs to be treated (at least from an application PoV) the same as an other route the system takes. What Kohana does with it internally is completely not really the concern. The issue here is ensuring consistency across in the way the Routing system is used by application developers.
update: soz for the status change, with this new bug tracking interface, i though i was directing the feedback to Jeremy, not assigning the entire ticket to him.
Updated by Jeremy Bush over 2 years ago
- Target version changed from 2.3.3 to 2.4
- Resolution deleted (
wontfix)
Convinced me, but it's an API change, so it goes to 2.4.
Updated by Chris Bandy over 2 years ago
- File 0001-Organize-logic-and-set-Router-current_uri-d.patch added
- 11 set to 2.3.4
Updated by Jeremy Bush over 2 years ago
- Status changed from Feedback to Assigned
- Assignee changed from Jeremy Bush to Chris Bandy
Updated by Jeremy Bush over 2 years ago
- Priority changed from Normal to High
Updated by Chris Bandy over 2 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
Applied in changeset r4465.
Updated by Chris Bandy over 2 years ago
- Resolution set to fixed