This is strange combination between drupal core and domain module.
The default language of the default domain gets changed when viewing other domain that has different default language set and when the javascript needs to be rebuild for that language.
The problem was tracked to function _locale_rebuild_js() in includes/locale.inc that when rebuilding the javascript for the language makes this :
$default_langcode = language_default('language');
if ($default_langcode == $language->language) {
$default = db_query("SELECT * FROM {languages} WHERE language = :language", array(':language' => $default_langcode))->fetchObject();
variable_set('language_default', $default);
}
So lets say we have the default domain with default language english. Then the other domain B has default language as danish. When you open domain B and the javascript needs to be rebuild you end up with default language for the domain to be danish and the current language to be danish and therefore the variable value is set to danish and that is wrong. After that if you open the default domain the default language will be danish even if you go to the standard language selection page it will be danish as well as this is the variable value if you check in the table. As there is no other configuration for the default domain all the values are taken from the variables table.
I am not sure that in the default_language situation the variable should be edited. Maybe only global $language should be changed but I am not that deep in the multilanguage options. As far i have added new language variable and used hook_domain_bootstrap_full in my custom module to change the default language and by this ignore the standard drupal settings form but i am not quite sure this is the right way.
Will do more tests and see how this handles.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 1271810-domain-conf-langauge-reset-7x2.patch | 3.07 KB | agentrickard |
| #14 | 1271810-domain-conf-langauge-reset.patch | 3.06 KB | agentrickard |
| #6 | da-01.png | 198.82 KB | globexplorer |
| #6 | da-02.png | 150.13 KB | globexplorer |
| #6 | da-3.png | 198.57 KB | globexplorer |
Comments
Comment #1
vflirt commentedComment #2
agentrickardProbably needs to be handled by Domain Locale. Is this only when using JS aggregation?
Comment #3
agentrickardComment #4
globexplorer commentedExactly the same problem. A complete bug report will follow by tomorrow.
Comment #5
agentrickardNot critical. Only affects a minority of users.
Comment #6
globexplorer commentedDomain Access Version 7.x-2.13
Drupal Version 7.7
i18n installed 7.x-1.0
For the domain access configuration, please refer to the attached screenshots!
As you can see, there are different default languages for some sites.
When somebody views the content on a domain with it's own default language,
and a javascript file has to be updated - Drupal does this when there are new strings that have never been fired - then the default language of the Default (Master) Domain get's changed to the default language of the Domain the JavaScript has been updated.
This goes exactly vflirt has described it!
I marked It as critical, because a JavaScript Workflow manipulates the settings of domain access and language settings -> default language.
I thank you for domain access. It's a cool module. Thank you
Comment #7
agentrickardWhat does a JavaScript Workflow refer to? Is that a module?
Comment #8
globexplorer commentedThe problematic workflow is this: everytime when Drupal loads a JS file, it looks for Drupal.t()
If this is successful, Drupal checks the default language by a SQL query and performes then an update inside the database - which overrides the default language of the main domain (e.g. "de") with the domain default language (e.g. "hu") of a current page. This leads to a new sitewide default language ("hu"), which is, of course, not intended. That said, domain access, especially domain locale, has to take care of the process of this Drupal core behaviour to avoid this side effect.
Comment #9
agentrickardAh. So is this really a Domain Access bug, or a core problem that someone has to work around?
Ideas for how to solve?
Comment #10
globexplorer commentedFvlirt says It could be done in implementing hook_domain_bootstrap_full, during hook_enabled. I will try this one. But I think It is a strange behaviour anyway. JavaScript update and boooom. Default language gone. Content disappears. Maybe there is a way to take care of that drupal workflow in overruling the core functions.
But why Fvlirt thinks "hook_domain_bootstrap_full" does a different thing to domain locale?
Thank you anyway for the interaction.
Comment #11
globexplorer commentedI will try one thing by tomorrow. I will provocate this bug again in adding some new translations. Then I will visit a sub domain where the new translation will set the javascript on fire. Then I will look at the language table to see what has changed.
By tomorrow we've got a solution, I hope.
Comment #12
vflirt commentedHi,
what i did is kinda of a workaround in my module :
also in hook_domainform in my module I add setting for the language so each domain can set its default language in the edit form.
As for now this is working but as i said in the start not sure if that is ok.
Comment #13
agentrickardI don't really understand how that code can fix the problem described. It looks very much like the code in
domain_conf_domain_bootstrap_full().Have you tried patching that function?
And why are you being forced to set another variable? Is 'language_default' the issue here?
Comment #14
agentrickardI am finding this bug very hard to reproduce reliably -- though I have seen it.
The attached patch approach should resolve this issue. It works by watching the functions that call the JS rebuild and then firing a shutdown function to ensure that the primary variable is not altered.
However, I think this might fail in a case where the default language variable has not been expressly saved to the database during configuration.
Needs testing, obviously, by those affected by the behavior.
This patch is against 7.x.3-dev, but should apply to 7.x.2.
Comment #15
agentrickardIt does not. Here's a patch against 7.x.2.
Comment #16
globexplorer commentedYou are quicker than me agentrickard! I did your patch, and at the moment It seems that it's working. I will keep my eye on this issue. Thank you!
Comment #17
agentrickardI'd like to roll this into a 7.x.3.1 and a 7.x.2.16 release. Can any else confirm that, at the least, it doesn't make things worse?
Comment #18
agentrickardCommitting and rolling a new release for testing.
Comment #19
globexplorer commentedOh no. It's here again. I patched, but here the error log.
But maybe it's not the whole patch. Look at the code snippet from your patch. It sould be $default_language == domain_conf_default_language
Am I right, that you overwrite the default language with the default language saved in the domain_conf table? The problem is both get's changed:
1. admin/config/regional/language
2. admin/structure/domain/batch/language_default
Comment #20
agentrickardThe function
domain_conf_default_language()is merely a static variable holder, not a lookup to domain_conf. The entire point to the patch was to bypass Domain Conf -- which is not the problem here, the problem is that core resets default language. The = is appropriate, because it the function returns FALSE if nothing is set. Here's the flow:Now, if language_default is not set when this process starts, then I think the error would still occur, because we don't have any data to update (see comment 14 above).
To test, be sure to save the default language form before rebuilding JS (use admin/config/regional/language). It is possible that we aren't properly handling (admin/structure/domain/batch/language_default) as well.
All that said, I haven't been able to reproduce this error consistently.
Comment #21
globexplorer commentedOk. I think, well done agentrickard. At the moment everythings fine.
Chicago, Chicago, Chicago that's my home town.
Comment #22
agentrickardSo is the problem that the default variable wasn't set? If so, we should open another issue to try to work around that (if possible).
Comment #23
globexplorer commentedOh god, the problem is still alive. The patch does not solve the problem! The default language get's changed again O:(
Comment #24
agentrickardPlease refrain from histrionics in the issue queue.
Let's open a new issue and see if we can trace the new problem. You need to report:
Comment #25
globexplorer commentedYes sorry! You are right, but shortly I was in a real trouble, because I'm now on air - live.
# Language settings:
Primary Domain -> DE
Hungary Domain TLD -> HU
Slovakia Domain TLD -> SK
etc.
After I patched the development site, the default language never get's changed again. But then I transfered the dev site, what means I changed my domain names. But of course I did not touch anything else.
Then the first user connected to a sub site eg Hungary. He jumped to a site where a javascript file has included some Drupal.t() strings. Wooom. The default language of the Primary domain, switched to the domain default language of the hungarian site. From DE to HU. Of course the Primary domain doesn't have any content in HU. Therefore the menu's disappeared.
You can see here the Recent log messages. Every time a new user was connected 18:51, 17:56, etc. WOOM.
locale 20.12.2011 - 18:51 Updated JavaScript translation file for the language... Anonymous (not verified)
locale 20.12.2011 - 17:56 Updated JavaScript translation file for the language... Anonymous (not verified)
locale 20.12.2011 - 17:56 Updated JavaScript translation file for the language... Anonymous (not verified)
locale 20.12.2011 - 17:56 Updated JavaScript translation file for the language... Anonymous (not verified)
locale 20.12.2011 - 17:49 Updated JavaScript translation file for the language... Anonymous (not verified)
locale 20.12.2011 - 17:49 Updated JavaScript translation file for the language... Anonymous (not verified)
locale 20.12.2011 - 17:33 Updated JavaScript translation file for the language... Anonymous (not verified)
locale 20.12.2011 - 16:54 Updated JavaScript translation file for the language... admin
Then I did the following. I accessed every page of a domain with a loaded JQUERY file and Drupal.t() functions to get the rebuild_js process to work. After I was sure, that I accessed every page, I changed the default language of the primary domain back to DE. Since then I've never seen this issue again.
Comment #26
agentrickardWhat part of "Let's open a new issue" was not clear?