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

[Routing] Properly handle Responses and exceptions by displaying 404 pages, etc. #1789

Closed
1 of 6 tasks
cmfcmf opened this issue Jun 19, 2014 · 16 comments
Closed
1 of 6 tasks
Labels
Milestone

Comments

@cmfcmf
Copy link
Contributor

cmfcmf commented Jun 19, 2014

refs #1552

@craigh
Copy link
Member

craigh commented Oct 26, 2014

handle exceptions

Symfony does some of this for us:

By default, the showAction() method of the ExceptionController will be called when an exception occurs.

This controller will either display an exception or error page, depending on the setting of the kernel.debug flag. While exception pages give you a lot of helpful information during development, error pages are meant to be shown to the user in production.

http://symfony.com/doc/current/cookbook/controller/error_pages.html

the debug flag is set to false in most situations I've seen (including zikula.org I think) so we are still seeing all exceptions all the time.

@craigh
Copy link
Member

craigh commented Oct 26, 2014

also, all twig stuff is moved to 1.5

Guite added a commit that referenced this issue Oct 26, 2014
@craigh
Copy link
Member

craigh commented Oct 26, 2014

I've looked through the entire /system directory at only the controllers and found that only the following exceptions are in use:

  • AccessDeniedException
  • NotFoundHttpException
  • InvalidArgumentException
  • FatalErrorException
  • RuntimeException
  • Exception

Of these, AccessDeniedException is now handled. NotFoundHttpException and InvalidArgumentException are used quite often. FatalErrorException is used some and the others are used rarely. What shall we do with the these?

@craigh
Copy link
Member

craigh commented Oct 26, 2014

I did not scan any API or other classes in /system and I did not scan other parts of the core. I guess I'm thinking those should be handled differently (or not handled) as they are the responsibility of the developer to handle.

@Guite
Copy link
Member

Guite commented Oct 26, 2014

For a NotFoundHttpException or a InvalidArgumentException we could display an error page.
Not sure about the others... at the end we log the error in all cases and show it in the output, right?

Slightly related but for future: http://symfony.com/blog/new-in-symfony-2-6-error-page-previews

@craigh
Copy link
Member

craigh commented Nov 17, 2014

[11/17/14, 4:00:46 PM] Craig Heydenburg: can you tell me more about #1789
[11/17/14, 4:00:51 PM] Craig Heydenburg: ?
[11/17/14, 4:03:29 PM] Christian: Sure. Basically, no matter what happens in a controller, the page shouldn't blow up. This includes but is not limited to:

  • NotFoundException
  • FatalErrorException
  • Any Exception
  • AccessDeniedException
  • RedirectResponses
  • Old Zikula_Response_Ajax_* responses
  • New Symfony responses

@craigh
Copy link
Member

craigh commented Nov 17, 2014

This ticket is mainly about using the new AbstractController and concerns about it's functionality. Especially with regard to theming and differences in how it might send responses, e.g.

return new Response($this->view->fetch('...'));
and 
return new Response("{json-data}")
and 
return new Response($twig->render('bla'))

@craigh
Copy link
Member

craigh commented Nov 17, 2014

ping @Kaik can you help out here by telling us how you have tested the new AbstractController and what your experience was?

@Kaik
Copy link
Contributor

Kaik commented Nov 18, 2014

That was long time ago I was able to display page with twig and some data from db and actually that was all, no theme wrapped, no translation, no forms, just plain page and items list and that was really long time ago...

@craigh
Copy link
Member

craigh commented Nov 20, 2014

I wrote a small module that can be used to test Exceptions and other things we want to break. feel free to expand the scope of the module 😄

https://github.com/craigh/BreakIt

ping @cmfcmf

the bad news is, zikula isn't yet performing as I expected with regard to this ticket.

@craigh
Copy link
Member

craigh commented Nov 20, 2014

screen shot 2014-11-19 at 8 08 06 pm

@craigh
Copy link
Member

craigh commented Nov 22, 2014

OK - I don't know if we are ready to close this ticket yet.

Everything that is currently testable by BreakIt 💣 seems to be covered:

When in prod environment:
Throw AccessDeniedException - redirects either to login or to referrer with message
Other exceptions go to an error page that we can customize further if needed, but currently looks like this:
screen shot 2014-11-22 at 3 51 24 pm

BreakIt also tests an invalid route (/I/AM/INVALID) which at this time simply redirects to the home page

and lastly and old-style invalid route (/index.php?module=invalid&type=user&func=main) which looks like so:
screen shot 2014-11-22 at 3 53 33 pm

what else should be done?

@craigh
Copy link
Member

craigh commented Nov 22, 2014

one interesting point I just learned:

because Core::init() runs before any REQUEST events, the old System::queryStringDecode() fires before listeners like src/lib/Zikula/Bundle/CoreBundle/EventListener/LegacyRouteListener.php but the latter is what is actually handling both invalid urls above.

@craigh
Copy link
Member

craigh commented Nov 26, 2014

closing. If other issues are discovered, they should be opened as separate issues.

@craigh craigh closed this as completed Nov 26, 2014
@craigh
Copy link
Member

craigh commented Nov 26, 2014

@Kaik - you might want to check out how I am using Twig in https://github.com/craigh/BreakIt

@cmfcmf
Copy link
Contributor Author

cmfcmf commented Nov 26, 2014

If other issues are discovered, they should be opened as separate issues.

👍

craigh added a commit that referenced this issue Dec 6, 2014
remove exception handling in ajax portion of legacy handler refs #1789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants