Commit c5a59dfe authored by Eugene Bocharov's avatar Eugene Bocharov Committed by Thomas Seiber
Browse files

Issue #3258375 by Eugene Bocharov, wells, drunken monkey, joshuami,...

Issue #3258375 by Eugene Bocharov, wells, drunken monkey, joshuami, MrDaleSmith, Grayle: Fixed out-of-memory error when used with Views, Metatag and caching.
parent d113624d
Loading
Loading
Loading
Loading
+2 −0
Changes for CHANGELOG.txt: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
Search API 1.x, dev (xxxx-xx-xx):
---------------------------------
- #3258375 by Eugene Bocharov, wells, drunken monkey, joshuami, MrDaleSmith,
  Grayle: Fixed out-of-memory error when used with Views, Metatag and caching.
- #3270324 by drunken monkey, kimberleycgm: Fixed incorrect storing of
  "Rendered item" processor setting "roles".
- #3266715 by kimberleycgm, drunken monkey: Fixed "Rendered item" processor not
+24 −1
Changes for src/Plugin/views/ResultRow.php: 24 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\search_api\Plugin\views;

use Drupal\views\ResultRow as ViewsResultRow;
use Drupal\views\ViewExecutable;

/**
 * A class representing a result row of a Search API-based view.
@@ -72,7 +73,7 @@ class ResultRow extends ViewsResultRow {
  }

  /**
   * Implements the magic __wakeup() method to lazy-load certain properties.
   * Implements the magic __get() method to lazy-load certain properties.
   */
  public function __get($name) {
    $properties = get_object_vars($this);
@@ -90,4 +91,26 @@ class ResultRow extends ViewsResultRow {
    return NULL;
  }

  /**
   * Implements the magic __sleep() method to remove the view from the entity.
   *
   * The "view" property is added by the "Rendered entity" row plugin in
   * \Drupal\search_api\Plugin\views\row\SearchApiRow::preRender() to make it
   * available to entity viewing code. It should not be needed elsewhere, but
   * can cause problems (including infinite loops) when Views results are
   * serialized (as done, for instance, by the Metatag module in some setups).
   *
   * @return string[]
   *   An array with the names of all object properties.
   */
  public function __sleep() {
    if (!empty($this->_object)) {
      $entity = $this->_object->getValue();
      if (($entity->view ?? NULL) instanceof ViewExecutable) {
        unset($entity->view);
      }
    }
    return array_keys(get_object_vars($this));
  }

}