Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update afterSave to ensure created entires have all translated fields…
… present Without all fields being present, find() will be unable to find the translated records. Fixes #3009
- Loading branch information
1c0b6c0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
With that Translate in my model:
With 2 (or more) languages (EN, FR, etc...), when I add a record in my back-office, I have 2 SQL inserts (field "title" for EN, field "title" for FR, etc...).
Nothing wrong here.
But after that, I have also one SQL update for the field "titleTranslation" for my default language, which content is empty.
So I lose the "title" field for my website default language.
To sum up: for 2 locales, I have 2 records in my I18n table: one with the classic name, and one with the Translate field. So i loose the record of my default language.
This problem is linked to that commit.
1c0b6c0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't make sense, the patch only fires when $created is set ... so it shouldn't do anything on updates ?
1c0b6c0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you do it on updates? That could potentially cause a partial save to erase all previous translations that defined other fields. Changing this code to apply on updates would make partial updates impossible.
1c0b6c0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a dork, I misread your comment @darxmac, sorry about that. But yes this code only applies to creates.
1c0b6c0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your attention and responsiveness.
Yes, my problem only happen when I add a record.
In my case, it adds an i18n record for "EN" and "FR" for the field "title", and then it adds an empty value for "titleTranslation".
Here is a dump of $tempData after your code:
Here is a dump of SQL queries executed around that piece of code:
I'm looking on my side if it's a generic problem or my fault/misunderstand.
Perhaps a conflict with the default locale...
I look further and try to find a solution if needed.
Thanks again for your help and work.
1c0b6c0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ grobux This was fixed after 2.2.1 and will be in 2.2.2. You can either upgrade to the current master branch for your app, or wait for 2.2.2 to be released, it shouldn't be too long now.