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

Slim Error on redirecting from error callback #46

Closed
X-Tender opened this issue Sep 29, 2016 · 5 comments
Closed

Slim Error on redirecting from error callback #46

X-Tender opened this issue Sep 29, 2016 · 5 comments

Comments

@X-Tender
Copy link

I have a strange issue. Thats the error callback of the JWT JwtAuthentication (1.x).

"error" => function ($options) use ($app) {
        return $app->redirect( $app->urlFor('index') );
    }

On my development system (mamp php 5.6) the rediect from the "error" callback works fine.
On my productions erver (1&1 php 5.6) I get the following error:

Type: Slim\Exception\Stop
File: /SERVERPATH/htdocs/app/vendor_modules/slim/slim/Slim/Slim.php
Line: 1022
Trace

#0 /SERVERPATH/htdocs/app/vendor_modules/slim/slim/Slim/Slim.php(1042): Slim\Slim->stop()
#1 /SERVERPATH/htdocs/app/vendor_modules/slim/slim/Slim/Slim.php(1105): Slim\Slim->halt(302)
#2 /SERVERPATH/htdocs/app/php/start.php(151): Slim\Slim->redirect('/app/public/')
#3 /SERVERPATH/htdocs/app/vendor_modules/tuupola/slim-jwt-auth/src/JwtAuthentication.php(150): {closure}(Array)
#4 /SERVERPATH/htdocs/app/vendor_modules/tuupola/slim-jwt-auth/src/JwtAuthentication.php(97): Slim\Middleware\JwtAuthentication->error(Array)
#5 /SERVERPATH/htdocs/app/vendor_modules/slim/slim/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\JwtAuthentication->call()
#6 /SERVERPATH/htdocs/app/vendor_modules/slim/slim/Slim/Slim.php(1302): Slim\Middleware\PrettyExceptions->call()
#7 /SERVERPATH/htdocs/app/php/start.php(176): Slim\Slim->run()
#8 /SERVERPATH/htdocs/app/public/index.php(2): require('/SERVERPATH/d...')
#9 {main}

What could be wrong?!

@tuupola
Copy link
Owner

tuupola commented Sep 29, 2016

Slim 2 uses exceptions internally for control flow. You are seeing one of these Slim 2 control flow exceptions. Look for differences in your development and production config.

@X-Tender
Copy link
Author

Honestly thats not realy any difference except the DB Connect credentials.
So I sould better bother the slim developer about the issue :) ?!

@tuupola
Copy link
Owner

tuupola commented Sep 29, 2016

It is Slim which throws the exception, not the middleware.

https://github.com/slimphp/Slim/blob/2.x/Slim/Slim.php#L1102-L1105
https://github.com/slimphp/Slim/blob/2.x/Slim/Slim.php#L1037-L1043
https://github.com/slimphp/Slim/blob/2.x/Slim/Slim.php#L1020-L1023

Why the Exception is ignored on development host and shown on live host I do not know. However quick Google search reveals this.

http://stackoverflow.com/questions/25902650/slim-redirect-works-but-also-throws-an-exception

@X-Tender
Copy link
Author

X-Tender commented Sep 29, 2016

Thanks. I packed it now that way and it works :/ But it feels wrong.

try {
    return $app->redirect( $app->urlFor('index') );
} catch(\Exception $e) {}

@tuupola
Copy link
Owner

tuupola commented Sep 30, 2016

Yeah I agree. I think that was the reason those Exceptions were dropped in 3.x.

@tuupola tuupola closed this as completed Sep 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants