Open axllent opened 6 years ago
I've also just hit this. We have the entire site protected by login and when an unauthenticated user attempts to view a 404 page, they're given a blank white page with the following text:
ERROR [UNKNOWN TYPE, ERRNO 404]: IN GET /sdf Line in Trace ===== SilverStripe\Dev\CliDebugView->renderTrace() DetailedErrorFormatter.php:119 SilverStripe\Logging\DetailedErrorFormatter->output(404, , , , ) DetailedErrorFormatter.php:54 SilverStripe\Logging\DetailedErrorFormatter->format(Array) HTTPResponse.php:355 SilverStripe\Control\HTTPResponse->outputBody() HTTPResponse.php:283 SilverStripe\Control\HTTPResponse->output() index.php:18
When an authenticated user views a 404 page it works perfectly.
Our workaround at the moment is to change the view permissions to "Anyone" in the CMS.
I'm not sure what the best fix is for this - always set canView to true and remove the CMS permissions?
The easy solution here would simply to ad a canview() { return true }
to ErrorPage
. I can't think of any scenario whereby either of those pages would require anything but that, though I may be wrong.
My workaround is a simple extension:
<?php
/**
* Make all ErrorPages visible regardless of site settings
*
*/
namespace {
use SilverStripe\CMS\Model\SiteTreeExtension;
class ErrorPageExtension extends SiteTreeExtension
{
public function canView()
{
return true;
}
}
}
SilverStripe\ErrorPage\ErrorPage:
extensions:
- ErrorPageExtension
I added hooks to work around this in #124
The leading example for usage is the SAML module when it protects the entire site via Middleware.
I'm not sure whether this is intentional or not, however when
Who can view pages on this site?
is set to either Logged-in users or "Only these groups" (ie: required permission), adev/build
will generate blank (0-byte)assets/error-(404|500).html
files.