Right now, we have many confusing fields in the client content type:
* Email address ($node->email, unique)
* Client name ($node->client_name, optional?)
* Organization ($node->organization, optional)
We have already changed the "Contact name" the be the "Client name" which helped but also confused things (#443258: A client's "contact name" should be "client name"). This could be reverted easily. The organisation could be promoted to be the base "client name" and be the complete node title *and* be unique.
I now feel we should have only one field:
* Client name ($node->title, unique)
The idea is that the "contact name" has already been dropped: the "client name" and "organization" are therefore duplicates. Furthermore, they are duplicated in the node title, so we could just use the node title there. I also feel the email shouldn't be a reference for clients, as they are associated with people or "contacts", those are the users and those are the ones that we should use to contact people. For this, see #461840: type client/user relationships and #336068: Confirmation e-mails should be sent to client users, not to the client email.
With this, we properly cover our two use cases:
* individual clients (client title/name = user name)
* organizational clients (client title/name != user name)
The signup form would "just" need to be changed to take that into account. The UI changes would be minimal except within the client node itself, which is already quite confusing.
The upgrade path would go as follows:
* 0.4 would deprecate the email field and 0.5 or 1.0 would drop it.
* the current client name would be dropped, as it's already in the node title
* organization would also be dropped, as it's also in the node title
* the node title would become the client name
Comment | File | Size | Author |
---|---|---|---|
#7 | 962330_drop_org_name.patch | 12.07 KB | anarcat |
Comments
Comment #1
anarcat CreditAttribution: anarcat commentedNote that this would completely resolve a major bug we have right now: #962338: duplicate clients can be created.
Comment #2
adrian CreditAttribution: adrian commentedemail is the only field that can be considered unique.
there are more than one 'john smith's in the world. This is why the client name contains the email address too.
Comment #3
adrian CreditAttribution: adrian commentedthere may also be more than one john smith working at , say, microsoft.
Comment #4
anarcat CreditAttribution: anarcat commentedBut there is only one "Microsoft", or there is "Microsoft canada", "Microsoft" and "Microsoft France". Also, I feel we're too easily confusing the client with the contact here: "John Smith" at Microsoft, if there are many of those, can be distinguished by their email addresses because they are users, and for those the email is unique.
By enforcing unique client names, we clarify a very blurry situation: if someone tries to register a "John Smith" *client* right now and there's already one, he will actually be allowed to do so, which creates havoc after because we end up with a zillion John Smiths.
Just like you can only have one john.smith@gmail.com (when you register a "client" at gmail), we shouldn't allow duplicate client names.
Comment #5
anarcat CreditAttribution: anarcat commentedI will work on this now, as I need this for LDAP integration.
Comment #6
anarcat CreditAttribution: anarcat commentedI am in the progress of writing a patch that would do the following:
* dropping the organisation and client name field
* make the title field mandatory and checked for uniqueness
* add a "uname" field that would be a machine-usable field (for mapping with UNIX groups, for example) and unique
* remove email from the forms - but keep in the db
Things that remain to be seen:
* testing
* what happens if client_email is not filled in?
Comment #7
anarcat CreditAttribution: anarcat commentedSee attached patch for now.
Comment #8
anarcat CreditAttribution: anarcat commentedAlright, this is now really ready for testing. I have pushed a feature branch on git.d.o for this that i would like people here to test. the branch is named dev-refactor-client-962330 in hostmaster.
Just create a platform with:
and test the upgrade:
I have made sure the changes are isolated in separate, clean commits to make debugging easier. --debug should also give you a lot of information about the duplicate resolution process. If there are more than 100 accounts with similar names, this will fail and will require a patch, but I think this is really unlikely.
The existing data is not destroyed, apart from the client node titles which are replaced with the "unique" version.
I'm looking for the following tests:
1. if your dataset survives the migration well
2. if the client creation form still works
3. if the registration form still works
4. if emails are sent to the right place
Comment #9
anarcat CreditAttribution: anarcat commentedFor the record, in the above tests, I have performed tests #1, #2 and #3 successfully.
I hope to *not* have to test #4 because of #336068: Confirmation e-mails should be sent to client users, not to the client email but i'm afraid that will take more time than what i really want to do here.
Comment #10
anarcat CreditAttribution: anarcat commentedSince this is a significant API change late in the release cycle, I have officially requested the community's benediction for this exception:
http://community.aegirproject.org/node/496
Comment #11
anarcat CreditAttribution: anarcat commentedNow that 336068 works well, I have gone further and got rid of the email in the frontend and backend.
The data in the tables is still left intact, but the forms have all been redone. There is now better glue between the signup form, which now respects the "register new user" setting for now and will yield a warning if the signup form is used by an anonymous user without 'register new user' option.
I am merging this in master, as it works according to my (all day) tests.
I am marking this to be ported until we get approval for the final merge into the stable branch.
Comment #12
sfyn CreditAttribution: sfyn commentedI've made a summary for myself of anarcat's changes for use in my patch to uc_hosting, maybe someone else will find them useful;
Database columns dropped:
* name in hosting_client
* organization in hosting_client
* email in hosting_client (?)
Database columns added:
* uname in hosting_client
Functions affected:
* hosting_client_node_info
* hosting_client_form
* hosting_client_validate
* hosting_client_insert
* hosting_client_update
* hosting_client_delete
* hosting_client_users
* hosting_client_views_data
* hosting_signup_form
* hosting_signup_form_validate
* hosting_import_site
* hosting_hosting_site_context_options
* hosting_add_task
* hosting_get_most_recent_task
* hosting_signup_thanks
* hosting_signup_form
Comment #13
sfyn CreditAttribution: sfyn commentedFor the time being I would suggest not deprecating the email field from the client. Because hosting_get_client_by_email is the only obvious api function to reliably get a client.
Here's my suggested strategy:
* Mark hosting_get_client_by_email as deprecated- have it issue warnings in php or to watchdog when it is called
* Create hosting_get_client_by_name as a drop-in replacement for this function
Maintain this for the 1.0 branch, and then move to this in a later release (1.1?) - we could have a special release just for api cleaning like this.
Comment #14
anarcat CreditAttribution: anarcat commentedThe problem with hosting_get_client_by_email is that if we don't *have* an email field (e.g. on new installs), it won't work reliably anymore.
So either we keep the email field in the client node, or we don't - we don't have to destroy the data, but we do have to make a choice on the form, because even if we create the field on new install, if there's no email field in the form, it won't get populated and that function will still not work.
What do you still use hosting_get_client_by_email() for?
And hosting_get_client_by_email() is actually still there, the email field is not dropped from old installs - new installs should just use the client internal name (or the nid) as the unique identifier, why doesn't that work for you?
Comment #15
anarcat CreditAttribution: anarcat commentedI have deprecated the hosting_get_client_email() call in head, so that's another commit to merge in stable.
Comment #16
sfyn CreditAttribution: sfyn commented> What do you still use hosting_get_client_by_email() for?
>
> And hosting_get_client_by_email() is actually still there, the email field is not dropped from old installs -
> new installs should just use the client internal name (or the nid) as the unique identifier, why doesn't
> that work for you?
OK, in uc_hosting I am trying to make sure that when people buy new stuff, and they're not logged in, that we avoid the creation of duplicate clients when the info they enter on the purchase form corresponds to an existing client. So I used the email address. Using the nid or even the title in this case is less reliable, I feel.
But I guess it was time to rewrite those functions in uc_hosting anyway, so that's what I'm going to do.
However, if other people writing contrib modules for aegir have made the same mistake I did, and they aren't aware of this change, then they are going to get hit, so that's why I suggested a transitional strategy.
Comment #17
anarcat CreditAttribution: anarcat commentedMy opinion on this is that we're better off making the transition right now, put it in the release notes, so that we have a *good* 1.0 API instead of a crappy one. :) Once 1.0 is out, we will *not* be making any more changes of this nature, that is absolutely certain, until 2.0, for the exact reason you mentionned. But since we're in a RC cycle, I figured this would be a better time than to wait months...
This is why I asked for a feature freeze exception for this to be merged in the stable branch. If you really think we should keep the email field, we can, but it will be until 2.0.
Keeping the email field in the client would require more work now, actually, because i actually went through the whole migration process and we'd need to have a mixed strategy of having the email for the client *and* the user. I really like the orthogonality of the new way things work.
That said, if you want to check for uniqueness of the client submitted, you should rely on existing functions. Look at how the signup form works. The uc_hosting should derive from that, and avoid, as much as possible, copying code but instead call existing functions.
For example, to validate the client submitted, the signup form does this:
... which will in turn call hosting_client_validate() which will check for duplicates (and even suggest alternate usernames! :).
I haven't looked at the uc_hosting code, but it should be very similar to the regular signup form...
Comment #18
sfyn CreditAttribution: sfyn commentedAlright, well I have no objection to that personally. Like I said, I want to look at reworking uc_hosting to just use the signup module directly.
Thanks!
Comment #19
anarcat CreditAttribution: anarcat commentedI have merged this in the stable branch.
Comment #20
anarcat CreditAttribution: anarcat commentedA summary of the changes here is detailed in this post: http://community.aegirproject.org/node/521