Per #2267251-10: Do not rely on "content language" in hook_entity_presave(), the Title module patch in that issue requires that code doing a programmatic entity save and changing the entity title needs to call the Entity Translation handler's setFormLanguage() method before saving.
Since Drafty does a programmatic entity save, it definitely needs to call this method. (In theory it could check if the save is changing the title, and only call the method if it is, but it seems cleaner and less prone to future bugs to just set it always.)
We are running that Title module patch on a site and have seen major bugs as a result (if you edit and save an entity translation twice in a CPS changeset, then after the second save, the translated title gets saved to the English version of the entity, on the live site!). This patch fixes the problem.
This issue is related to #2395793: Remove title module special-casing but not the same thing since it's not clear the old code can be removed yet, even once the above-referenced Title module patch is committed.
Comment | File | Size | Author |
---|---|---|---|
#13 | title-module-fix-2487013-13.patch | 1.68 KB | richardcanoe |
#5 | 2487013.patch | 1.68 KB | Pol |
#1 | drafty-title-fix-2487013-1.patch | 1.49 KB | David_Rothstein |
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein at Tag1 Consulting commentedHere is the patch.
Comment #2
catchIf #2395793: Remove title module special-casing passes tests with #2267251: Do not rely on "content language" in hook_entity_presave() applied to entity_translation, but we still need to patch for this case, that suggests a hole in the test coverage.
Comment #3
DamienMcKennaComment #4
PolHello,
The Title module will get rid of
title_active_language()
function used in Drafty and replace that using the Entity Translation Handlers properly. (See #2882888: Use new Entity Translation API).I see that the return value of that function is not even used in Drafty.
Should we get rid of the line calling the function ? Or something else ?
Comment #5
PolHere's an updated patch, working with Title + patch from #2267251: Do not rely on "content language" in hook_entity_presave().
Comment #7
joseph.olstad2 out of the 3 fails on the above patch are related to this issue:
#2911357: Fix tests; update for latest to Entity Translation changes
Comment #8
DamienMcKennaThanks for working on this, @joseph.olstad.
Comment #9
joseph.olstadComment #11
DamienMcKennaSo the tests won't work because #2267251 hasn't been committed. *sigh*
Comment #12
DamienMcKennaAlso, progress on the title module is blocked by #2813673: Tests broken since new permission in drupal core.
Comment #13
richardcanoe CreditAttribution: richardcanoe commentedPatch re-rolled