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

Optimize ContentEntityBase::getTranslatedField and do not store field values under the default and the asked langcode under $values

$
0
0

Problem/Motivation

I've noticed that ContentEntityBase::getTranslatedField is called recursively for non translatable fields and also in __sleep the field values of non translatable fields will be stored twice and the function getValue will be called for all the translations for which a field has been initialized. Also if you iterate over $values you will get unneeded iterations over the same values. In the case where the an referenced entity of a non translatable field will be returned by FieldItemList::getValue this would cause $values to contain the referenced entity not only once but one time for the default langcode and additionally so many times as the number of entity translations, which in case of serializing the parent would cause a bigger serialized object.

Proposed resolution

Remove the recursive call of ContentEntityBase::getTranslatedField and store directly non translatable fields only under the default langcode by keeping track which field are translatable and which not.

Remaining tasks

Review.

User interface changes

API changes

Data model changes


Viewing all articles
Browse latest Browse all 299069

Latest Images

Trending Articles



Latest Images

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