Using an existing client name during anonymous checkout still allows the site to be ordered, but assigns it to the existing client (and associated user). It also throws the following errors:
Client name already in use.
user warning: Duplicate entry 'ergonlogicenterp' for key 'uname_unq' query: INSERT INTO hosting_client (vid, nid, uname) VALUES (142, 120, 'ergonlogicenterp' ) in /var/aegir/hostmaster-6.x-1.2/profiles/hostmaster/modules/hosting/client/hosting_client.module on line 306.
Validating the "company" field (or client name, or whatever) should avoid this.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | uc_hosting-Unique-client-titles-1236558-3.patch | 1.15 KB | jayelless |
Comments
Comment #1
ergonlogicMy patch in #1237178: hosting_client_validate_suggest() appears broken mostly fixes this. However, hosting_client_validate_suggest() will only work for the first 10 duplicates. Admittedly, that is an edge case.
But the code below (lines 252-5 from _uc_hosting_add_client in uc_hosting.module) doesn't actually do what it says:
Since we aren't validating a form at this point, we can't use hosting_client_validate()... So maybe we need to suggest/write a new Aegir function: hosting_client_is_unique() or something.
Comment #2
ergonlogicAha! just found:
So, maybe break out the client construction code from _uc_hosting_add_client, and check that a form submission would result in a unique client?
Comment #3
jayelless commentedI experienced this problem, and was investigating this issue, along with the fact that the created hosting client node titles were generated with an unnecessary zero tacked onto the end (even when they were unique and there was no name collision).
Additionally, when a long client name was entered (or company name when that was used), then the resulting client name and client title were rejected.
I had the following errors:
The code in comment #1 above does not provide for uniqueness in the first 16 characters ("MAX_GROUP_LENGTH"), which is required for uname.
I believe the solution is to recode the section that forces a unique client username and title as follows:
This code will cycle though as many iterations as are required to find a unique "uname" within the MAX_GROUP_LENGTH string length, and will also add the numeric suffix to the title that would otherwise be generated (it does not have the same length restriction).
This change appears to work correctly for anonymous users as well as logged in users.
Patch attached
Comment #4
gboudrias commentedAfter testing and validating with ergonlogic, I pushed jlscott's patch to the 6.x-1.x branch.
Thanks!