Bug Report #1282

Router::$current_uri incorrect after Rouing::setup() completes

Added by David Dixon almost 3 years ago. Updated over 2 years ago.

Status:Closed Start date:
Priority:High Due date:
Assignee:Chris Bandy % 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)

router.diff - Patch File (580 Bytes) David Dixon, 04/22/2009 11:20 am

0001-Organize-logic-and-set-Router-current_uri-d.patch - against 2.4 (1.4 kB) Chris Bandy, 06/30/2009 05:44 am

Associated revisions

Revision 4465
Added by Chris Bandy over 2 years ago

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

Hang on. I feel that these properties should be true after the system.routing event:
  1. $current_uri matches the request
  2. $routed_uri matches the called controller + method
     
  3. $segments is an array matching $current_uri,
    implode('/', $segments) === $current_uri AND $segments === explode('/', $current_uri)
     
  4. $rsegments is an array matching $routed_uri
    implode('/', $rsegments) === $routed_uri AND $rsegments === explode('/', $routed_uri)
     
  5. $controller === $rsegments[0]
  6. $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 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

Also available in: Atom PDF