Problem/Motivation
When using URL based language detection using domain, the default path can not be empty. The help text on the settings page states that, the domain field can be
Proposed resolution
Remove the line from the settings screen as suggested by gabor-hojtsy in #5
Remaining tasks
create patch to remove / alter the line, saying "Leave blank for the default language.", noting that the domain for the default language can not be empty. This is done.
change the form validation, so that a domain can not be empty for any language. This is done.
Need manual tests and screen shots.This is done.
User interface changes
before:
after:
Original report by @greg-sims
I created a new website based on 8.0.0-alpha15. The site was loaded in English and I added Spanish. "Detection and selection" uses URL configured for "Domain" as follows:
- English: Blank per the instructions on the configuration page for the default site. "Leave blank for the default language."
- Spanish: es.raystedman.info
I then enabled the "Language switcher" block on the "First sidebar".
I created content in English and translated it to Spanish. When the English version is displayed and Spanish is clicked in the Language switcher block, everything works as expected -- the Spanish version of the content is displayed with URL: http://es.raystedman.info/devocionales-diarios/efesios/a-la-vista
Here is the issue. When the Spanish version of the content is displayed and English is clicked in the Language switcher block, the URL created is not correct. The URL displayed is: http://es.raystedman.info/daily-devotions/ephesians/on-display. Everything is correct with this URL except for the sub-domain. The sub-domain should be that of the default language which is English -- not es for Spanish.
The big question is what is sub-domain of the default English language? Please recall it is configured as blank per the directions in the "detection and selection" configuration page as mentioned above. When English is changed to "www.raystedman.info" everything works as expected. The solution to this problem could be as easy updating the configuration page documentation.
Comments
Comment #1
Gábor HojtsyI am not sure where the domain is taken when on a translated domain. I mean how would Drupal tell which domain to use? Whether it is en.x.y.z or just x.y.z? Just specify the value for default language and let's see if that works. If so, we should fix the docs.
Comment #2
Gábor HojtsyComment #3
Greg Sims CreditAttribution: Greg Sims commentedPlease see the attached screenshot of the "Configure URL language negotiation" page that might need to be changed.
Comment #4
Greg Sims CreditAttribution: Greg Sims commentedComment #5
Gábor HojtsyRight I believe the docs are not correct. Drupal has no way to tell the default domain unless provided. Can you help with a patch? Should just remove that sentence AFAIS.
Comment #6
Gábor HojtsyComment #7
pefferen CreditAttribution: pefferen commentedComment #8
pefferen CreditAttribution: pefferen commentedComment #9
pefferen CreditAttribution: pefferen commentedWe changed the form alter, to check for a domain for each language. In addition the description on the form is altered and the error message, on the form validate is altered aswell. see the attached patch.
Comment #10
pefferen CreditAttribution: pefferen commentedComment #11
pefferen CreditAttribution: pefferen commentedComment #13
alimac CreditAttribution: alimac commentedI'm looking at why this patch failed testing.
Comment #14
YesCT CreditAttribution: YesCT commented@alimac said is going to try and run the tests locally to get some more info.
-
1.
this comment needs to change also.
2.
there are no changes to tests. Maybe we did not have test about this? Or maybe we did and now they are failing cause we did not update them...
Maybe those tests were not setting the default domain. and so now there is an exception thrown during the tests.
3.
It might be interesting to do a git blame on those lines which say it may be blank to try and find out why we thought it would be a good idea to allow no value.
Comment #15
alimac CreditAttribution: alimac commentedI ran tests locally and a lot more of them failed. Running tests again to see if the results will be consistent.
Comment #17
alimac CreditAttribution: alimac commentedThis patch will most likely fail, but it should fail a smaller number of tests than the previous patch.
We should add a test for when the exception is thrown (that is, when the domain for default language is not specified). Also, noticed some typos in the doc blocks.
Comment #19
alimac CreditAttribution: alimac commentedTest failed earlier because we supplied an explicit default hostname (en.example.com). Instead, since we don't know the hostname, let's try using gethostname() to determine the current hostname.
Comment #21
alimac CreditAttribution: alimac commented"Use with caution.." is repeated twice.
Previously, "Leave blank" used active voice, so we should also use active voice: https://www.drupal.org/style-guide/content#voice
Maybe: Don't leave the domain blank.
Comment #22
alimac CreditAttribution: alimac commentedThis patch has the fix for the remaining test (LanguageUrlRewritingTest) and also updated text of the description.
Still need to see about writing a test for leaving the domain field blank.
Comment #23
alimac CreditAttribution: alimac commentedHere's a test to make sure that if you leaven the domain field blank, it will throw an error.
Comment #24
alimac CreditAttribution: alimac commentedFixed a whitespace issue and added an assertion for the test in which configuration is saved successfully.
Adding a test-only patch that should fail.
Comment #26
alimac CreditAttribution: alimac commentedGood. The patch passed and the test-only patch failed with the expected message.
Comment #27
realityloopComment #28
xadag CreditAttribution: xadag commentedI'm working on this issue
Comment #29
Sutharsan CreditAttribution: Sutharsan commented@xadag Please assign the issue to yourself while working on an issue. It will prevent others to start woking on the issue.
Comment #30
alimac CreditAttribution: alimac commented@Sutharsan new contributors often work together on issues, so we don't assign issues. Instead we post comments to communicate what we are going to do ("I am going to manually test this patch at the DrupalCon Amsterdam mentored sprint" for example.)
Comment #31
Sutharsan CreditAttribution: Sutharsan commentedOk, thanks.
Comment #32
xadag CreditAttribution: xadag commentedComment #33
xadag CreditAttribution: xadag commentedComment #34
pp CreditAttribution: pp commentedComment #35
xadag CreditAttribution: xadag commentedHello,
I've reviewed the latest two patches (full one and only testing one).
Everything is fine for me, process and code, when now i'm viewing a translated node in english and switched to spanish with the language selector, i've the correct version and domain displayed.
When i'm trying to submit the configuration of detection domain with blank domain for default language, i've got an error so everything it's fine.
Comment #36
pp CreditAttribution: pp commentedI tried the patch.
Switch on the language module.
Add a Hungarian language
Go to Configure URL language negotiation page.
Change "Part of the URL that determines language" to "Domain"
Save empty fields.
Without patch, I can save emty English domain. With patch I got a following error:
No, I will check the code, and if I do not find any issue, I put it to rtbc
Comment #37
pp CreditAttribution: pp commentedThe line:
'domain[en]' => gethostname(),
missing in test only patch.
I reroll that patch and waiting for testbot.
Anything else looking good for me.
If it will be FAILED, I put it to RTBC
Comment #38
pp CreditAttribution: pp commentedoooh... I must to goo. Anybody else must put it to RTBC, sorry
Comment #39
alimac CreditAttribution: alimac commented@pp
The test-only patch is supposed to only add the assertion, and not the
'domain[en]' => gethostname()
part, because it's testing what happens when the domain for the default language (in this case 'en') is left blank.Comment #40
marcus7777 CreditAttribution: marcus7777 commentedWe wanted to see to see what changed from the test only patch in the #24 to the the test only patch in #37.
I made the interdiff by applying the patch no #24 the 8.0.x on branch 24 then switching back to 8.0.x and applying patch no #37 and running a diff between the two branches.
Comment #41
Gábor HojtsyNo the test only patch needs to be equal to the test changes of the complete fix. Otherwise how do you know that it properly fails? The test looks good, it has coverage for both empty and filled in domains, it should properly fail without the fix. It *should not* be a different test.
Already done in #37 so no need to set to needs work.
Comment #42
rudivanes CreditAttribution: rudivanes commentedSo I used the test module to run the 2 tests changed by this patch and also did a manual test. And the output by the test module was ok for the empty domain issue.
However another testline returned a failure. I guess it can be caused by my local environment not allowing it.example.com. I don't know if this is relevant.
If not. I think it is RTBC.
P.S. I've added a screenshot of the test moduel output.
Comment #43
Sutharsan CreditAttribution: Sutharsan commentedPlease update the tags and the issue summary, specifically the remaining tasks.
I do not like the double negative in: "Do not leave the domain blank." Either make it a positive sentence about required values or remove this part completely as its added value is limited.
Comment #44
marcus7777 CreditAttribution: marcus7777 commentedremoved 'Do not leave the domain blank.' per #43
Comment #46
marcus7777 CreditAttribution: marcus7777 commentedComment #47
rudivanes CreditAttribution: rudivanes commentedA am manualy testing this right now.
Comment #48
rudivanes CreditAttribution: rudivanes commentedHere is the screenshot of manual testing before applying patch #44.
Comment #49
XanoIf the value field is no longer optional, shouldn't we add
'#required' => TRUE,
here?Comment #50
marcus7777 CreditAttribution: marcus7777 commentedscreen shot after:
Comment #51
alimac CreditAttribution: alimac commented@Xano The field cannot be required at this point because the domain fields are hidden and only appear when the user selects Domain radio button. (This form could be refactored but that's outside of the scope of this issue.)
Comment #52
rudivanes CreditAttribution: rudivanes commentedTested the before and after situation manually. The test went succesfully.
Before applying the patch leaving the english domain empty was allowed.
After applying the patch #44 it wasn't allowed and the correct error message was displayed.
Comment #53
marcus7777 CreditAttribution: marcus7777 commentedComment #54
XanoThanks! It makes total sense not to mark this field as required.
Manual testing was done in #52. Multiple people have confirmed the patch works, that this approach is the right one, and that the test coverage is sufficient. The code looks good. This is good to go!
Comment #55
ricardoamaro CreditAttribution: ricardoamaro commentedI' tested this on:
http://testbot.drupal-pt.org/node/404
You have the results here with 1 fail:
http://testbot.drupal-pt.org/sites/default/files/build_D80x_mysql55_PHP5...
Also you can have the results suite from:
http://testbot.drupal-pt.org/sites/default/files/build_D80x_mysql55_PHP5...
Tested:
DCI_TESTGROUPS="language,locale,system"
Comment #56
webchickCommitted and pushed to 8.0.x. LIVE FROM DRUPALCON! :D
Comment #58
Schnitzel CreditAttribution: Schnitzel commentedFollow up for the broken testbot: https://www.drupal.org/node/2350543