diff --git a/core/lib/Drupal/Core/ExceptionController.php b/core/lib/Drupal/Core/ExceptionController.php index 807efae9d375b174edad1b38e471520578a968e6..48bb6a1f25b59f40985be9966e86212d5f334187 100644 --- a/core/lib/Drupal/Core/ExceptionController.php +++ b/core/lib/Drupal/Core/ExceptionController.php @@ -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); } diff --git a/core/modules/system/config/system.fast_404.yml b/core/modules/system/config/system.fast_404.yml deleted file mode 100644 index 731c8bbcff5b63fbf89f87cc73f9099c25180e63..0000000000000000000000000000000000000000 --- a/core/modules/system/config/system.fast_404.yml +++ /dev/null @@ -1,4 +0,0 @@ -enabled: '1' -paths: '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i' -exclude_paths: '/\/(?:styles)\//' -html: '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

' diff --git a/core/modules/system/config/system.performance.yml b/core/modules/system/config/system.performance.yml index 80f349a1b5d9a5ac53d745ab7de3f4a972ffd68c..018803207d4541be82798fae0333b4a9cbe6c253 100644 --- a/core/modules/system/config/system.performance.yml +++ b/core/modules/system/config/system.performance.yml @@ -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: '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

' js: preprocess: '0' gzip: '1' @@ -12,4 +17,3 @@ response: gzip: '0' stale_file_threshold: '2592000' theme_link: '1' - diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php index 30399d6a86606c409aae3deff74f5bd8f2ff9204..56c40c608d274d618dfda72d4f596c91772197ef 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php @@ -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' => 'Page Not Found

Page Not Found

The requested URL "@path" was not found on this server.

', + ), ); $expected_config['system.rss'] = array( diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 882a049f7de52acad72eabccaa6d9ca6f1a6f3b0..08a9fd90863c803a4c4ce127defe95e819e70451 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -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', )); } diff --git a/core/modules/system/tests/upgrade/drupal-7.system.database.php b/core/modules/system/tests/upgrade/drupal-7.system.database.php index 5bf6f296d0c524236769291bf43c15689c440a9f..a1454647674035bea06fbe1a9e27a01e4ba0be26 100644 --- a/core/modules/system/tests/upgrade/drupal-7.system.database.php +++ b/core/modules/system/tests/upgrade/drupal-7.system.database.php @@ -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:"Page Not Found

Page Not Found

The requested URL "@path" was not found on this server.

";', + )) ->execute(); db_update('variable') diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index b2fbc90868481b5f58ae8f07b4371007af35def7..319db29e68b6d4f45163d4125b3523c0120b2733 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -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'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; +#$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'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; /** * Load local development override configuration, if available.