Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#8 | interdiff-5-8.txt | 632 bytes | Anonymous (not verified) |
#8 | 2864922-8.patch | 1.57 KB | Anonymous (not verified) |
#5 | 2864922-5.patch | 1.38 KB | Anonymous (not verified) |
#5 | 2864922-5-test-only.patch | 854 bytes | Anonymous (not verified) |
#2 | 2864922-2.patch | 569 bytes | dawehner |
Comments
Comment #2
dawehnerComment #3
LendudeShould 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.
Comment #4
dawehnerWell it just needs to return an array for entity references.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #7
Lendude@vaplas nice!
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.Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commented@Lendude, thank you!
Comment #9
Lendude@vaplas thanks!
Comment #10
jibranComment #12
catchCommitted/pushed to 8.4.x, thanks!