Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

route: notFound, setting params error

i Have in my route conf:

    $router->notFound(array(
    'module' => 'public',
    'controller' => 'error',
    'action' => 'index',
    'params' => '404'
));

in controller:

    public function indexAction($error = NULL) {
    var_dump($error);
    die();
    }

the response is: string(2) "04", i need 404 param

but if change the route to:

      $router->notFound(array(
    'module' => 'public',
    'controller' => 'error',
    'action' => 'index',
    'params' => '0404'
    ));

the response is: string(2) "404" , and it oks for me!..

and i need that 404 param... why is this problem??, bug in notFound?



1.5k
Accepted
answer

I've found the problem. The params variable usually looks like "/param1/param2/param3/param4" ("/:params" translates to "(/.)"). As such, the router "trims" the params content using substr(params, 1) to remove the first character which is usually a forward slash. See here.

I've changed it so that it trims only forward slashes: https://github.com/phalcon/cphalcon/pull/10277

The good news is, it looks like 2.0.1 will be arriving in the next few days so you won't have to wait long for it to come to a stable release.

Sounds good!, thanks!!