Problem/Motivation

I created a view with multiple field instances of the same field. I used the the formatter but with different configuration. This bug was introduced since beta14. I could not figure out which change trigged the bug. I think is does not matter because logic in EntityFieldRenderer is buggy.

views.view_.test_2549033 was my test view. The view works with standard profile.

Current behaviour

Expected behaviour

Proposed resolution

Fix logic in EntityFieldRenderer

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug, because wrong configuration is used
Issue priority Major because there is no workaround

Comments

webflo created an issue. See original summary.

webflo’s picture

Issue summary: View changes
StatusFileSize
new71.34 KB
new9.73 KB
webflo’s picture

Status: Active » Needs review
StatusFileSize
new2.02 KB

The logic is a bit complex because we cluster by field_name but we need the field_id later to populate $build[$row_index][$field_id]

webflo’s picture

Issue summary: View changes
StatusFileSize
new67.01 KB
webflo’s picture

Issue summary: View changes
dawehner’s picture

Did maybe #2534780: Fatal error rendering fields using an optional relationship caused this break? I'm curious about that.

I think we should expand the test coverage in core/modules/views/src/Tests/Handler/FieldFieldTest.php in this case
What exactly did you asked for in IRC, actually a test or just a pointer?

webflo’s picture

StatusFileSize
new6.27 KB
new8.29 KB

@dawehner Just a pointer :)

I added the test coverage in FieldFieldTest::testComplexRender. I used the created field on the user because that bug happens with more than two field handlers of the same field. The date formatter is handy is this use case because its easy to create different outputs of the same field.

The last submitted patch, 7: 2549033-7-test-only.patch, failed testing.

dawehner’s picture

+++ b/core/modules/views/src/Tests/Handler/FieldFieldTest.php
@@ -376,26 +377,44 @@ public function testComplexRender() {
+    $this->assertEqual(format_date($this->testUsers[4]->getCreatedTime(), 'custom', 'Y'), $executable->getStyle()->getField(4, 'created'));

Even format_date() is not marked as deprecated it would be nicer if we could use \Drupal::service('date.formatter')->format() directly

webflo’s picture

StatusFileSize
new8.77 KB

Fixed #9

geertvd’s picture

Status: Needs review » Needs work

Tested this, this fixes the issue. Just some nitpicks

  1. +++ b/core/modules/views/src/Entity/Render/EntityFieldRenderer.php
    @@ -231,7 +233,7 @@ protected function buildFields(array $values) {
    +          foreach ($display_fields['field_ids'] as $field_id => $field) {
    

    we are not using $field_id here so let's cut it.

  2. +++ b/core/modules/views/src/Tests/Handler/FieldFieldTest.php
    @@ -371,31 +372,50 @@ public function testComplexExecute() {
    +
    ...
    +
    ...
    +
    

    Let's remove these double enters

geertvd’s picture

Status: Needs work » Needs review
StatusFileSize
new2.99 KB
new24.29 KB

Fixed those nitpicks

geertvd’s picture

StatusFileSize
new8.75 KB

Oops forgot to rebase

geertvd’s picture

Issue tags: +VDC
lendude’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Manually tested this and 'multiple field instances of the same field' in this case means 'more then 2' (2 instances don't show this bug, 3 do).

Using two different fields (UI wise) with the same field name and entity type (so combining content: 'authored on' and content revision:'authored on') also cause this bug to show itself if you have a total of more then 2 instances combined.

The patch fixes this.

All raised issues in previous comments are fixed. Looks good to me.

Added beta eval.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: views_field_rendering-2549033-13.patch, failed testing.

Status: Needs work » Needs review
lendude’s picture

Status: Needs review » Reviewed & tested by the community

Random test failure, back to RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_field_field_complex_test.yml
@@ -58,6 +58,45 @@ display:
+        created_2:
+          id: created_1

The id looks incorrect - I guess it is being ignored but rather than fix on the commit I think we need a fix and test.

geertvd’s picture

Status: Needs work » Needs review
StatusFileSize
new737 bytes
new8.75 KB

Thanks, totally missed that.

EDIT: Just saw I accidentally set a .patch extension on that interdiff, oops.

The last submitted patch, 20: interdiff-2549033-13-20.patch, failed testing.

geertvd’s picture

The last submitted patch, 20: interdiff-2549033-13-20.patch, failed testing.

lendude’s picture

Status: Needs review » Reviewed & tested by the community

Issue in #19 addressed, and if I understand @alexpott correctly, the issue with the faulty/duplicate id being ignored is out of scope for this issue, so back to RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 20: views_field_rendering-2549033-20.patch, failed testing.

Status: Needs work » Needs review
lendude’s picture

Status: Needs review » Reviewed & tested by the community

Random fail. Back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 7a8cb7a and pushed to 8.0.x. Thanks!

  • alexpott committed 7a8cb7a on 8.0.x
    Issue #2549033 by webflo, geertvd, Lendude: Views field rendering on...

Status: Fixed » Closed (fixed)

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