This is actually against alpha6, not alpha3.

When using the site signup form with "Automatically create user accounts for new clients." selected, the clients that are created don't have a UID associated with them when the signup is done by an anonymous user. This is also true for the site node.

IMHO, the desired effect when an anonymous user creates a site+client+user should be that the client and site UID's both get set to the new user UID. It's a bit questionable though, since technically it is the anonymous user who's creating the site I just don't think you'd want anonymous to own the site if you're creating a user account to go along with it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hadsie’s picture

Status: Active » Needs review
FileSize
406 bytes
814 bytes

Patches for the signup and client modules that seem to do the trick for me.

hadsie’s picture

Project: Hostmaster (Aegir) » Hosting

I think this should be in the hosting queue not hostmaster...

hadsie’s picture

FileSize
816 bytes

Rerolled the client patch against the alpha8 release.

adrian’s picture

Status: Needs review » Needs work

i'm worried about an infinite loop in this

the set_title function gets called by node_save, and you are calling node_save from inside it.
what happens when you change the setting for revisions?

hadsie’s picture

I'm calling node_save from within the hook_insert, not set_title. However, I'm not totally sure of all the implications of doing it this way either. Do you think it would be better if this code manually ran the db query as set_title does? So something like...

  db_query("UPDATE {node} SET uid=%d WHERE nid=%d", $user->uid, $node->nid);
  db_query("UPDATE {node_revisions} SET uid=%s WHERE vid=%d", $user->uid, $node->vid);
hadsie’s picture

Status: Needs work » Needs review
FileSize
940 bytes

Updated the patch to do basically what I said in #5. In the most recent version of aegir the signup patch is no longer needed only the patch to hosting_client.module that I've attached here.

adrian’s picture

Status: Needs review » Fixed

committed. thanks.

[master 7cfda05] New users are associated properly with their respective clients on signup. thanks hadsie #767008
1 files changed, 4 insertions(+), 1 deletions(-)

hadsie’s picture

Status: Fixed » Needs review
FileSize
563 bytes

I've been looking into this some more, and it seems I really don't understand how PHP's pass by reference works. The problem with my patch was that I only updated the client node, which works, however, the correct UID is still not assigned to the client node object since I forgot to add $node->uid = $client->uid in the patch. Without having the client node uid set properly on the object, the ownership of the site node will not be correctly set in hosting_signup_form_submit().

function hosting_client_insert($node) does not appear to be passing $node by reference, but in fact it is. This can be seen by the fact that hosting_client_set_title($node) is actually able to alter the $node object (perhaps objects are passed by reference by default in php?).

Anyway, the patch attached here adds a one line fix to the function to also set the uid on the $node object as opposed to just the db. This way the signup form will properly set the UID on the site node as well.

Anonymous’s picture

Status: Needs review » Fixed

Thoroughly lucid explanation (which helps idiots like me) - I tested this and it fixes exactly what it says it does.

P.S, while trying to understand, I did some research and yes, in PHP5 objects are passed as references by default.

The patch isn't clean (not from the top of the repo tree) but this has been sitting around being ignored and it's a fix that works, so I'm committing it.

Thanks very much!

hadsie’s picture

Thanks @mig5! :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit b1c75d4 on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by adrian:
    New users are associated properly with their respective clients on...
  • Commit 48723bf on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by mig5:
    #767008 by hadsie - fix to make site nodes owned by client when using...

  • Commit b1c75d4 on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by adrian:
    New users are associated properly with their respective clients on...
  • Commit 48723bf on 6.x-2.x, 7.x-3.x, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by mig5:
    #767008 by hadsie - fix to make site nodes owned by client when using...