How to create cascading page error handlers for a TYPO3 site - typo3

Currently it is only possible to add one error handler per HTTP status code in the site configuration, e.g. for 404 or 403. Alternatively you can always write your custom error handler. But this makes it a bit inflexible.
Imagine the following scenario:
default 404 handling would be a specific page, e.g. 12
in a custom error handler I have a cache of URI-to-page mapping. If this gets a hit, the page from that should be displayed. If not, the generic error page 12
which page is displayed should be configurable in the site configuration
or
for 403 I have an error handler which can redirect to a login page
however this may not work in some cases where it should default to standard 403 page
Nice would be if you could configure this for the site so you have something like this:
404
| - custom error handler 1
| - custom error handler 2
| - page error handler
Keeping your extension with the custom error handlers, you could just replace the "page error handler" with a Fluid template for the last step via site configuration.
However, the site module only allows for one error handler per status code (e.g. 404).
I am thinking it might be useful to change this in the TYPO3 core.
But would like to know how others would solve this first.

Related

TYPO3 Core exception: "Id was out of domain" instead of Error 404

because of some alterings in the page structure many of our pages changed the pid. It does not matter in SEO terms because of speaking urls but there are a bunch of third party links with wrong pids, e. g.:
https://www.myDomain.de/index.php?id=46&no_cache=1&sword_list[0]=someWord
The page with uid 46 exists but is not the meant one, and it now resides under a different domain. So the result is the following exception:
Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1518472189:
ID was outside the domain | TYPO3\CMS\Core\Error\Http\PageNotFoundException
thrown in file typo3/sysext/frontend/Classes/Controller/ErrorController.php
in line 80. Requested URL:
https://www.myDomain.de/index.php?id=46&no_cache=1&sword_list[0]=someWord
My question:
Can i tell TYPO3 not to throw an exception but to treat all Outside Domain Events simply as 404 with a redirect to the error page?
thanks!
Should be possible by ading an 404 error handling in Site Management module:
Site Management -> Sites -> Yoursite -> Tab "Error hanling" -> Create new
Showing your 404-page with the correct status code in that case is in my experience unfortunately not too obvious.
The simplest for ?id=... with deleted/moved pages (which because of that do not map to the correct site) is to do redirects to useful pages with EXT:redirect or on the webserver level.
That's an example with EXT:redirect:
If there's nothing comparable in the new content that you could redirect to, you can show your 404-page, e.g. by a passthrough ([PT] with Apache mod_rewrite https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html). You should make sure to send a 404 status in that case. (E.g. through .htaccess, a userFunc on the 404-page, ...).
I hope somebody else has a simpler idea.

Zend framework 1.2 handling 404

I am having one requirement that I want to manage 404 error differently.
When a system found 404, so before moving it to errorController, it should first check in a table which saves data for special urls and internal project url, if an entry found then it should internally execute that internal url and show the output on the page without changing url.
If no entry found in the table then it should move to error controller as it is.
Please help me on this, I have tried and succeeded using dynamic routing from db, but it is pushing route entries each time page initialize and I want to check this only on 404 to avoid useless load on system.
Thanks

404 when post submitted; found when directly called

I have a ColdFusion enabled form (for validation) submitting to a separate page. When this form is submitted it is showing me a 404 on the action page, yet when I directly load the action url into the address bar it shows up (errors appear, but that's ok). This is by far one of the most odd issues I have encountered.
Form page: http://www.jefferson.edu/population_health/_archive/contact_me.cfm
Action page: http://www.jefferson.edu/population_health/_archive/contact_action.cfm
Even if I try passing the form variables via URL it gives me a 404.
My gut is that there is another service on that machine that is trying to take over the request whenever you submit data and binding it to another webserver...which, of course, it can't find the right page based on it's own webroot.
If you click http://www.jefferson.edu/population_health/_archive/contact_me.cfm, it loads fine and returns 200 header with IIS as the server, but if you click http://www.jefferson.edu/population_health/_archive/contact_me2.cfm it throws a 404, as expected, but it's properly handled with a custom 404 and the header response is still IIS. But if you click http://www.jefferson.edu/population_health/_archive/contact_me.cfm?foo=bar, it returns an ApacheSling default 404 and header information saying the server is "Day-Servlet-Engine/4.1.12".
Your page is posting to the page contact_action.cfm ... in your question you indicate that the proper page should be "mailaction.cfm".
If the action page is actually mailaction.cfm then you simply need to change the action attribute of your cfform.

What event to hook to redirect on 404 errors? Symfony 1.4

I am using symfony 1.4.
I need to redirect certain urls when 404 error occurs.
Let's say user is looking for a url http://example.com/oldurl and it doesn't exist I want to check if this url is set for redirect.
If url is set to be redirected I would like to redirect it to that url.
QUESTION: Which event should I hook into to get info about the requested url, that got redirected to 404 error page ?
P.S We only want to check for redirection if page doesn't exist. We do not want to run "the check" for every request, only when page not found!
thanks a lot!
Symfony fire an event each time a page is not found: controller.page_not_found.
You can find it in the documentation: http://www.symfony-project.org/reference/1_4/en/15-Events#chapter_15_sub_controller_page_not_found
Edit:
You can retrieve the url in the method that listen to this event by calling the context. With something like that:
$context = sfContext::hasInstance() ? sfContext::getInstance() : null;
if(null !== $context)
{
$requested_url = $context->getRequest()->getUri();
}
You can give a closer look to the plugin sfErrorNotifierPlugin, it catches exception and 404 error and send an email for a report. Look at how they handle 404 error.
I don't know where to hook exactly inside the execution stack, but I know the general cleaner way through routing. If you are doing routing without still having in code the default routing rule (which you shouldn't by practice since), then it would be as simple as the following in your app routing.yml (at the end):
catch_all:
url: /*
param: { module: yourModule, action: handleNotFound }

Request Dialog CRASHED?

Recently, Facebook has updated the component "request dialog" assigning responsibility to the exclusion of requests to the developers (http://developers.facebook.com/docs/reference/dialogs/requests#deleting). He also made other adjustments to the format of the request id. Thus added configuration option "request 2.0 efficient" on menu of the application developer.
The problem started after this change , the component "request dialog Multi - Friend- Selector" is in serious trouble. The component is crashed while trying to load friends. Sometimes friends loads, but the component does not resize height.
See the image of the errors:
Crashed before load friends:
http://postimage.org/image/glk2mf3bb/
Resize fail
http://postimage.org/image/iobduhn41/
In chrome browser component generates the following error:
s-static.ak.facebook.com/rsrc.php/v1/yS/r/syXGEAW5WYH.js:36 Uncaught TypeError: Cannot read property 'origin' of undefined
In firefox generates following error:
Erro: Permission denied to access property 'DocRPC'Arquivo-fonte: https://s-static.ak.facebook.com/rsrc.php/v1/yS/r/syXGEAW5WYH.js Linha: 36
Can you reproduce the error with the code itself Documentation
http://developers.facebook.com/docs/reference/dialogs/requests
Help please.
Seeing same errors here, but I can add some info:
It does seem to work if you use the basic example in https://developers.facebook.com/docs/reference/dialogs/requests, which opens up the dialog in a new browser window.
In Chrome, I found an additional error message to the one you posted:
"Unsafe JavaScript attempt to access frame with URL [...] from frame with URL [...]facebook.com/dialog/apprequests. Domains, protocols and ports must match."
From all that I guess the error may be related to the dialog display mode (read https://developers.facebook.com/docs/reference/dialogs). Within my app, I am getting this error exactly as you do, unless I set display to something like 'popup', in which case everything works (but a new borwser window is opened). The docs do state that "Because of the risk of clickjacking, [iframe] is only allowed for some certain dialogs, and requires you to pass a valid access_token." Well, passing access tokens did no good for me.
Little question: are you using some toolkit like GWT?