When merging two Translations objects using the mergeWith method, the source catalog is modified in some situations. This is unexpected and undesired behaviour in my opinion.
The Translation object from the source catalog is added to the target catalog and is now referenced in the target catalog. But modifications of the target catalog will now also modify the source catalog.
This is undesired for example in situations where a source catalog is generated by an extractor and is used to be merged with several other catalogs (in my case: target catalogs for different languages).
The solution is quite simple. Instead of referencing the source translation, create a clone:
When merging two
Translations
objects using themergeWith
method, the source catalog is modified in some situations. This is unexpected and undesired behaviour in my opinion.The problem is in line 164 of Merge.php:
The
Translation
object from the source catalog is added to the target catalog and is now referenced in the target catalog. But modifications of the target catalog will now also modify the source catalog.This is undesired for example in situations where a source catalog is generated by an extractor and is used to be merged with several other catalogs (in my case: target catalogs for different languages).
The solution is quite simple. Instead of referencing the source translation, create a clone: