mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Prioritize static error pages in ErrorPage::response_for() (otherwise any 404 will be a major performance hit)
This commit is contained in:
parent
32548a9b3b
commit
51a0a806fc
@ -33,12 +33,7 @@ class ErrorPage extends Page {
|
||||
* @return SS_HTTPResponse
|
||||
*/
|
||||
public static function response_for($statusCode) {
|
||||
// first attempt to dynamically generate the error page
|
||||
if($errorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = $statusCode")) {
|
||||
return ModelAsController::controller_for($errorPage)->handleRequest(new SS_HTTPRequest('GET', ''));
|
||||
}
|
||||
|
||||
// then fall back on a cached version
|
||||
// first look for cached files
|
||||
$cachedPath = self::get_filepath_for_errorcode($statusCode, Translatable::get_current_locale());
|
||||
|
||||
if(file_exists($cachedPath)) {
|
||||
@ -48,6 +43,9 @@ class ErrorPage extends Page {
|
||||
$response->setBody(file_get_contents($cachedPath));
|
||||
|
||||
return $response;
|
||||
} else if($errorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = $statusCode")) {
|
||||
// then attempt to dynamically generate the error page
|
||||
return ModelAsController::controller_for($errorPage)->handleRequest(new SS_HTTPRequest('GET', ''));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user