Problem/Motivation

When you setup an entity reference using a view as selection plugin but you don't have any valid item in the view, \Drupal\views\Plugin\views\display\EntityReference::render will return an empty string, which is problematic as otherwise its an array.

Proposed resolution

Return an empty array.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#8 interdiff-5-8.txt632 bytesAnonymous (not verified)
#8 2864922-8.patch1.57 KBAnonymous (not verified)
#5 2864922-5.patch1.38 KBAnonymous (not verified)
#5 2864922-5-test-only.patch854 bytesAnonymous (not verified)
#2 2864922-2.patch569 bytesdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner created an issue. See original summary.

dawehner’s picture

Status: Active » Needs review
FileSize
569 bytes
Lendude’s picture

Should we also update the docblock on \Drupal\views\Plugin\views\display\DisplayPluginInterface to specify that this needs to return an array?

If we categorise this as a bug, this would need a test. Feels more like a task really.

dawehner’s picture

Should we also update the docblock on \Drupal\views\Plugin\views\display\DisplayPluginInterface to specify that this needs to return an array?

Well it just needs to return an array for entity references.

Anonymous’s picture

The last submitted patch, 5: 2864922-5-test-only.patch, failed testing. View results

Lendude’s picture

@vaplas nice!

Well it just needs to return an array for entity references.

Well it would be nice to document this somewhere, even if it's just an inline comment before the return statement. But I think we need to update the docblock for \Drupal\views\Plugin\views\display\EntityReference::render and not have it @inheritdoc, but make it explicit that this needs to return an array, in case anybody wants to extend from this, because they will need to take this into account too.

Anonymous’s picture

@Lendude, thank you!

Lendude’s picture

Status: Needs review » Reviewed & tested by the community

@vaplas thanks!

jibran’s picture

Issue tags: +Quickfix

  • catch committed 0287e53 on 8.4.x
    Issue #2864922 by vaplas, dawehner, Lendude: \Drupal\views\Plugin\views\...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.4.x, thanks!

Status: Fixed » Closed (fixed)

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