Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291555

Leverage entityDisplay to provide fast rendering for fields

$
0
0

Proposed commit message

Issue #1867518 by plach, dawehner, epari.siva, Fabianx, yched, Wim Leers, marcvangend: Leverage entityDisplay to provide fast rendering for fields

Problem/Motivation

Rendering entity fields in views works like the following:

For reach row, and for each entity field execute the following code:

<?php
$entity
->$field_name->view();
?>

This creates a lot of temporary objects, as some benchmarks here and in #2342045: Standard views base fields need to use same rendering as Field UI fields, for formatting, access checking, and translation consistency has shown.

Proposed resolution

Based on #1852966: Rework entity display settings around EntityDisplay config entity views could use the entityDisplay object to render with better performance.

Basically, the idea is a View should :

  • run its query
  • load the corresponding entities and group them by entity type
  • for each entity type
    • create a runtime EntityViewDisplay object
    • render each field for all entities in one pass via EntityViewDisplay::buildFieldMultiple() and store the result
  • for each row/entity and each field in the row, pick the field renderable array in the $build array.

Remaining tasks

  • Validate the current solution
  • Write a patch
  • Reviews

User interface changes

None

API changes

Additional methods EntityViewDisplay::buildField() and EntityViewDisplay::buildFieldMultiple() that instantiate field formatters on demand without needing an EVD configuration entity.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue categoryTask becausethe functionality is not broken
Issue priorityCritical because of the performance improvements introduced.
DisruptionDisruptive for contributed/custom classes extending \Drupal\views\Plugin\views\field\Field::getItems().

Viewing all articles
Browse latest Browse all 291555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>