Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|
Comments
Comment #2
bendev CreditAttribution: bendev at WebstanZ commentedsame 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
Comment #3
tobiberlinFound 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 wheretitle_entity_sync
is called which callstitle_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 donode_save($node)
- adding this property to the $node object will avoid that title_entity_presave() will do it's syncing.Comment #4
tobiberlinSorry. 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
Comment #5
tobiberlinComment #6
tobiberlinI 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.Comment #7
tobiberlinComment #9
joseph.olstadhead tests are fixed
#2813673: Tests broken since new permission in drupal core
re-queuing tests here.
Comment #11
joseph.olstadComment #12
joseph.olstadI haven't reviewed this issue, just simply rerollled
Comment #13
semiaddict CreditAttribution: semiaddict as a volunteer commentedPatch 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
Comment #14
joseph.olstadhi semiaddict, I re-uploaded the patch 10 you speak of to re-trigger the tests.
Comment #15
Ron Collins CreditAttribution: Ron Collins commentedThe 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.
Comment #16
jas1988 CreditAttribution: jas1988 as a volunteer commentedThis 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 ?
Comment #17
sano CreditAttribution: sano commentedthe 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.
Comment #18
quotesBro CreditAttribution: quotesBro commentedI'm hiding #11 patch because it is not a solution