Zend Framework

Inconsistent initialization of routes' path variables

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.5.1
  • Fix Version/s: 1.6.0
  • Component/s: Zend_Controller
  • Labels:
    None

Description

Andriess Seutens:

I have a little issue with the url helper and route matching. I think
this is a critical missing feature / bug.
I'm going to try to explain my issue by example:

My bootstrap file:

set_include_path('./ZendFramework-1.5.1/library');

require_once 'Zend/Loader.php';
Zend_Loader::registerAutoLoad();

$frontController = Zend_Controller_Front::getInstance();
$frontController->addControllerDirectory('./application/controllers')
    ->throwExceptions(true)
    ->returnResponse(true);

$router = $frontController->getRouter();
$router->addRoute('foo', new Zend_Controller_Router_Route(
    ':lang/foo',
    array(
        'lang'       => 'nl',
        'controller' => 'index',
        'action'     => 'index'
    )
));

$router->addRoute('bar', new Zend_Controller_Router_Route(
    ':lang/bar',
    array(
        'lang'       => 'nl',
        'controller' => 'index',
        'action'     => 'index'
    )
));

$response = $frontController->dispatch();
$response->sendHeaders()
    ->outputBody();

My template file:

<?php echo $this->url(array(), 'foo') ?>
<br />
<?php echo $this->url(array(), 'bar') ?>

when i call: http://mydomain/nl/bar
the output is:

/nl/foo
/nl/bar

which is good!

if i call: http://mydomain/en/foo
the output is

/en/foo
/en/bar

which is good too!

the problem occurs when the last route in the row is matched (in this
case: 'bar')

http://test/en/bar

output:

/nl/foo
/en/bar

works for all routes after the matched one, but not the ones before.....

In order for this to work I would need to pass in the 'lang' parameter:

<?php echo $this->url(array('lang' =>
Zend_Controller_Front::getInstance()->getRequest()->getParam('lang')),
'foo') ?>

So, in other words: I am unable to take a url param into each route and
use it with the url helper?

Best,
Andriesss

Issue Links

Activity

Hide
Michal Minicki added a comment -

Probably temporary fix to inconsistent route path variables handling.

Show
Michal Minicki added a comment - Probably temporary fix to inconsistent route path variables handling.
Hide
Michal Minicki added a comment -

The proposed fix is in a direct conflict with the linked issue. I will fix the problem the other way - routes will not be initialized with url values on negative match. I will provide a way to use request variables in a route on a router assembly level.

Show
Michal Minicki added a comment - The proposed fix is in a direct conflict with the linked issue. I will fix the problem the other way - routes will not be initialized with url values on negative match. I will provide a way to use request variables in a route on a router assembly level.
Hide
Michal Minicki added a comment -

Fixed in opposite way:

http://mydomain/nl/bar => /nl/foo, /nl/bar
http://mydomain/en/foo => /en/foo, /nl/bar
http://mydomain/en/bar => /nl/foo, /en/bar

Show
Michal Minicki added a comment - Fixed in opposite way: http://mydomain/nl/bar => /nl/foo, /nl/bar http://mydomain/en/foo => /en/foo, /nl/bar http://mydomain/en/bar => /nl/foo, /en/bar
Hide
Wil Sinclair added a comment -

Updating for the 1.6.0 release.

Show
Wil Sinclair added a comment - Updating for the 1.6.0 release.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: