Closed (fixed)
Project:
JSON:API
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Sep 2017 at 13:36 UTC
Updated:
15 Oct 2017 at 21:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
e0ipsoYou can see an example of a computed field working in the jsonapi module itself. It's the URL download field for file entities.
Maybe that'll help find the disconnect.
Comment #3
nuezThank you for the tip:
The
FileDownloadUrlclass actually works, although not entirely: because of the 'vfs' scheme, thefield_create_url()returns FALSE, and the computed URL stays empty in the test.In the patch I've added the test for the computed field, and changed the
FileDownloadUrlclass so it returns the $uri when the scheme is 'vfs'. I guess this should actually be fixed in the field_create_url() method in core, but that might not be a viable road.The reason why the
ComputedTestFieldItemListfails is because theisEmpty()returns TRUE and the computation never happens.Conclusion: documentation should be improved about how to create computed fields. Basically the
isEmpty()method should always return FALSE when computed to force the computation to be executed.I've added the related issue.
Comment #4
nuezComment #5
e0ipsoI made some adjustments on commit. See the actual commit for more details.