This is a folk from http://drupal.org/node/83738, with alternative solution.
The problem of slow LOWER() on user.name can handle by 2 methods:
- add
name_lower: folk normal name field as name_lower, indexing it, and change all corresponding LOWER(name) queries into name_lower. - add
fullname: a new field with no limitation, restrict name AS STRICT AS email local-part (always lower case), keep existing checking queries in using name but compare with lowered input.
This patch try to approach the solution by second method. As a short run, code will not break even we don't upgrade the checking queries: the LOWER(name) is just dummy, since name is already stored as lower case; just without performance boost. On the other hand, it can simplify the checking of name: it is now combined with partly free form + strict email format, this patch upgrade its restriction and so checking will become more simple. As a long run, the additional free form fullname field can give enough flexibility to normal user, and input as whatever they like.
Patch already include core features, and tested with MySQL fresh installation. I will come back and handle the upgrade section :)
| Comment | File | Size | Author |
|---|---|---|---|
| #44 | drupal-6.x-dev-user_fullname-0.6.1.patch | 43.23 KB | hswong3i |
| #43 | drupal-6.x-dev-user_fullname-0.6.0.patch | 36.33 KB | hswong3i |
| #27 | drupal-6.x-dev-user_fullname-0.5.2.patch | 60.16 KB | hswong3i |
| #22 | drupal-6.x-dev-user_fullname-0.5.1.patch | 43.15 KB | hswong3i |
| #21 | drupal-6.x-dev-user_fullname-0.5.0.patch | 44.62 KB | hswong3i |
Comments
Comment #1
hswong3i commentedUpdate include:
P.S. The restriction upgrade for "name" may require for some reconsideration. PROS include:
But it come with some CONS: We give up some existing flexibility about username. On the other hand, we may also need to consider about the username upgrade and transformation, if we hope to employ the new standard within a one-take action.
Comment #2
chx commentedComment #3
hswong3i commentedPatch update: shouldn't restrict username as email syntax, e.g. in case of ADS, username is required in
domain\usernamesyntax. So keep user_validate_name() logic, and add lowercase checking.All existing username will convert as lowercase within database during upgrade from D5.3; on the other hand, all newly created account and user account update will stored as lowercase, too. Users are able to login with natural case: system will just filter it as lowercase. Actually, we don't really need to handle username in case sensitive: we always user LOWER() for filtering, handling all username in lowercase can solve the performance impact.
User's existing natural case username will folk as "full name" with no case or other limitation. It is just for display purpose. Some UI already update for this change (user block, user profile). With this new field, we can even provide search function according to full name (we miss this in drupal.org, as we use profile.module which don't have search function), or hide user ID from other users for more security.
Comment #4
hswong3i commentedComment #5
hswong3i commentedUpdate, no logical update with LOWER() but mainly for full name usability:
TODO:
Comment #6
hswong3i commentedminor update to blog.pages.inc: display full name rather than username.
Comment #7
stevenpatzIsn't it a little late for features in 6.x?
Comment #8
hswong3i commentedI guess so too. BTW, when compare with http://drupal.org/node/83738, if LOWER() is something that MUST fix within D6, and a new field is also a MUST for solving problem, I would even vote for adding a field which is meaningful for many cases (fullname) rather than something for compare ONLY (name_lower). We may find some better solution for replacing name_lower on tomorrow, but fullname should be what we really needed for. That's not easy to judge which solution is better: both are risky :'(
Comment #9
andrewfn commentedThe idea of having a fullname field as well as a username is a really good idea, for two other reasons apart from performace:
Comment #10
Crell commentedI agree with splitting a free-form display name from an easily-indexed login name for a variety of reasons, such as those listed in #9 as well as performance. I'm really not sure if we can safely do so at this point, though, for Drupal 6. Gabor, do you have any input here? I think this is the proper long-term solution, but it's your call if this is the right time for it.
Comment #11
hswong3i commentedminor update: use users.fullname for contact, openid and tracker.
Comment #12
hswong3i commentedminor update: add users.fullname supporting for comment, both UI and admin UI.
Comment #13
robloachWhat happens on websites where you don't care to collect your users' full names? The great thing about how theme_username is setup is that you can theme it to display a fullname field from the Profile module. We could also add the functionality to the profile module, allowing the fields to be searchable. Note that I'm just being devil's advocate here....
Comment #14
catchNo users on my site use their full names. There's also plenty of indymedia sites which would be put off by this being mandatory in core although there's nothing to stop people putting their screen-name twice apart from redundancy/irritation.
Comment #15
Crell commentedThe theme_username() solution is not a solution if you're listing a lot of user links on one page, because you then have to hit the database inside theme_username() to get the profile data for each user. That's terrible for performance.
We could make the "real name" field optional by a config setting, and display real name if set or login name if not, but now we're definitely getting out of D6 territory, I think.
Comment #16
hswong3i commented@Rob: Site security and user privacy can always improved by protecting user login ID from public; even some site don't need to care/consider about security/privacy, this won't be a bad idea for them. An in-house core/module hack can always solve the problem; BTW, this usually introduce more complicated maintenance issue :(
@catch: fullname field is now set as required, so every user need to provide that. Site upgrade from D5.3 will automatically folk existing username (with case styling) to fullname. On the other hand, if we don't hope to set fullname as required, we may hack theme_fullname(), check if $user->fullname exist, or else fail-as-default to theme_username(). We can adjust this handling with more discussion.
@Crell: I even brainstorming about a clone from eGroupWare, about case sensitive username issue (http://edin.no-ip.com/html/?q=node/348). Anyway, that is too far from D6 ;p
I guess my main focus is: name_lower can solve todays' problem, but it may be replaced by some other solution within a short future, e.g. fullname can work as an alternative. So if change is required for slow LOWER() issue, I would like to vote for a long term solution rather than a short one; it is just a bonus if fullname can benefit for more than we are hoping for :)
Comment #17
catchhswong3i: so how do users on my site log in after I've upgraded to 6.x if their login name is different?
Comment #18
hswong3i commented@catch: no change.
From the user point of view, they can use both "UserName", "USERNAME", "username" for their account login, even they save in whatever format in D5.3.
From the system and DB point of view, all record are converted as lowercase during upgrade, and all user input for authentication will also filtered as lowercase. So we don't need LOWER() compare during runtime.
Comment #19
hswong3i commented@catch: Just give a simple test for my blog with D5.3: my username is saved as "hswong3i", and I am able to login with whatever "HSWONG3I", HSWONG3i", "HSWong3i", "hswong3i", etc. So there is no change with user behavior between D5.3 and D6 w/o patch :)
Comment #20
catchSorry hswong3i, I just saw this bit, should've read through more carefuly.
Comment #21
hswong3i commentedUpdate:
TODO (UI update):
Comment #22
hswong3i commentedMinor update: thanks to Gabor's comment (http://drupal.org/node/174025#comment-625544), no strtolower() nor drupal_strtolower() is used, but optimize the use of LOWER():
name = LOWER('s'), so name will always filtered as lower case during input.LOWER(name) = LOWER('%s')in _user_edit_validate(): we don't really need to care about it performance impact during validation.name = LOWER('%s'), so indexing will keep its effect, on the other hand fully utilize LOWER() as user input filtering.P.S. This change won't change the meaning of adding
users.fullname: we hope to fully utilize indexing with a filed contain content in lower case, forcingusers.nameas lower case will lose all username styling. We still need eitherusers.name_lower(for lower case compare only, where keep styling inusers.name) orusers.fullname(store existing styling with more flexibility, where filterusers.nameas lower case for compare). Again, I vote for adding a meaningful field, rather than a compare-only field for performance boost only :)Comment #23
chx commentedUnlike the other two LOWER patches which keep changes to the absolute required minimum, this patch adds a new user facing field which is a feature and we are way past the freeze.
Comment #24
hswong3i commentedI think we may have some misunderstanding about the natural of this patch. Let's says in simple, this patch include 3 sections:
The first 2 sections are just "slow LOWER() issue" related. They are similar as http://drupal.org/node/83738, which just handle the same problem with different solution and implementation.
On the other hand, we may just seems UI update as usability enhancement. That is not a new idea for normal user (e.g. MSN, Skype, or even drupal.org both provide "full name" field for custom username styling with no limitation). There is not critical programming nor logical change among core, which just simply switch the display handling. Finally, it can improve user privacy and site security.
As the core idea of this patch is just similar as http://drupal.org/node/83738, no critical change to normal user, where bonus features are just usability enhancement (which may still welcome even we are in final beta status), hope we may give a kindly reconsideration about this patch for D6.
Comment #25
chx commented*shrug* I am out of D6 and out of debating with you. One of the core committers will surely set this back to 7.x
Comment #26
Crell commentedhswong, while I agree that your solution is better in the long term, chx is right that we've already been in D6 freeze for 4 months. This is not the time for new functionality, which we'd then have to check against existing usability standards, it would be more UI to debug, etc. Let's keep it simple for now, and come back to this version early in the D7 lifecycle.
Comment #27
hswong3i commentedMinor update:
TODO: ???
@Crell: I don't really care if we hope to postpone this for D7 or able to get in for D6: works are most likely done for UI update and debug, commit or not should just time dependent (if, this is a suitable solution...). BTW, if slow LOWER() issue is such critical that MUST fix within D6 cycle, I always hope to propose a better and complete solution, rather than a temporary name_lower field as a temporary solution.
Comment #28
deekayen commentedsubscribing (yes, I changed to 7.x on purpose. This is a feature request during a feature freeze)
Comment #29
hswong3i commentedJust hope to ask a simple question: will we postpone slow LOWER() issue (http://drupal.org/node/83738) with name_lower handling? If yes, name_lower will also postpone, so this issue must postpone, too; If no, we need to fix slow LOWER() within D6, therefore please don't postpone this counter solution which comes with better and complete handling: it is meaningful when brainstorming and compare for a better solution. Just focusing on a single solution will easily face deadlock and critical bug.
Moreover, this issue is just AS LATE AS chx's original proposal (Oct 8, http://drupal.org/node/181625), based on the definition of "feature freeze". I can't see the different between the natural of this 2 patches: we both touch DB schema, and hack a lot of codes for new handling. If this issue MUST postpone according to its late submit, please postpone BOTH slow LOWER() related issue :'(
P.S. Anyway, if name_lower is already committed, I will just take this easy, and update fullname issue for D7, based on required update for name_lower -> fullname conversation :)
Comment #30
Crell commentedThe other LOWER() solution involves no UI changes, and does not add new functionality. This does. That's the difference.
Edison, this is not going to make it into D6. Please don't play the back and forth game. Instead, when D7 opens for new features let's make this one of the first things that goes in.
Comment #31
hswong3i commentedMy last and only request: please let this issue open for D6 until: 1. name_lower is committed for D6, or 2. name_lower is postponed for D7. I have no business about this issue up to now since works are most likely complete.
I am totally understanding the risky of this patch, and I am not such stubborn about committing this issue for D6; BTW, I am always stubborn when requesting an open-end technical discussion ;p
Comment #32
chx commentedAfter deekayen , Crell and myself have said this is not Drupal 6 material, what else you want? The other name_lower issue might not be committed now...
Comment #33
hswong3i commentedAccording to the progress of this fullname issue and http://drupal.org/node/174025, we are now able to sort out a better solution with utilizing LOWER(): http://drupal.org/node/83738#comment-625640. This counter proposal just enrich the view angle of slow LOWER() issue, but not means it strike away the chance of name_lower in D6...
On the other hand, as we are both handling slow LOWER() by alternative lower case column, so we are working with the same target. The only different is: name_lower is much strict forward but temporary; fullname is much static and solid but too huge for D6. May be we should give core committers a chance for choosing. That should be no harm and no risk if we are able to employ whatever name_lower or fullname in D6. They may have some other and different concern :)
P.S. if core committers judge "fullname should belongs to D7, based on XXX and YYY concern. Let's move focus to name_lower!", I will not question for anything. I hate slow LOWER() issue as you all, on the other hand asking for a complete and better solution. That's all.
Comment #34
gábor hojtsyThis is a feature request with very huge changes. We are focusing on stabilizing Drupal 6, not adding new features, modifying the code in whatever place possible. Save this for Drupal 7.
Comment #35
hswong3i commentedThanks for everyone. According to existing research founding and our completely understanding about fullname issue, hope we will able to commit fullname for D7 whenever it is open for public development :)
On the other hand, I guess we are now able to conclude name_lower as the most suitable solution for D6, by the counter prove of fullname for D7, based on its complete research founding and successful foreseeing. Yes, name_lower is very late within D6 development cycle; it also seems ugly, lossy and temporary solution. BTW, name_lower hidden most handling from UI, and there is no change to client behavior. It also give no impact to existing API, as no additional abstraction is required. And the most important is, name_lower should give us the most smooth upgrade path for D7 with minimum impact :)
I guess we should move our focus to name_lower for D6, and let's fix the slow LOWER() on time, with the most suitable solution on hand; most other solution may introduce much complicated impact for D6, and difficult upgrade path for D7 (if we are considering fullname in D7).
Comment #36
pasqualleI like this feature, but it is missing one mayor requirement: how can I disable it?
I would rather use nicknames than full names on my site..
Comment #37
hswong3i commentedWhy would we need to disable it? From my point of view, let's take MSN messenger as an example:
Comment #38
pasquallelogin ID is not private, not even in MSN..
On web pages login ID is the one, that is displayed in most cases. People use their nicknames as login ID. Or it just become their nick name, on that particular web page..
It is a good option to display full name instead of login name, but it should be an option, not hard coded. I can imagine that intranet (company) networks will use this option, because they know their colleagues by real name, not by nicks..
Comment #39
pasqualleTake a practical example: sourceforge.net
On sourceforge you can only register a lowercase login name, with not special characters. This login name is so "clean" that it can be used even as cvs login. You can't change this login name. There is a "Publicly Displayed Name" field to change the login name to something more comfortable for you. But the login name is still displayed in many places.
This is an ideal situation. Drupal does not force such login name, and I do not think it will. So I think we need to create such name for special situations. To speed up these queries is just only one..
Comment #40
hswong3i commentedThat's why this patch should delay until D7: we may need to modify where and when should display fullname only, or together with user login ID. This is not something about the correctness of programming logic, but layout and usability which needed for more discussion :)
Take eGroupWare as example. As login name may authenticated by either SQL (default), SQL/SSL, LDAP, ADS, Mail, HTTP, NIS or PAM backend, user login ID is always preferred as simple as possibile (limitation is related with what authentication backend is chosen). On the other hand, both screen name and login ID are display on top right conner after user login. Screen name is also used when sending email notification.
Option for display is a good idea. I will give some effort of this later.
sourceforge.net is the most ideal handling that I can imagine, too. BTW, as we try toooo much effort for making users.name as flexible as possible in the past, it is not easy for rolling back the status to ideal. I try to explain this "down grade of username" idea with some of my friends once before, but most of them are objecting about this. I guess preserve old username styling with fullname, on the other hand filter existing username as lower case should be the most suitable solution based on our current status :'(
Comment #41
deekayen commentedI'd like to see this patch evolve into something that's a security "feature", whereby the username that's used for login isn't displayed on the site anywhere except to admins to make breaking into accounts that much harder. Perhaps there'd be a box to check somewhere to even enforce username != fullname.
Comment #42
andrewfn commented+1 to that. It would be a really important security feature.
Comment #43
hswong3i commentedCritical update:
check_plain($account->name). This change will give a great help to the previous centralized style handling.check_plain($account->name)bytheme('username', $account, array('plain' => TRUE)). (This progress may backport for D6)TODO:
[a-z0-9-_.]) and "email localpart mode" (restrict as email localpart limitation) for username validation, beside existing "lower case free form mode". Site upgrade from previous version will set as "lower case free form mode" after upgrade, in order to keep a valid login authentication; site with fresh new install will set as "enhanced strict mode", in order to provide maximum compatibility with 3rd part system, e.g. CVS. Change restriction into a not compatibile mode will not convert ANY existing user login ID; BTW, a message will always prompt up after user login, in order to remind some update of username is required for their account.fullname [name],fullname,name,name [fullname], etc. This hack should all done within theme_username() for centralized handling.Comment #44
hswong3i commentedBugfix and feature update:
!fullname,!username,!fullname [!username]and[!username] !fullname. Administrator may define custom styling.TODO:
Comment #45
birdmanx35 commentedNo longer works against HEAD.
Comment #46
Dave Cohen commentedI'm glad I discovered this thread.Subscribing. I've been reading up on http://drupal.org/node/102679 and http://drupal.org/node/83738. I believe you're on the right track to address both problems.
Small suggestion, I think the patch would be simpler if instead of introducing fullname (which may not literally be someone's full name) you introduce a new name_login, then change name to be the non-unique, displayed name. Then you'd change the login logic to use name_login, and skip all the changes from $obj->name to $obj->fullname and save third-party modules the trouble of ever having to learn about $user->fullname.
My three columns would be:
Further, I would not make ANY UI changes. Keep the default behavior the same. Then third-party modules using form_alter and other hooks can make the UI changes.
Comment #47
dmitrig01 commented+1
Comment #48
pwolanin commentedduplicate to #279851: Replace LOWER() with db_select() and LIKE() where possible