I had setup a custom block type with a link field. I created a block instance with it.
It looks like even without assigning that block to a region it produces errors and makes the front-end of the site render without its theme. The messages:
Notice: Undefined index: path in link_field_formatter_view() (line 376 of core/modules/link/link.module).
Notice: Undefined index: options in link_field_formatter_view() (line 377 of core/modules/link/link.module).
I'm not absolutely sure these notices are the cause for the theme not being rendered. I can't delete the block using the link field so bit hard to reproduce.
Related Issues
- will help #1818560-33: Convert taxonomy entities to the new Entity Field API
- see discussion in #1839068: Implement the new entity field API for the file field type
- included here and this might need reroll after #1822000: Remove Drupal\field_test\Plugin\Entity\Type\TestEntity in favor of EntityTest
Comment | File | Size | Author |
---|---|---|---|
#29 | field-attach-ng-1957748-29.patch | 4.83 KB | amateescu |
#29 | interdiff.txt | 2.82 KB | amateescu |
#24 | field-attach-ng-1957748-24.patch | 5.21 KB | Berdir |
#16 | link-formatter-1957748.16.interdiff.txt | 872 bytes | larowlan |
#16 | link-formatter-1957748.16.patch | 5.24 KB | larowlan |
Comments
Comment #1
larowlanComment #2
larowlanConfirming a fatal is thrown, hence the theme blows up
Comment #3
sunLoss of theme/page output is critical.
Comment #4
larowlan$item['path'] doesn't exist so far as I can see.
$item['options'] needs to be something else we get unsupported operand types.
Comment #5
sunComment #6
sunWhat happened to hook_field_prepare_view()?
http://drupalcode.org/project/drupal.git/blob/HEAD:/core/modules/link/li...
Why is it not called for blocks?
Comment #8
larowlanSun pointed out that link_field_prepare_view not running for custom block.
Comment #9
larowlanSo turns out hook_field_prepare_view() isn't passed the correct field values if the entity is an NG entity.
We need to invoke the BC.
Comment #11
tim.plunkettI'd think you'd have to set it back again in the second hunk as well? Not sure if that's the cause of the fails, I didn't try it.
Comment #12
larowlanComment #13
larowlanResetting back to original entity as per #11
Comment #14
larowlanNew title
Comment #16
larowlanWrong view mode.
Also, extra $language variable isn't used.
Comment #17
larowlanComment #18
BerdirComment #19
yoroy CreditAttribution: yoroy commentedI was wondering what kind of freak issue I had gotten subscribed to, but ah, this one :-)
Comment #20
Wim LeersAt the bottom of #1818560-33: Convert taxonomy entities to the new Entity Field API (below the last horizontal rule, "Finally: manual testing…"), I explained in detail what seems to be the same problem. Berdir pointed me to this issue in #34 of that issue.
I applied the patch in #16 to check if it'd fix things. Unfortunately, it does not, it causes the site to break entirely:
InvalidArgumentException: Property uuid is unknown. in Drupal\image\Type\ImageItem->setValue() (line 101 of <drupalroot>/core/modules/image/lib/Drupal/image/Type/ImageItem.php).
(This is on the taxonomy term page of a taxonomy term that has an image field associated with it.)
So, AFAICT, this patch has the potential to break Drupal, hence marking as NW.
Finally, AFAICT this is not isolated to "link" fields, since image fields are what's failing for me. If I'm conflating two different issues, then my apologies and feel free to go back to NR.
Comment #21
BerdirSee also the discussion in #1839068: Implement the new entity field API for the file field type where we already discovered and discussed some of these issues but then forgot about it.
Comment #22
sun#16: link-formatter-1957748.16.patch queued for re-testing.
Comment #24
BerdirSorry that it took me so long to have a look at this :)
field_attach_*() function never should be called with an EntityNG object, that simply doesn't work. So the fault is in EntityRenderController. The existing link field test already fail when ported to use EntityTest (which is NG) instead of TestEntity (which is not), so I just copied over my fix from #1822000: Remove Drupal\field_test\Plugin\Entity\Type\TestEntity in favor of EntityTest, where I'm working on this.
Given that, not sure if we need additional test coverage for this. that issue will provide test coverage as soon as we switch to NG and then this will be mostly a test duplicate. But I kept it for now. Can also try to get over just the link field tests from that issue not sure if they can be isolated easily.
Also fixed ImageItem to work like FieldItemBase and accept all additional things values, at least for now until we have converted everything, then we can switch to use ->entity for this.
Comment #25
BerdirOk, those tests actually call field_attach_*() directly, must have been others that failed. I do wonder if those tests should be converted to use EntityTest instead of a real entity and live in link.module or field.module?
Comment #26
Wim LeersWorks perfectly.
Comment #27
BerdirUnassigning @larowlan :)
Comment #28
alexpottI think we could do with a comment to explain what's going on here...
Comment #29
amateescu CreditAttribution: amateescu commentedActually, I think that what was going on there is totally unnecessary. Both
field_attach_prepare_view()
andfield_attach_view()
have the swtich to BC entities incorporated, the problem was that infield_attach_prepare_view()
it was called a bit late.Comment #30
BerdirOh, didn't know that.
It's a bit inconsistent with all other field_attach_*() functions right now, which except a BC entity. Maybe we should change all these others in a follow-up as well? That would simplify #1822000: Remove Drupal\field_test\Plugin\Entity\Type\TestEntity in favor of EntityTest a lot.
Comment #31
amateescu CreditAttribution: amateescu commentedSure, anything that makes that patch easier gets a huge ++ from me :)
Comment #32
fagoGood fix and comes with tests -> RTBC.
Comment #33
alexpottCommitted 0261175 and pushed to 8.x. Thanks!
Comment #34
amateescu CreditAttribution: amateescu commentedAlso, this doesn't have anything to do with link.module, it's more like.. Field API meets EntityNG, unpredictable things are bound to happen :)
Comment #35
amateescu CreditAttribution: amateescu commentedThanks, Alex!
Comment #36
Wim Leers#34: Indeed, that's what I'd been thinking too :)
Thanks!
Comment #37
yoroy CreditAttribution: yoroy commentedNever trust me to know the right component for stuff like this :)
Comment #38
BerdirOpened #1974474: Make sure within field_attach_*() that we are working with a BC entity
Comment #39.0
(not verified) CreditAttribution: commentedadded related issues section