As per #1216094: We call too many things 'language', clean that up we are converting schemas and parallel APIs to use 'langcode' instead of 'language' where a language code is involved. The use of 'language' inconsistently for language objects and language codes in Drupal 7 keeps throwing people off the cliff and makes understanding the API much harder.
This issue is about user.module needing the same conversion to move from $user->language to $user->langcode. Will need updates and upgrade tests but first of all it would be a well focused search and replace wherever user language is involved.
Comment | File | Size | Author |
---|---|---|---|
#36 | 1439680-36.patch | 17.63 KB | effulgentsia |
#35 | 1439680-35.patch | 15.49 KB | effulgentsia |
#30 | 1439680-30.patch | 15.46 KB | kalman.hosszu |
#24 | 1439680-24.patch | 14.73 KB | kalman.hosszu |
#22 | 1439680-22.patch | 12.5 KB | kalman.hosszu |
Comments
Comment #1
clemens.tolboomJust some greps to get an idea
Comment #2
balagan CreditAttribution: balagan commentedComment #3
balagan CreditAttribution: balagan commentedI have changed the $user->language to $user->langcode and $account->language to $account->langcode.
Also changed the language in database schema to langcode (user.install).
Comment #5
balagan CreditAttribution: balagan commentedSecond try...
Comment #6
Gábor HojtsyComment #8
kalman.hosszu CreditAttribution: kalman.hosszu commentedPatch attached.
Comment #9
fubhy CreditAttribution: fubhy commentedThis is not required. We can just use
Is this a completely new index? If yes, what does it have to do with the patch? If not, where do we remove the old index? :)
Comment #10
kalman.hosszu CreditAttribution: kalman.hosszu commentedChanged upgrade test method, and new index is removed.
Comment #11
fubhy CreditAttribution: fubhy commentedOk, looks good now!
Comment #12
Gábor HojtsyLet's at least wait for the tests to come back green :)
Comment #14
balagan CreditAttribution: balagan commented3rd try... (needs merging with Kalman's upgrade patch)
Comment #15
kalman.hosszu CreditAttribution: kalman.hosszu commentedMerged with balagan's patch in comment 14.
Comment #16
fubhy CreditAttribution: fubhy commentedThere is some unwanted whitespace in the line above $langcode_spec
Comment #17
balagan CreditAttribution: balagan commentedComment #18
Gábor Hojtsy@kalman.hosszu: your patch is much smaller then balagan's so its likely not merged. Can you post a merged version?
Comment #19
kalman.hosszu CreditAttribution: kalman.hosszu commentedSorry Gábor, I attached the unmerged file.
Attached again
Comment #21
Gábor HojtsyThe remaining test fails need to be fixed. Just two notes on the patch:
Can we set this to Catalan (available in the dump) instead just to be more interesting :)
This should go to a new update function and not extend an existing one (to support D8-D8 upgrade path).
Comment #22
kalman.hosszu CreditAttribution: kalman.hosszu commentedI changed the patch based on Gábor's comments.
The remaining failed tests need to be fixed.
Comment #24
kalman.hosszu CreditAttribution: kalman.hosszu commentedSome of the failed tests are fixed. The openID test fix is remained.
Comment #26
effulgentsia CreditAttribution: effulgentsia commentedIn #1444992-12: Add langcode property in file schema, Damien says:
It seems like between this issue, that one, #1444966: Add langcode property in taxonomy schema, and perhaps others, we're trying to have a consistent langcode property for all entity types, but that for users, the meaning of this property is different. Should we actually be renaming this property to something like
preferred_langcode
and adding a separate langcode column for identifying the language of the entity itself?Comment #27
tstoeckler@effulgentsia: I think that would be #1410114: Rename $user language property to something else
Comment #28
tstoecklerOops, hadn't seen that was closed. Hmm....
Comment #29
effulgentsia CreditAttribution: effulgentsia commentedHah! I hadn't seen that issue, or that Gabor proposed the same name :)
Comment #30
kalman.hosszu CreditAttribution: kalman.hosszu commentedThe new patch is attached.
Comment #31
Gábor Hojtsy@effulgentsia: yes, I clearly thought originally that we should treat $user separately at first. *But* (a) nobody else cared for a month, which was a clear sign this should not be complicated, see that issue (b) even if we want to separate the two meanings, we do want to have a langcode in any case (meaning the language code for the user entity). So if we branch the $user->language to two properties, one would be 'langcode', and in updates, the best we can ensure is that that langcode is what 'language' was before, so we need to update the existing language and use that data in langcode either way.
Then if there is a true interest in branching this property out to two things, then we can do that as a next step too. I don't think we'd want to expose two language selectors on the user UI for example (select your profile data language here and then select your preferred site language here in the next dropdown), so the default built-in UI/behavior would be to handle both as the same and sync their values anyway, right? That is likely why nobody cared for the existing issue where I'd have started with a different name at first.
If we do want to change to preferred_langcode first, we can certainly do that here, but we'll need a 'langcode' type value anyway to support the user entity/field language backend (and that would be derived from the same language property in upgrades from D7).
What do you think?
Comment #32
Gábor HojtsyBTW we can also spawn to langcode *and* preferred_langcode here right away and choose either to expose on the UI and just make the other a #type => value so a contrib / site specific module can make it exposed if they want to make the two things separate, otherwise just use the same value for both when saved/changed?
Comment #33
effulgentsia CreditAttribution: effulgentsia commented#30: 1439680-30.patch queued for re-testing.
Comment #35
effulgentsia CreditAttribution: effulgentsia commentedThis is just a reroll of #30 for chasing HEAD.
Comment #36
effulgentsia CreditAttribution: effulgentsia commentedRe #32: yeah, I think we should deal with both langcode and preferred_langcode in this one issue.
Here's a patch that renames the existing language field to preferred_langcode, and adds a *new* langcode field that defaults to LANGUAGE_NONE, just as in #1444992: Add langcode property in file schema and #1444966: Add langcode property in taxonomy schema. I see no reason why core should assume that langcode has any relationship to preferred_langcode. Instead, when we figure out what logic core and contrib should use for determining the langcode of taxonomy terms and files, then I imagine a similar logic/workflow will be needed for account profiles, independently of users configuring their preferred site language. But, this is just my naive gut feeling. If you have experience to suggest there is a relationship between the two that we should maintain, please educate me.
Comment #37
Gábor Hojtsy@effulgentsia: I do think making it possible to have separate preferred language and entity language for users as a possibility is good. I dont think we should expose that in core though, having two language fields on your user profile is puzzling at best. Also, since there is no separation for the two values in D7, the language is also used as entity language in contrib modules so I think the only logical way to handle this is to (a) upgrade to have both new properties use the same value (b) maintain both values as equal until we have any good idea as to how to expose them separately (or contrib will do that).
Comment #38
effulgentsia CreditAttribution: effulgentsia commentedMerging this into a combined issue in #1454538: Add langcode property to all entity types; for the user entity, distinguish entity language from user's language preference. Will address #37 in that patch.
Comment #39
Gábor HojtsyRemoving outdated tags.