issue after updating from Version: 7.x-1.0-alpha7 to Version: 7.x-1.0-alpha9:
title_field_text_sync_set function is called and legacy field replaces translated field.
title translation is lost.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jas1988 created an issue. See original summary.

bendev’s picture

same issue after updating from Version: 7.x-1.0-alpha7 to Version: 7.x-1.0-alpha9

title_field_text_sync_set function is called and legacy field replaces translated field.
title translation is lost

tobiberlin’s picture

FileSize
1.55 KB

Found the same issue here. I am calling node_save() for a node which has title field enabled and has translated titles for English (original language) and French (translation of the node). I do not really get why this function title_field_text_sync_set overrides the French title translation to the original English title on a node_save() call in one place of my script although it was called before without this effect (I need this second call to node_save() due to several reasons).

I rolled back to alpha7 version of this module but here the effect was the other way around: I changed the French title and on the node_save() the English title changed to the French version.

Please note that I can update the node and it's translated titles from the node form without problems like this. The problem apprears in my case on a place in my script where do a node_load(), change some properties of the node object and save it with node_save()

For me it is not quite clear what the intention of title_entity_presave is from where title_entity_sync is called which calls title_field_text_sync_set itself - which seems to cause this issue. This hook is called every time an entity gets saved. Is it really necessarry to do this sync everytime an entity gets saved?

In my case I found a fast solution: simply avoid all this sync if not needed. See my patch - it is just a quick and dirty solution as I need to fix this know but without understanding the intention of title_entity_presave I cannot do better. To use this / to avoid the sync of the title module add $node->avoid_title_entity_presave = TRUE; and then do node_save($node) - adding this property to the $node object will avoid that title_entity_presave() will do it's syncing.

tobiberlin’s picture

FileSize
597 bytes

Sorry. my first patch included code which is not part of title module. And it was created with PHP Storm which makes it useless for others. Here is a new patch

tobiberlin’s picture

tobiberlin’s picture

FileSize
596 bytes

I am very very sorry... I am a little bit in a hurry... the patch 2844496_fast_solution_2.patch had an error - the sync logic was avoided when the property $node->avoid_title_entity_presave was NOT set - my idea was instead to run the sync logic by default and to avoid it when this property is set.

tobiberlin’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: 2844496_fast_solution_3.patch, failed testing. View results

joseph.olstad’s picture

Status: Needs work » Needs review

head tests are fixed
#2813673: Tests broken since new permission in drupal core
re-queuing tests here.

Status: Needs review » Needs work

The last submitted patch, 6: 2844496_fast_solution_3.patch, failed testing. View results

joseph.olstad’s picture

Status: Needs work » Needs review
FileSize
468 bytes
joseph.olstad’s picture

I haven't reviewed this issue, just simply rerollled

semiaddict’s picture

Patch title_1991988-10.patch from https://www.drupal.org/project/title/issues/1991988#comment-7752973 worked great for me in both 7.x-1.0-alpha8 and 7.x-1.0-alpha9

joseph.olstad’s picture

hi semiaddict, I re-uploaded the patch 10 you speak of to re-trigger the tests.

Ron Collins’s picture

The patch mentioned by @semiaddict doesn't appear to be the same as the one @joeseph.olstad mentioned in #11. I used the one mention by @semiaddict and that seems to have resolved the issue for me.

jas1988’s picture

This one seems no effect : https://www.drupal.org/files/issues/title-avoid_presave_fast_solution-28...

But by using this one https://www.drupal.org/files/title_1991988-10.patch issue got resolved for me as well but as this patch fails testing, details in this thread https://www.drupal.org/project/title/issues/1991988#comment-7752973

can we use this one for now to solve purpose ?

sano’s picture

Status: Needs review » Needs work

the patch #11 does not apply to neither 7.x-1.0-alpha9 nor the 7.x-1.0-alpha9+33-dev version of the module.

quotesBro’s picture

Title: With new security update Version: 7.x-1.0-alpha9 the problem of title overriding is there » Translated field value is overwritten with legacy field value
Issue summary: View changes
Status: Needs work » Active
Related issues: +#1269076: Translated title_field replaces node->title with translated value

I'm hiding #11 patch because it is not a solution