Part of the EllisLab Network

Bug Report

wrong parameters when rerouting

Date: 08/08/2007 Severity: Minor
Status: Duplicate Reporter: mo26
Version: 1.5.3
Keywords:

Description

When using routing and the url has got a different length, then parameters to controllers are not passed correctly

Code Sample

in routes.php
    $route
['controller/(.*)'] = "$1";

in controllers/admin.php
  
class admin extends Controller {
  
function admin()
  
{
    parent
::Controller();
  
}

  
function edit($ID)
  
{
    
echo $ID;
  
}
}

then on url http
://controller/admin/edit/1

Expected Result

1

Actual Result

edit

Comment on Bug Report

Page 1 of 1 pages
Posted by: Seppo on 16 January 2008 9:59pm
Seppo's avatar

I think it gets fixed replacing
$diff = (count(array_diff($this->rsegments, $this->segments)) == 0) ? FALSE : TRUE;

for
$diff = (count(array_diff($this->rsegments, $this->segments)) == 0 && count(array_diff($this->segments, $this->rsegments)) == 0) ? FALSE : TRUE;

Posted by: Derek Jones on 30 January 2008 1:32am
Derek Jones's avatar

Indeed, this is fixed by way of the fix for this bug, though the fix that went in the code omits count()ing the returned arrays.

$diff = (array_diff($this->rsegments, $this->segments) != array_diff($this->segments, $this->rsegments)) ? TRUE : FALSE;

I don’t anticipate this causing any problems, as it should never evaluate as TRUE unless one of the arrays contains a key that the other doesn’t, regardless of the order of the values in the original arrays.

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?