typo3-realurl icon indicating copy to clipboard operation
typo3-realurl copied to clipboard

Override core 404 handling to prevent subsequent pageNotFoundAndExit()

Open sventendo opened this issue 6 years ago • 5 comments

The default core handling of inaccessible pages (due to access restrictions) is fallback content. For this to work this must be empty: $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = ''

When I need to show a pretty 404 page if a page doesn't exist, then the same config must not be be empty.

This is a problem if I want both handlings (fallback on access denied, 404 on page doesn't exist).

This is fixed in #509

sventendo avatar Jul 25 '17 10:07 sventendo

I do not understand this. Please, explain better.

dmitryd avatar Aug 06 '17 19:08 dmitryd

Let's say I have a public page "/products" and a subpage "/products/for-members" that is only accessible to one usergroup. The default behavior is this: A user with that usergroup can visit "/products" and "/products/for-members". A user without that usergroup can visit "/products" and he can also visit "/products/for-members" but he will see the content of "/products". This is a silent fallback, not a redirect- the URL in the address bar will NOT reflect the fallback content. It will still display "/product/for-members".

This is exactly the behavior I want. But I also want proper 404 handling. So when a user visits the page "/products/foo" or "/bar" I want to display a nice 404 page. Now setting $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] properly will handle this, but then I will loose the silent fallback logic. So this is no good.

realurl to the rescue! \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::checkAlternativeIdMethods calls the realurl hook that eventually calls \DmitryDulepov\Realurl\Decoder\UrlDecoder::handleNonExistingPostVarSet. So at this point the system would know if the page actually exists or not. But the only way out from here is \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::pageNotFoundAndExit which does not support the rendering of a nice 404 page.

So in short, this is what I want and what the PR would support:

  1. Silent fallback logic on restricted pages
  2. nice 404 pages on non-existing pages

sventendo avatar Aug 08 '17 20:08 sventendo

@dmitryd : did this make any sense to you? I think this would be a really useful feature.

sventendo avatar Aug 30 '17 14:08 sventendo

But the only way out from here is \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::pageNotFoundAndExit which does not support the rendering of a nice 404 page.

You can provide your own 404 page using TYPO3 config at this point using $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'].

dmitryd avatar Aug 31 '17 12:08 dmitryd

But that is precisely the point: if $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] is used, then we lose the content fallback logic on restricted pages as detailed here: https://github.com/dmitryd/typo3-realurl/issues/510#issuecomment-321066304.

sventendo avatar Sep 04 '17 12:09 sventendo