Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293129

Avoid having empty field items by default

$
0
0

At #1777956-35: Provide a way to define default values for entity fields raised that having empty field items in $field objects is weird - as others. We've an empty field item object by default such that this gets cloned during prototyping the field object, thus speeds up getting further field objects.

"Sometimes there is an empty FieldItem, sometimes there isn't" sounds wrong ?

I think both cases are semantically equivalent as in both cases the overall field would be empty and storage would remain the same. So whether there is an empty field item or not is not something that matters to the persistent state of the entity, however yes - the different run-time state matters in some scenarios like should an empty item be rendered or presented in a form.

Right now, I fear we need to have that items due to the performance improvements it brings us. But let's research ways to remove that empty item when it's not needed here.

Thinking about it having getPropertyInstance() call setValue(NULL) for a NULL $value also should be good enough and still use the prototyped/cloned field item when a value is given to getPropertyInstance() - but not later on. Performance wise changes later on are not interesting, so that should not be a performance regression (to be verified).


Viewing all articles
Browse latest Browse all 293129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>