Bug Report #4681
Route::url() says param is required when it's not
| Status: | Closed | Start date: | 12/20/2012 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | - | |||
| Target version: | 3.3.1 | |||
| Resolution: | duplicate | Points: | 1 |
Description
I have a route:
Route::set('module', '<controller>(/<type>(/<entity>))(/<action>(/<id>))', array(
'controller' => 'blog|messageboard',
'type' => 'committee|group|user',
'entity' => '[0-9]+',
))
->defaults(array(
'action' => 'index',
));
Now i calls:
Route::url('module', array(
'controller' => 'blog',
'type' => 'committee',
'entity' => NULL,
'id' => NULL,
))
And instead of '/blog/controller' the exception 'Required route parameter not passed: id' in https://github.com/kohana/core/blob/3.3/master/classes/Kohana/Route.php at line 568 is rised.
If I remove '(/<id>)' from the route everything works fine.
Related issues
History
Updated by Ihor Chumachenko 5 months ago
It seems I've got the problem. The code
534 // Keep track of whether an optional param was replaced
535 $provided_optional = FALSE;
536
537 while (preg_match('#\([^()]++\)#', $uri, $match))
538 {
539
540 // Search for the matched value
541 $search = $match[0];
should be changed by this:
534 while (preg_match('#\([^()]++\)#', $uri, $match))
535 {
536 // Keep track of whether an optional param was replaced
537 $provided_optional = FALSE;
538
539 // Search for the matched value
540 $search = $match[0];
Updated by Ihor Chumachenko 5 months ago
Oops. I'm sorry. Previous post was wrong. Of course $provided_optional = FALSE; should stay before the while. Current code doesn't suppose to meet (...)(...) in the route.
Updated by Thomas Lété 3 months ago
I have the same problem here, nested route parameters seem to fail with Kohana 3.3...
Updated by Lorenzo Pisani 3 months ago
- Status changed from New to Closed
- Assignee set to Lorenzo Pisani
- Target version set to 3.3.1
- Resolution set to duplicate
was fixed by #4630