summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries2012-12-17 21:56:35 (GMT)
committerDries2012-12-17 21:56:35 (GMT)
commit2aa87d3993eccf8684010fd11b7051ec7fcc79f2 (patch)
treefcb5c6e544a1c59030a724ed26a12a21ae83ccbe
parentf55649698c3168b7ccb6dce2ed7b5e9bf8b2adbb (diff)
Issue #1778478 by dstol, cam8001, Albert Volkman, japicoder, ACF: Convert fast_404 to CMI.
-rw-r--r--core/lib/Drupal/Core/ExceptionController.php10
-rw-r--r--core/modules/system/config/system.fast_404.yml4
-rw-r--r--core/modules/system/system.install13
-rw-r--r--sites/default/default.settings.php32
4 files changed, 30 insertions, 29 deletions
diff --git a/core/lib/Drupal/Core/ExceptionController.php b/core/lib/Drupal/Core/ExceptionController.php
index d08e1cf..352ffea 100644
--- a/core/lib/Drupal/Core/ExceptionController.php
+++ b/core/lib/Drupal/Core/ExceptionController.php
@@ -156,11 +156,13 @@ class ExceptionController extends ContainerAware {
watchdog('page not found', check_plain($request->attributes->get('system_path')), NULL, WATCHDOG_WARNING);
// Check for and return a fast 404 page if configured.
- $exclude_paths = variable_get('404_fast_paths_exclude', FALSE);
- if ($exclude_paths && !preg_match($exclude_paths, $request->getPathInfo())) {
- $fast_paths = variable_get('404_fast_paths', FALSE);
+ $config = config('system.fast_404');
+
+ $exclude_paths = $config->get('exclude_paths');
+ if ($config->get('enabled') && $exclude_paths && !preg_match($exclude_paths, $request->getPathInfo())) {
+ $fast_paths = $config->get('paths');
if ($fast_paths && preg_match($fast_paths, $request->getPathInfo())) {
- $fast_404_html = variable_get('404_fast_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>');
+ $fast_404_html = $config->get('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
new file mode 100644
index 0000000..731c8bb
--- /dev/null
+++ b/core/modules/system/config/system.fast_404.yml
@@ -0,0 +1,4 @@
+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>'
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 0b3bfef..ac70335 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -2349,6 +2349,19 @@ function system_update_8043() {
}
/**
+ * Moves system fast 404 settings from variable to config.
+ *
+ * @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',
+ ));
+}
+
+/**
* @} End of "defgroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
*/
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index e0d69bd..8d123d2 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -484,37 +484,19 @@ ini_set('session.cookie_lifetime', 2000000);
*
* The options below return a simple, fast 404 page for URLs matching a
* specific pattern:
- * - 404_fast_paths_exclude: A regular expression to match paths to exclude,
+ * - $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.
- * - 404_fast_paths: A regular expression to match paths that should return a
+ * - $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.
- * - 404_fast_html: The html to return for simple 404 pages.
+ * - $conf['system.fast_404']['html']: The html to return for simple 404 pages.
*
- * Add leading hash signs if you would like to disable this functionality.
+ * Remove the leading hash signs if you would like to alter this functionality.
*/
-$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//';
-$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i';
-$conf['404_fast_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>';
-
-/**
- * By default the page request process will return a fast 404 page for missing
- * files if they match the regular expression set in '404_fast_paths' and not
- * '404_fast_paths_exclude' above. 404 errors will simultaneously be logged in
- * the Drupal system log.
- *
- * You can choose to return a fast 404 page earlier for missing pages (as soon
- * as settings.php is loaded) by uncommenting the line below. This speeds up
- * server response time when loading 404 error pages and prevents the 404 error
- * from being logged in the Drupal system log. In order to prevent valid pages
- * such as image styles and other generated content that may match the
- * '404_fast_html' regular expression from returning 404 errors, it is necessary
- * to add them to the '404_fast_paths_exclude' regular expression above. Make
- * sure that you understand the effects of this feature before uncommenting the
- * line below.
- */
-# drupal_fast_404();
+#$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>';
/**
* External access proxy settings: