Problem/Motivation

Using the block entity_field (Drupal\ctools_block\Plugin\Block\EntityField) causes creation of the render array twice due to the fact that the field->view is executed once in blockAccess() and once in build().

This is introduced in #2804165: Missing check for empty field when building ctools block.

This causes issues when an entity reference field to i.e. a webform is used, where validation and submissions are handled twice because the ->view function gets called twice.

Proposed resolution

Either reuse the created render array in build() again or use access() hook only for access and handle emptyness of fields somewhere else (in build() ?).

Remaining tasks

Implement solution.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eyilmaz created an issue. See original summary.

eyilmaz’s picture

eyilmaz’s picture

Issue summary: View changes
eyilmaz’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: ctools-entity_field_rendered_twice-2924356-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

eyilmaz’s picture

Status: Needs work » Needs review

Tests for 8.4 are passing, 8.5 tests are failing due to deprecation errors I think.

joseph.olstad’s picture

we've been using this for quite some time now

joseph.olstad’s picture

triggered some tests again, passes PHP 8.2, PHP 8.1, D10.0.x, D10.1.x

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

passes tests, we've been using this for quite some time already

joseph.olstad’s picture

Version: 8.x-3.x-dev » 4.1.x-dev

all branches