Problem/Motivation
While indexing a page I get an error "RuntimeException while trying to render item entity:node/10006:de with view mode search_index for search index Index A: Failed to start the session because headers have already been sent by "/app/vendor/symfony/http-foundation/Response.php" at line 1285. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 116 of /app/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php)."
The stack trace indicates this starts in CookiePreviewDetector::isPreviewing method.
#0 /app/docroot/core/lib/Drupal/Core/Session/SessionManager.php(129): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
#1 /app/docroot/core/lib/Drupal/Core/Session/SessionManager.php(94): Drupal\Core\Session\SessionManager->startNow()
#2 /app/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php(282): Drupal\Core\Session\SessionManager->start()
#3 /app/vendor/symfony/http-foundation/Session/Session.php(201): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->getBag('attributes')
#4 /app/vendor/symfony/http-foundation/Session/Session.php(221): Symfony\Component\HttpFoundation\Session\Session->getBag('attributes')
#5 /app/vendor/symfony/http-foundation/Session/Session.php(69): Symfony\Component\HttpFoundation\Session\Session->getAttributeBag()
#6 /app/docroot/modules/contrib/entity_reference_preview/src/Plugin/PreviewDetector/CookiePreviewDetector.php(51): Symfony\Component\HttpFoundation\Session\Session->get('entity_referenc...')
#7 /app/docroot/modules/contrib/entity_reference_preview/src/Cache/StatusPreviewCacheContext.php(68): Drupal\entity_reference_preview\Plugin\PreviewDetector\CookiePreviewDetector->isPreviewing(Object(Symfony\Component\HttpFoundation\Request))
#8 [internal function]: Drupal\entity_reference_preview\Cache\StatusPreviewCacheContext->Drupal\entit
Steps to reproduce
Set up Search API.
Enable this module.
Used the rendered output plugin in your search index.
Check the logs.
Proposed resolution
We should check that the session is actually started before trying to access the cookie. That gets rid of the error for me. If it hasn't just return FALSE. I don't think returning FALSE really matters in search index because you only want to render default revision content.
Remaining tasks
N/A
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Issue fork entity_reference_preview-3605600
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
achapComment #5
steven jones commentedThanks! LGTM.
Comment #7
steven jones commented