Problem/Motivation

What are the steps required to reproduce the bug?

  1. Create a view listing "Content" (nodes).
  2. Add a "Entity Reference" Display.
  3. Save the view.
  4. Add a "Content reference" (entity reference for nodes) field to a node bundle (ie Article).
  5. Select "views: Filter by an entity reference view".
  6. Save the field settings.
  7. Edit the created field.

What behaviour were you expecting?

  1. Create a view.
  2. Create a view mode.
  3. Save the view.
  4. Get to the next screens.
  5. See the view created in the first step.
  6. Get back to the fields overview page.
  7. Get to the field edit page.

What happened instead?

  1. Create a view. (ok)
  2. Create a view mode. (ok)
  3. Save the view. (ok)
  4. Get to the next screens. (ok)
  5. The view is NOT available, no error that no view is available is displayed.
  6. Get back to the fields overview page. (ok)
  7. Recoverable fatal error!

Proposed resolution

Remaining tasks

User interface changes

API changes

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because the expectation is not met.
Issue priority Major because it is a significant regression with a fatal, but not critical because it only affects this one specific feature.

Comments

xjm’s picture

Issue summary: View changes
Issue tags: +VDC

Thanks @bircher, good find and very clear steps to reproduce.

Agreed that this is major per: https://www.drupal.org/core/issue-priority#major-bugs It's a significant bug (and a regression), but ER and Views are still usable overall, and we would not block release on it.

geertvd’s picture

Status: Active » Needs review
Issue tags: +drupaldevdays
StatusFileSize
new1.14 KB

This fixes that. Working on test coverage.

geertvd’s picture

StatusFileSize
new2.17 KB
new3.32 KB

Added test.

The last submitted patch, 3: entity_reference_views-2472421-3-test.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 3: entity_reference_views-2472421-3-complete.patch, failed testing.

bircher’s picture

Status: Needs work » Needs review
StatusFileSize
new3.8 KB
new1.89 KB

asserting the right text does make the test green.
But the issue is also that the created view doesn't show up.

bircher’s picture

Status: Needs review » Needs work

just for the test bot to verify.
The manual test doesn't show the view, and we should also add a test that asserts that the view is shown when it exists.

The last submitted patch, 6: 2472421-6.patch, failed testing.

geertvd’s picture

StatusFileSize
new3.88 KB
new3.25 KB
new4.94 KB

Ok, I overlooked that the view should have actually been there and just fixed the fatal error.
In this one the eligible views are found correctly, I also added some more tests to demonstrate this.

geertvd’s picture

Status: Needs work » Needs review

The last submitted patch, 9: 2472421-9-test.patch, failed testing.

nickdickinsonwilde’s picture

https://www.drupal.org/node/2454481 is an *older* bug report that this fully fixes (since this has a test case and identical fixes) as well as fixing further problems.

dawehner’s picture

Thank you for finding the old issue, I totally forgot about that. Marked that one as duplicate of this issue.

+++ b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
@@ -110,7 +110,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
       list($view, $display_id) = $data;
-      if ($view->storage->get('base_table') == $entity_type->getBaseTable()) {
+      if ($view->storage->get('base_table') == $entity_type->getDataTable()) {

Its not that always. I'd vote for if (in_array($view->storage->get('base_table'), [$entity_type->getBaseTable(), $entity_type->getDataTable()], given that there might be entity types without a data table

jibran’s picture

Status: Needs review » Needs work

NW for #13

geertvd’s picture

StatusFileSize
new955 bytes
new4.98 KB

Fixed feedback in #13

geertvd’s picture

Status: Needs work » Needs review
geertvd’s picture

jibran’s picture

Thank you @geertvd for updating the patch.

+++ b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
@@ -110,7 +110,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
+      if (in_array($view->storage->get('base_table'), [$entity_type->getBaseTable(), $entity_type->getDataTable()])) {

@dawehner do you think we should add tests for this change because this seems to me a very important piece of the puzzle.

dawehner’s picture

@dawehner do you think we should add tests for this change because this seems to me a very important piece of the puzzle.

Yeah we absolutely should! So once for an entity type with just a base table and one with also a data table.

geertvd’s picture

StatusFileSize
new7.89 KB
new9.62 KB
new5.56 KB

Extended the test a bit, we are also testing this with entity_test now so we should have test coverage in case we just use base table also.

The last submitted patch, 20: 2472421-20-test.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 20: 2472421-20-complete.patch, failed testing.

bircher queued 20: 2472421-20-complete.patch for re-testing.

geertvd’s picture

Status: Needs work » Needs review
berdir’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, test coverage looks good now I think.

People who are interested in this might also be interested in two other ViewsSelection bugs:

#2482625: Views entity reference selection with autocomplete widget broken and #2482705: ViewsSelection::validateAutocompleteInput is not implemented

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed f7c357e and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed f7c357e on 8.0.x
    Issue #2472421 by geertvd, bircher, dawehner, jibran: Entity reference,...

Status: Fixed » Closed (fixed)

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