Problem/Motivation
In #2339151: Conditions / context system does not allow for multiple configurable contexts, eg. language types both @EclipseGc and myself found that the language negotiation form does not save values immediately. One needs to go back to the form and save it again to get settings to actually save.
Steps to reproduce:
- Enable content translation module
- On admin/config/regional/language/detection check content language negotiation to be customized
- Actually customize settings, eg. disable URL negotiation, enable session
- Observe page coming back but settings are only partially saved (session not enabled)
- Any further change will save all changes, above only happens for the first change
Proposed resolution
- Fix it
- Add tests
Remaining tasks
Task | Novice task? | Contributor instructions | Complete? |
---|---|---|---|
Create a patch | Instructions | ||
Add automated tests | Instructions | ||
Add steps to reproduce the issue | Instructions | (done) | |
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards | Instructions |
User interface changes
Form will not lie about saved setings.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#17 | 2364171-language-negotiation-17.patch | 2.82 KB | penyaskito |
#17 | 2364171-language-negotiation.interdiff.14-17.txt | 663 bytes | penyaskito |
#14 | 2364171-language-negotiation-14.patch | 2.74 KB | penyaskito |
#14 | 2364171-language-negotiation.only-test-14.patch | 2.17 KB | penyaskito |
Comments
Comment #1
YesCT CreditAttribution: YesCT commentedComment #2
YesCT CreditAttribution: YesCT commentedComment #3
Gábor HojtsyThese tests should expose the problem. Let's see if they do.
Comment #5
Gábor HojtsyParenthesis needs to be at the right place.
Comment #6
Gábor HojtsyA non zero byte roll of what 5 should have been lol.
Comment #7
Gábor HojtsyThis issue will be a great one to show to pepole why they should not be afraid that they post silly patches :D Paying more attention++
Comment #10
Gábor HojtsyNow fails for the right thing. We can work on fixing the bug.
Comment #11
penyaskitocore/modules/language/src/LanguageNegotiator.php
:$default_types
contains onlylanguage_interface
yet.Comment #12
Gábor HojtsyShould call languageManager::reset() then before invoking this one I would guess. Or this one should invoke it I guess.
Comment #13
Gábor Hojtsy@penyaskito said in IRC this solved the issue but the test is not confirming it.
Comment #14
penyaskitoOk, gotcha.
I'm not sure if this is what we expect, but this is how language.types.yml looks like after saving some config:
The test is checking with
in_array
, but should usearray_key_exists
.Comment #16
Gábor HojtsyLooks great! Only one thing:
Let's add a comment. Something like "Configurable language types might have changed. Reset the cache."
Comment #17
penyaskitoSure, done that.
Comment #18
Gábor HojtsyLooks great!
Comment #19
catchWhy doesn't the code that changes the configurable language types reset this cache?
Comment #20
Gábor HojtsyThat's a great suggestion. That would be in NegotiationConfigureForm::submitForm(), right before the first $this->negotiator->updateConfiguration() is called.
Comment #21
penyaskitoWe are already resetting the language manager (even clearing the negotiator manager cache) on
purgeConfiguration()
andupdateConfiguration()
... so why not insaveConfiguration()
? Otherwise, the form will know too much about the language manager, and even can cause issues if reproducing this via API.Comment #22
alexpottI agree with @penyaskito putting the cache clear on the form layer feels wrong - having it in LanguageNegotiator::saveConfiguration() feels right - if anything calls that API, Drush, form this will reset the language manager and the configuration we change the system as expected once saved.
Comment #23
alexpott@penyaskito wanted to assign this to @catch
Comment #24
catchSomething is still niggling but it's not concrete, and I agree this shouldn't be done in the form, so this seems OK.
Committed/pushed to 8.0.x, thanks!
Comment #26
Gábor HojtsyYay, thanks!