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

Override core 404 handling to prevent subsequent pageNotFoundAndExit() #510

Open
sventendo opened this issue Jul 25, 2017 · 5 comments
Open

Comments

@sventendo
Copy link

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

@dmitryd
Copy link
Owner

dmitryd commented Aug 6, 2017

I do not understand this. Please, explain better.

@sventendo
Copy link
Author

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
Copy link
Author

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

@dmitryd
Copy link
Owner

dmitryd commented Aug 31, 2017

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'].

@sventendo
Copy link
Author

sventendo commented Sep 4, 2017

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: #510 (comment).

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