Closed Plaristote closed 8 years ago
How are both requests handled by the same thread??!
The thread doesn't die at the end of the request, it just goes to sleep. When you set Globalize (in versions 2.1.x, you use Thread.current[:globalize_locale]
) the value of Globalize will be the same for the next requests, as long as they're done in the same thread (so if your server uses only one thread, you can be sure that the behavior I described in my original post will happen).
Unless of course the value is cleared at the end of the request, but I don't see that being done anywhere.
@Plaristote Globalize moved to RequestStore
recently. Can you try Refinery
master with Globalize
master branch?
That sounds like it would solve the problem. I'll try the upgrade and come back to you.
@Plaristote Could i close this issue ?
Sure.
Greetings.
I've noticed that when people use the site simultaneously with an administrator working on the back-end, the administrator's locale become inconsistent. It's not a severe issue. But it's something that our client finds annoying.
Here's the process (considering the default locale is English):
This only happens if the two user's request were handled in the same thread... but our own application runs on only one thread, so this is the behavior we get 100% of the time.
We've read the code of refinerycms-i18n, and it all makes perfect sense. This is the behavior written in the code, no doubt about that: what we're wondering is whether the application was designed that way, or if it's an unintentional mistake ?
It sounds like a mistake to me, because at the end of a request, the application is left on a different state than it was at the beginning of the request. And I'm pretty sure that's generally considered a bad practice. Any thoughts on that ?
Source: https://github.com/refinery/refinerycms-i18n/blob/master/lib/refinery/i18n/engine.rb from line 19 to 69.