Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling skipRemaning() or skipThis() can cause HttpException 404 #285

Open
nfrias opened this issue Apr 9, 2015 · 2 comments
Open

Calling skipRemaning() or skipThis() can cause HttpException 404 #285

nfrias opened this issue Apr 9, 2015 · 2 comments

Comments

@nfrias
Copy link

nfrias commented Apr 9, 2015

If there is a single route match, calling skipRemaining() or skipThis() within the respond() call causes an HttpException and onHttpError gets called. This is because the $matched->add($route) (line 596) in klein.php does not execute in those cases.

I solved it by moving that block before calling handleRouteCallback(), but I'm not sure if there are other side effects. So far none that I can detect.

try {
    if ($path !== '*' && $count_match) {  // this is far more clear than:
        $matched->add($route);            // $count_match && $matched->add($route);
    }
    $this->handleRouteCallback($route, $matched, $methods_matched);

} catch (DispatchHaltedException $e) {
    ...
}

The continue 2; and break 2; statements cause the skipping of the code block.

@tikoflano
Copy link

Can we have an update on this? The current version of Klein still has this error. As I use Composer I don't want to modify teh source code directly.

@thinsoldier
Copy link

@tikoflano I've used $klein->abort(200) and it still seems to successfully stop processing further routes while also sending the response code specified. This is my first time using Klein so I'm not sure if using abort is going have some strange side effect I'll regret later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants