Commit 62fd3516 authored by Lars Schröter's avatar Lars Schröter Committed by Thomas Seiber
Browse files

Issue #2869103 by osopolar, drunken monkey: Fixed problems with theme cache...

Issue #2869103 by osopolar, drunken monkey: Fixed problems with theme cache when indexing the "Rendered HTML output" field.
parent ddd534f8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
Search API 1.x, dev (xxxx-xx-xx):
---------------------------------
- #2869103 by osopolar, drunken monkey: Fixed problems with theme cache when
  indexing the "Rendered HTML output" field.
- #3229495 by AndyF, drunken monkey: Fixed "start batch tracking" functionality
  for indexes.
- #3238635 by drunken monkey, mkalkbrenner: Added the
+18 −4
Original line number Diff line number Diff line
@@ -231,14 +231,22 @@ class RenderedItem extends ProcessorPluginBase {
   * {@inheritdoc}
   */
  public function addFieldValues(ItemInterface $item) {
    // Switch to the default theme in case the admin theme is enabled.
    // Switch to the default theme in case the admin theme (or any other theme)
    // is enabled.
    $active_theme = $this->getThemeManager()->getActiveTheme();
    $default_theme = $this->getConfigFactory()
      ->get('system.theme')
      ->get('default');
    $default_theme = $this->getThemeInitializer()
      ->getActiveThemeByName($default_theme);
    $active_theme_switched = FALSE;
    if ($default_theme->getName() !== $active_theme->getName()) {
      $this->getThemeManager()->setActiveTheme($default_theme);
      // Ensure that static cached default variables are set correctly,
      // especially the directory variable.
      drupal_static_reset('template_preprocess');
      $active_theme_switched = TRUE;
    }

    // Fields for which some view mode config is missing.
    $unset_view_modes = [];
@@ -294,8 +302,14 @@ class RenderedItem extends ProcessorPluginBase {

    // Restore the original user.
    $this->getAccountSwitcher()->switchBack();
    // Restore the original theme.

    // Restore the original theme if themes got switched before.
    if ($active_theme_switched) {
      $this->getThemeManager()->setActiveTheme($active_theme);
      // Ensure that static cached default variables are set correctly,
      // especially the directory variable.
      drupal_static_reset('template_preprocess');
    }

    if ($unset_view_modes > 0) {
      foreach ($unset_view_modes as $field_id => $field_label) {