- 🇦🇹Austria drunken monkey Vienna, Austria
See 🐛 Rendered item is not indexed in groups content using layout builder Needs work for a ticket which proposes to set a specific user while indexing. That’s where you’d want to make that change: in the
\Drupal\search_api\Plugin\search_api\processor\RenderedItem::addFieldValues()
method, where the call to$this->getAccountSwitcher()->switchTo()
is made.
Another way would be to usedebug_backtrace()
and look (for example) for\Drupal\search_api\Entity\Index::indexSpecificItems()
.
Finally, you could listen to the\Drupal\search_api\Event\IndexingItemsEvent
(search_api.indexing_items
) and\Drupal\search_api\Event\ItemsIndexedEvent
(search_api.items_indexed
) events and set/unset some global state between them. This could only cause problems when all items fail indexing, but even then it’s probably no big deal if your workaround is active for the rest of the page request – it will either be right at the end anyways, or in a batch process, or in Drush, and in none of these cases a node would get rendered after indexing happens.I hope this helps.
- 🇺🇸United States michelle Wisconsin, USA
Thanks, that other ticket looks useful. I'll dig into that one once the client prioritizes this again. It would be nice to have a more stable solution than the hack-around I did.
Automatically closed - issue fixed for 2 weeks with no activity.