Problem/Motivation
Using the Simple XML sitemap view submodule, view pages that have enabled the "Index this display in sitemap Default" in the view settings are getting the following error only for logged-in users:
RuntimeException: Failed to start the session because headers have already been sent by "/var/www/html/vendor/symfony/http-foundation/Response.php" at line 410. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 132 of /var/www/html/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php)
#0 /var/www/html/web/core/lib/Drupal/Core/Session/SessionManager.php(144): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
#1 /var/www/html/web/core/lib/Drupal/Core/Session/SessionManager.php(109): Drupal\Core\Session\SessionManager->startNow()
#2 /var/www/html/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php(311): Drupal\Core\Session\SessionManager->start()
#3 /var/www/html/vendor/symfony/http-foundation/Session/Session.php(222): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->getBag('attributes')
#4 /var/www/html/vendor/symfony/http-foundation/Session/Session.php(242): Symfony\Component\HttpFoundation\Session\Session->getBag('attributes')
#5 /var/www/html/vendor/symfony/http-foundation/Session/Session.php(69): Symfony\Component\HttpFoundation\Session\Session->getAttributeBag()
#6 /var/www/html/web/core/modules/views/src/ViewExecutable.php(722): Symfony\Component\HttpFoundation\Session\Session->get('views')
#7 /var/www/html/web/core/modules/views/src/Form/ViewsExposedForm.php(85): Drupal\views\ViewExecutable->getExposedInput()
#8 [internal function]: Drupal\views\Form\ViewsExposedForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
#9 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array(Array, Array)
#10 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(283): Drupal\Core\Form\FormBuilder->retrieveForm('views_exposed_f...', Object(Drupal\Core\Form\FormState))
#11 /var/www/html/web/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php(134): Drupal\Core\Form\FormBuilder->buildForm('\\Drupal\\views\\F...', Object(Drupal\Core\Form\FormState))
#12 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1255): Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase->renderExposedForm()
#13 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1433): Drupal\views\ViewExecutable->build(NULL)
#14 /var/www/html/web/core/modules/views/views.module(778): Drupal\views\ViewExecutable->execute()
#15 [internal function]: views_get_view_result('general_search', 'page_news', '2')
#16 /var/www/html/web/modules/contrib/simple_sitemap/modules/simple_sitemap_views/src/SimpleSitemapViews.php(319): call_user_func_array('views_get_view_...', Array)
#17 /var/www/html/web/modules/contrib/simple_sitemap/modules/simple_sitemap_views/src/SimpleSitemapViews.php(252): Drupal\simple_sitemap_views\SimpleSitemapViews->addArgumentsToIndexByVariant(Object(Drupal\views\ViewExecutable), 'default', Array, 'page_news')
#18 /var/www/html/web/modules/contrib/simple_sitemap/modules/simple_sitemap_views/src/EventSubscriber/ArgumentCollector.php(83): Drupal\simple_sitemap_views\SimpleSitemapViews->addArgumentsToIndex(Object(Drupal\views\ViewExecutable), Array, 'page_news')
#19 [internal function]: Drupal\simple_sitemap_views\EventSubscriber\ArgumentCollector->onTerminate(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#20 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#21 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(115): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...')
#22 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(63): Symfony\Component\HttpKernel\HttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Render\HtmlResponse))
#23 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(688): Drupal\Core\StackMiddleware\StackedHttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Render\HtmlResponse))
#24 /var/www/html/web/index.php(22): Drupal\Core\DrupalKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Render\HtmlResponse))
#25 {main}
Proposed resolution
Based on other issues related to the header error, I tried to check if there was code similar to this
comment
🐛
RuntimeException: Failed to start the session because headers have already been sent
Closed: works as designed
, but it seems that the submodule or the module, in general, does not use RedirectResponse.
Did anyone have a similar problem?