From 277d8fe978adcdfbacae9c5b2af3042738850096 Mon Sep 17 00:00:00 2001
From: webchick <webchick@24967.no-reply.drupal.org>
Date: Sun, 10 Mar 2013 12:14:36 -0700
Subject: [PATCH] Issue #1934716 by alexpott: Merge system.fast_404 config
 object into system.performance.

---
 core/lib/Drupal/Core/ExceptionController.php  | 10 ++++----
 .../modules/system/config/system.fast_404.yml |  4 ----
 .../system/config/system.performance.yml      |  6 ++++-
 .../Tests/Upgrade/SystemUpgradePathTest.php   |  6 +++++
 core/modules/system/system.install            |  8 +++----
 .../upgrade/drupal-7.system.database.php      | 12 ++++++++++
 sites/default/default.settings.php            | 23 +++++++++++--------
 7 files changed, 45 insertions(+), 24 deletions(-)
 delete mode 100644 core/modules/system/config/system.fast_404.yml

diff --git a/core/lib/Drupal/Core/ExceptionController.php b/core/lib/Drupal/Core/ExceptionController.php
index 807efae9d375..48bb6a1f25b5 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 731c8bbcff5b..000000000000
--- 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: '<!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/config/system.performance.yml b/core/modules/system/config/system.performance.yml
index 80f349a1b5d9..018803207d45 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: '<!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'
-
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 30399d6a8660..56c40c608d27 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' => '<!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(
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 882a049f7de5..08a9fd90863c 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 5bf6f296d0c5..a14546476740 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:"<!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')
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index b2fbc9086848..319db29e68b6 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'] = '<!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.
-- 
GitLab