Using the fast404.inc approach throws errors

Created on 16 April 2018, over 6 years ago
Updated 2 June 2023, over 1 year ago

Loading the fast404.inc file from settings.php and calling fast404_preboot($settings); is broken. This approach is outlined in the README.txt.

When $settings['fast404_path_check'] = TRUE;, Drupal attempts to run db queries and access the service container without either of these being established.

The website encountered an unexpected error. Please try again later.
Drupal\Core\DependencyInjection\ContainerNotInitializedException: \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container. in Drupal::getContainer() (line 129 of /var/www/docroot/core/lib/Drupal.php).

When $fast_404->extensionCheck(); is run, Drupal will return Cannot modify header information errors.

RuntimeException: Failed to start the session because headers have already been sent by "/var/www/sitename/vendor/symfony/http-foundation/Response.php" at line 376. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 141 of /var/www/sitename/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php) #0
/var/www/sitename/docroot/core/lib/Drupal/Core/Session/SessionManager.php(164): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() #1 /var/www/sitename/docroot/core/lib/Drupal/Core/Session/SessionManager.php(195): Drupal\Core\Session\SessionManager->startNow() #2 /var/www/sitename/vendor/symfony/http-foundation/Session/Session.php(196): Drupal\Core\Session\SessionManager->save() #3 /var/www/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(60): Symfony\Component\HttpFoundation\Session\Session->save() #4 /var/www/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #5 /var/www/sitename/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(184): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #6 /var/www/sitename/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(121): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true) #7 /var/www/sitename/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(75): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true) #8 /var/www/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #9 /var/www/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #10 /var/www/sitename/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #11 /var/www/sitename/docroot/core/lib/Drupal/Core/DrupalKernel.php(666): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #12 /var/www/sitename/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #13 {main}.
Warning: Cannot modify header information - headers already sent by (output started at /var/www/sitename/vendor/symfony/http-foundation/Response.php:376) in Drupal\fast404\Fast404->response() (line 202 of /var/www/sitename/docroot/modules/contrib/fast_404/src/Fast404.php) #0
 /var/www/sitename/docroot/core/includes/bootstrap.inc(582): _drupal_error_handler_real(2, 'Cannot modify h...', '/var/www/sitename/do...', 202, Array) #1 [internal function]: _drupal_error_handler(2, 'Cannot modify h...', '/var/www/sitename/do...', 202, Array) #2 /var/www/sitename/docroot/modules/contrib/fast_404/src/Fast404.php(202): header('HTTP/1.0 404 No...') #3 /var/www/sitename/docroot/modules/contrib/fast_404/src/EventSubscriber/Fast404EventSubscriber.php(52): Drupal\fast404\Fast404->response(true) #4 [internal function]: Drupal\fast404\EventSubscriber\Fast404EventSubscriber->onKernelRequest(Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #5 /var/www/sitename/docroot/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #6 /var/www/sitename/vendor/symfony/http-kernel/HttpKernel.php(127): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.request', Object(Symfony\Component\HttpKernel\Event\GetResponseEvent)) #7 /var/www/sitename/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #8 /var/www/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #9 /var/www/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #10 /var/www/sitename/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(184): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #11 /var/www/sitename/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(121): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true) #12 /var/www/sitename/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(75): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true) #13 /var/www/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #14 /var/www/sitename/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #15 /var/www/sitename/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /var/www/sitename/docroot/core/lib/Drupal/Core/DrupalKernel.php(666): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /var/www/sitename/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #18 {main}.
πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jasonawant New Orleans, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024