Commit 277d8fe9 authored by webchick's avatar webchick

Issue #1934716 by alexpott: Merge system.fast_404 config object into system.performance.

parent c0995955
......@@ -137,13 +137,13 @@ public function on404Html(FlattenException $exception, Request $request) {
watchdog('page not found', check_plain($request->attributes->get('system_path')), NULL, WATCHDOG_WARNING);
// Check for and return a fast 404 page if configured.
$config = config('system.fast_404');
$config = config('system.performance');
$exclude_paths = $config->get('exclude_paths');
if ($config->get('enabled') && $exclude_paths && !preg_match($exclude_paths, $request->getPathInfo())) {
$fast_paths = $config->get('paths');
$exclude_paths = $config->get('fast_404.exclude_paths');
if ($config->get('fast_404.enabled') && $exclude_paths && !preg_match($exclude_paths, $request->getPathInfo())) {
$fast_paths = $config->get('fast_404.paths');
if ($fast_paths && preg_match($fast_paths, $request->getPathInfo())) {
$fast_404_html = $config->get('html');
$fast_404_html = $config->get('fast_404.html');
$fast_404_html = strtr($fast_404_html, array('@path' => check_plain($request->getUri())));
return new Response($fast_404_html, 404);
}
......
enabled: '1'
paths: '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'
exclude_paths: '/\/(?:styles)\//'
html: '<!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>'
......@@ -5,6 +5,11 @@ cache:
css:
preprocess: '0'
gzip: '1'
fast_404:
enabled: '1'
paths: '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'
exclude_paths: '/\/(?:styles|imagecache)\//'
html: '<!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>'
js:
preprocess: '0'
gzip: '1'
......@@ -12,4 +17,3 @@ response:
gzip: '0'
stale_file_threshold: '2592000'
theme_link: '1'
......@@ -55,6 +55,12 @@ public function testVariableUpgrade() {
'response.gzip' => '1',
'js.preprocess' => '1',
'css.preprocess' => '1',
'fast_404' => array(
'enabled' => '1',
'paths' => '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|aspi|pdf)$/i',
'exclude_paths' => '/\/(?:styles|imagecache)\//',
'html' => '<!DOCTYPE html><html><head><title>Page Not Found</title></head><body><h1>Page Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>',
),
);
$expected_config['system.rss'] = array(
......
......@@ -2003,10 +2003,10 @@ function system_update_8043() {
* @ingroup config_upgrade
*/
function system_update_8044() {
update_variables_to_config('system.fast_404', array(
'404_fast_html' => 'html',
'404_fast_paths' => 'paths',
'404_fast_paths_exclude' => 'exclude_paths',
update_variables_to_config('system.performance', array(
'fast_404_html' => 'fast_404.html',
'fast_404_paths' => 'fast_404.paths',
'fast_404_paths_exclude' => 'fast_404.exclude_paths',
));
}
......
......@@ -123,6 +123,18 @@
'name' => 'mail_system',
'value' => 'a:2:{s:14:"default-system";s:17:"DefaultMailSystem";s:7:"maillog";s:17:"MaillogMailSystem";}',
))
->values(array(
'name' => 'fast_404_paths',
'value' => 's:74:"/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|aspi|pdf)$/i";',
))
->values(array(
'name' => 'fast_404_excluded_paths',
'value' => 's:27:"/\/(?:styles|imagecache)\//";',
))
->values(array(
'name' => 'fast_404_html',
'value' => 's:168:"<!DOCTYPE html><html><head><title>Page Not Found</title></head><body><h1>Page Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>";',
))
->execute();
db_update('variable')
......
......@@ -587,19 +587,22 @@
*
* The options below return a simple, fast 404 page for URLs matching a
* specific pattern:
* - $conf['system.fast_404']['exclude_paths']: A regular expression to match paths to exclude,
* such as images generated by image styles, or dynamically-resized images.
* If you need to add more paths, you can add '|path' to the expression.
* - $conf['system.fast_404']['paths']: A regular expression to match paths that should return a
* simple 404 page, rather than the fully themed 404 page. If you don't have
* any aliases ending in htm or html you can add '|s?html?' to the expression.
* - $conf['system.fast_404']['html']: The html to return for simple 404 pages.
* - $conf['system.performance]['fast_404']['exclude_paths']: A regular
* expression to match paths to exclude, such as images generated by image
* styles, or dynamically-resized images. If you need to add more paths, you
* can add '|path' to the expression.
* - $conf['system.performance]['fast_404']['paths']: A regular expression to
* match paths that should return a simple 404 page, rather than the fully
* themed 404 page. If you don't have any aliases ending in htm or html you
* can add '|s?html?' to the expression.
* - $conf['system.performance]['fast_404']['html']: The html to return for
* simple 404 pages.
*
* Remove the leading hash signs if you would like to alter this functionality.
*/
#$conf['system.fast_404']['exclude_paths'] = '/\/(?:styles)\//';
#$conf['system.fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i';
#$conf['system.fast_404']['html'] = '<!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>';
#$conf['system.performance]['fast_404']['exclude_paths'] = '/\/(?:styles)\//';
#$conf['system.performance]['fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i';
#$conf['system.performance]['fast_404']['html'] = '<!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>';
/**
* Load local development override configuration, if available.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment