New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong locale field value on DataObject #190
Comments
Code sample please
|
I think I have something like this too. My case involves also the SilverStripe Blog module. The Blog module also uses silverstripe/lumberjack module to better manage the site tree of blog articles in the CMS. This module comes by default with the blog module, so it's not something I have included myself. Thus, I don't know if the Lumberjack module relates to this bug at all, but I just mentioned it just in case, because I don't know it very well. So, what's the problem in practise? I have a site with two languages, English and Finnish, and English is the default language. I have one Blog page that is translated to both English and Finnish - that works well. While having English selected as the content language (in the dropdown field left above the site tree in the editor), if I create a new BlogPost under the Blog page, saving and publishing it goes well. But, if I want to write a blog article in Finnish, I switch the language from the dropdown field to Finnish and then create a new BlogPost page under the Blog page. I write the article and publish it. It saves the article with a wrong locale field value, 'en_US' instead of 'fi_FI'. I checked that directly from the database. More strange, my new Finnish blog article won't appear in the CMS at all - no matter what language I select. It just doesn't show up in the gridfield that lists the blog articles. However, it does appear in the public site - but of course under the English side of it. Too bad for people who can't speak Finnish! :D I have SilverStripe 3.1.12. Blog and Translatable are the newest versions - I have ran composer update today and don't have any version limits in composer.json for those two modules. Do you need any code samples? I think I don't have made any custom code relating to Translatable or Blog. Edit: I just updated to SilverStripe 3.1.16. Nothing changed. I also tried to update to 3.2.1, but due to some dependencies, Composer doesn't let me update to newer than 3.1, so I can't test the newest version of SilverStripe. But perhaps that isn't needed. We'll see :). |
Here is a temporary fix in a form of an extension, so no need to hack any existing files: mysite/code/BlogPostLanguageFix.php:
Add to mysite/_config/config.yml:
Please note that this does not solve the original bug, but rather fixes the symptom in a quick and dirty way. I have done very little testing after creating this extension. I created new BlogPosts in Finnish and in English and checked in the database that the locales are now saved correctly. I found no errors. If you use this fix, can you please report back here if it worked for you, and also of course if it didn't? Tell me also what locales you are using. Thank you! :) |
Ran into the same problem, looks to be a little more extensive. Happens whenever I try to add a new page (e.g. with the "New page" button above the site tree). Looks like the issue is Translatable sets the default for Locale to the default locale (likely english). The onBeforeWrite only sets the Locale to the current locale if Locale isn't already set (which it was by the default value). |
Sounds reasonable. @silverstripe-issues , is this information enough for inspecting the issue? If still needed, I think I can write some example code showing the bug. |
I'm not sure who @silverstripe-issues is (@chillu?), @Taitava and you supply some code just for clarity's sake? thanks |
Yes, just for clarity if needed :). |
Unfortunately, Silverstripe CMS 3 has entered limited support in June 2018. This means we'll only be fixing critical bugs and security issues for Silverstripe CMS 3 going forward. You can read the Silverstripe CMS Roadmap for more information on our support commitments. |
I've got a custom SiteConfig extension. The hidden field 'Locale' ist always the default locale, not the current locale.
Why isn't the value updated to the current locale? Can't save new items to other locales.
The text was updated successfully, but these errors were encountered: