split from #1778122-57: Enable modules to inject attributes into field formatters, so that RDF attributes get output, where yched wrote in #57 and #59:

The last thing that bugs me is that all those $item->html_data_attributes properties stay in the $entity for the rest of the request, and can get stale if field values are changed, or if the same entity is displayed again in a different view mode later in the request.
Can't easily check right now, but I'm not sure there's a place / hook where those could be cleaned up / removed once formatters have done their job.
We should at least make sure that rdf_entity_prepare_view() resets html_data_attributes to at least an empty value on all fields in the entity ?

[...] we try to avoid entities to have a "state" - so that you don't hit weird edge cases (for example when writing tests).

However, *if* formatters are the only things that are ever going to use this html_data_attributes property, then it's not really a problem in practice. As you point, rdf_entity_prepare_view() will always re-compute html_data_attributes before formatters run, so it's not a big deal if field values changed meanwhile.
I'd still find it cleaner if we had a way to remove html_data_attributes after the rendering has happened, so that we don't clutter the entity with possibly stale values, but that's not a blocker.

Comments

scor’s picture

Issue tags: +RDF

tagging

joelpittet’s picture

Issue summary: View changes
Status: Active » Closed (cannot reproduce)

html_data_attributes doesn't exist in D8 anymore.

Triaging theme system.