Problem/Motivation

Let's assume we have a single field entity display object:

  public function buildMultiple(array $entities) {
    $build_list = array();
    foreach ($entities as $key => $entity) {
      $build_list[$key] = array();
    }

    // Run field formatters.
    foreach ($this->getFieldDefinitions() as $field_name => $definition) {
      if ($formatter = $this->getRenderer($field_name)) {
        // Group items across all entities and pass them to the formatter's
        // prepareView() method.

... So we still iterate over all field definitions, even we just render a single field.

Similar on a normal entity display rendering, we try it for all fields, even most fields are hidden.

Proposed resolution

Remaining tasks

User interface changes

API changes

CommentFileSizeAuthor
#2 2450151-optimize-EVD_build-2.patch3.27 KByched
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Issue tags: +Performance

.

yched’s picture

Status: Active » Needs review
FileSize
3.27 KB

Hm - I guess we could loop on $this->content instead.

Attached patch does this,
+ adjust EntityFormDisplay accordingly for consistency,
+ unifies a couple var names while I'm in there

dawehner’s picture

dawehner’s picture

Assigned: plach » Unassigned
Status: Needs review » Reviewed & tested by the community

The code changes looks great!

Wim Leers’s picture

Title: Don't try to render all fields for single entity display » Don't try to render all fields (including hidden ones) for single entity display

Patch looks clean & simple indeed :)

  • catch committed 94fb2af on 8.0.x
    Issue #2450151 by yched: Don't try to render all fields (including...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Good find. Committed/pushed to 8.0.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.