Unverified Commit 3245d571 authored by Alex Pott's avatar Alex Pott
Browse files

perf: #3564937 Remove duplicative caching of views rows

By: catch
parent 9e6f0a2c
Loading
Loading
Loading
Loading
Loading
+10
Changes for core/modules/views/src/Plugin/views/cache/CachePluginBase.php: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -338,8 +338,13 @@ public function getRowCacheTags(ResultRow $row) {
   *
   * @return string[]
   *   The row cache keys.
   *
   * @deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. There
   * is no replacement.
   * @see https://www.drupal.org/node/3564958
   */
  public function getRowCacheKeys(ResultRow $row) {
    @trigger_error(__METHOD__ . ' is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. There is no replacement. See https://www.drupal.org/node/3564958', E_USER_DEPRECATED);
    return [
      'views',
      'fields',
@@ -357,8 +362,13 @@ public function getRowCacheKeys(ResultRow $row) {
   *
   * @return string
   *   The row identifier.
   *
   * @deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. There
   * is no replacement.
   * @see https://www.drupal.org/node/3564958
   */
  public function getRowId(ResultRow $row) {
    @trigger_error(__METHOD__ . ' is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. There is no replacement. See https://www.drupal.org/node/3564958', E_USER_DEPRECATED);
    // Here we compute a unique identifier for the row by computing the hash of
    // its data. We exclude the current index, since the same row could have a
    // different result index depending on the user permissions. We exclude also
−11
Changes for core/modules/views/src/Plugin/views/style/StylePluginBase.php: 0 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -686,24 +686,13 @@ protected function renderFields(array $result) {
        foreach ($result as $index => $row) {
          $this->view->row_index = $index;

          // Here we implement render caching for result rows. Since we never
          // build a render array for single rows, given that style templates
          // need individual field markup to support proper theming, we build
          // a raw render array containing all field render arrays and cache it.
          // This allows us to cache the markup of the various children, that is
          // individual fields, which is then available for style template
          // preprocess functions, later in the rendering workflow.
          // @todo Fetch all the available cached row items in one single cache
          //   get operation, once https://www.drupal.org/node/2453945 is fixed.
          $data = [
            '#pre_render' => [[$this, 'elementPreRenderRow']],
            '#row' => $row,
            '#cache' => [
              'keys' => $cache_plugin->getRowCacheKeys($row),
              'tags' => $cache_plugin->getRowCacheTags($row),
              'max-age' => $max_age,
            ],
            '#cache_properties' => $field_ids,
          ];
          $renderer->addCacheableDependency($data, $this->view->storage);
          // Views may be rendered both inside and outside a render context:
−503

File deleted.

Preview size limit exceeded, changes collapsed.

−225

File deleted.

Loading