Problem/Motivation
static is evil :)
That pattern causes the EntityTranslationHandlerFactory instance to persist between test methods of a test.
See https://www.drupal.org/node/2674592#comment-10892412, I had test fails that I didn't have locally, turns out the difference was that I had a very old entity_translation version locally that didn't have that static cache yet.
Which resulted that the code ended up using handlers from a previous run (as the entities had the same ID's), and then the language returned by entity_language() doesn't return what you'd expect.
Proposed resolution
Use drupal_static(). Yes, it's weird, but that's the only option.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | entity-translation-factory-static-2675230-2.patch | 1.01 KB | berdir |
Comments
Comment #2
berdirComment #3
douggreen commentedThis problem also causes a memory leak, because entity translation holds onto a copy of the entity after resetCache() and drupal_static_reset().
Comment #4
stefanos.petrakisSo, after this patch is applied, one could call
drupal_static_reset('EntityTranslationHandlerFactory')to make sure no out-dated or irrelevant object is kept in memory, as in the case of running aut. tests.I am considering making this part of the class's interface as in: