Problem/Motivation
CEB::getTranslation keeps a translation cache under $this->translation for each initialized translation, however when we call getTranslation on the default translation the default translation is not put into the translation cache which leads to initializing an additional entity object translation when retrieving the default translation from a non-default translation.
Proposed resolution
When retrieving a translation put the current translation into the translation cache as well.
Remaining tasks
Reivew & Commit.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#22 | interdiff_19-22.txt | 2.71 KB | leolandotan |
#22 | initializes-object-2839089-22.patch | 2.97 KB | leolandotan |
#19 | initializes-object-2839089-19.patch | 3.11 KB | anmolgoyal74 |
#13 | initializes-object-2839089-13.patch | 2.96 KB | arunkumark |
#10 | 2839089-10.patch | 2.96 KB | hchonov |
Comments
Comment #2
hchonovThe only possible test I can think of would be:
Does such a test make sense?
Comment #3
hchonovComment #6
hchonovComment #8
hchonovComment #9
tstoecklerLooked at this. I think in general, this makes a lot of sense, as it's a harmless optimization.
I found the following code, though, a couple lines further up in
ContentEntityBase::getTranslation()
:So I think we should consolidate. It seems as though there is no reason not to always cache
$this
in$this->translations
, so maybe we can replace the above + the hunk in the patch simply with:Thoughts?
Comment #10
hchonov@tstoeckler, yes that makes sense :). Thank you for the suggestion.
Comment #12
arunkumarkComment #13
arunkumarkHi All,
I have re-rolled the patch for Drupal 8.5.x version.
Comment #15
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs, Google Summer of Code for DrupalFit commentedHi All,
Here is the re-rolled patch for Drupal 8.6.x version.
Comment #16
tstoecklerWrong indentation here.
Minor, but this does not need to be broken into two lines.
Comment #17
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs, Google Summer of Code for DrupalFit commentedHi All,
Here is the updated re-rolled patch for Drupal 8.6.x version.
Comment #19
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs, Google Summer of Code commentedComment #20
tstoecklerThe patch does not fix #16 and instead introduces some whitespace problems.
Comment #21
leolandotan CreditAttribution: leolandotan as a volunteer and at Promet Source commentedI'll work on this.
Comment #22
leolandotan CreditAttribution: leolandotan as a volunteer and at Promet Source commentedAs per the comment from #16, I have applied the fix on coding standards and some additional ones as well.
Hope everything is in order.
Comment #23
tstoecklerPerfect, thank you!
Comment #24
alexpottThis is a task. The current behaviour is not a bug it is just not the most efficient and whilst I don't doubt there is a performance increase I'd be surprised if it is enough to make this a bug.
Comment #25
alexpottAdding @tstoeckler to commit credit for reviews.
Comment #26
alexpottCommitted cebca29 and pushed to 8.6.x. Thanks!