When installing usernode module, all usernodes were created correctly.
For new registered users no working usernodes are created.
In fact in usernode table as much rows as new users were created, but each new (correct) nid is assigned to the wrong uid 0.
My Installation:
Configuration file Protected
Cron maintenance tasks Last run 25 min 14 sec ago
You can run cron manually.
Database schema Up to date
File system Writable (public download method)
GD library bundled (2.0.28 compatible)
MySQL database 5.0.18
PHP 5.1.2
Unicode library PHP Mbstring Extension
Web server Apache/2.2.0 (Linux/SUSE)
Comments
Comment #1
jpetso commentedI can not reproduce this on my system. Do you run the latest CVS version of the usernode module?
If so, please provide more detailed steps on how to reproduce your issue. If not, please update and test again.
Comment #2
marcor commentedI took the one-day-old dev version and updated now to today's one (2007-01-29).
Still the same problem occurs.
I installed on a quite clean Drupal 5.0 system I only use for testing, with just a few modules and buddylist and views installed.
Sometimes I had problems with modules that are not compatible with php5, especially "array_merge" function, that seems to be often used but behaves differently now. Note: I'm not a php guru, this is just what I read about it.
usernode table:
nid uid
6 0 // user registered after usernode install
4 1 // admin
5 2 // user registered before usernode install
My Test-Installation:
Drupal 5.0
Configuration file Protected
Cron maintenance tasks Last run 4 weeks 2 days ago
You can run cron manually.
Database schema Up to date
File system Writable (public download method)
GD library bundled (2.0.28 compatible)
MySQL database 5.0.18
PHP 5.1.2
Unicode library PHP Mbstring Extension
Web server Apache/2.2.0 (Linux/SUSE)
Comment #3
luno commentedI'm experiencing the same problem on a fresh 5.1 install. Existing users were assigned a usernode when the module was installed, but new users are not added correctly to the usernode table. They all have a UID of 0.
mysql> select * from usernode;
+-----+-----+
| nid | uid |
+-----+-----+
| 6 | 0 |
| 8 | 0 |
| 9 | 0 |
| 4 | 1 |
| 5 | 2 |
+-----+-----+
5 rows in set (0.00 sec)
Comment #4
luno commentedLooks like the node table is also getting a uid of 0.
Comment #5
luno commentedNB: I'm using the LoginToboggan module. I've tried setting the checkbox for "immediate user login" and assigned a pre-authenticated role, with the same results as an ordinary (email-to-validate) account.
I uncommented the workaround that disables the "Your Usernode has been created." message and discovered that it appears just before "Your password and further instructions have been sent to your e-mail address" during account registration. I believe that at this point, the user is still a guest, so the usernode is being created when there is not a user logged in; $user->uid = 0.
Adding a few drupal_set_message() calls in the module reveals the following:
So 0 for the first function and "" for the second.
I don't know enough about drupal's hook system to get much further with this, but I think I'm on the right track.
Comment #6
luno commentedI was unable to get this working, with or without the LoginToboggan module. I'm giving up and using CCK for my application, along with a cron hook to ensure every user has one of the CCK nodes that I've developed. It still would be nice to have usernode working, though.
NB: There's no difference between the latest CVS version and the tarball in the modules page except for the CVS header line.
Comment #7
jpetso commentedOh yeah, that was an interesting problem. (I tried creating the users from the admin interface, which was why I didn't encounter this bug.)
This issue was caused by Usernode 5.x using drupal_execute() for programmatically submitting the usernode forms when creating them. (Usernode 4.7 did this by writing the tables manually, which was not quite as clean.) The point is that drupal_execute() is run with the permissions of the current user.
So while the form was submitted correctly, drupal_execute() simply didn't have the permissions to create a form for "another" user. (Even when registering a new user, you are still not logged in, so the uid of the global $user object is still 0.) Whereas from the admin interface it has to work because you've got the "administer nodes" permission.
The solution is as hacky as compelling ;) ...see the attached patch.
Comment #8
jpetso commentedMaybe also change the status of this issue accordingly.
Comment #9
fagoI've just committed the bugfix, so that there is a working version.
However I'd like to see a cleaner fix for this. One approach I can think of:
Change hook_access, so that usernodes may be created by the user as long as he has none. Then drupal_execute() should work and afterwards the user has no permission any more to create another usernode.
Comment #10
jpetso commentedI think hook_access() can't do it. The problem is not that the anonymous user can't create those usernodes at all - they are created indeed, only with "anonymous" as owner (it seems that hook_access is bypassed anyways, because $op='create' already returns false, so the anonymous user shouldn't be able to create a usernode anyways, but still does).
node_submit() only allows changing the owner uid (from the 'name' form value) if user_access('administer nodes') returns true. So I can think of the following possibilities to get it done:
- Temporarily log the user in (like the above patch has done) so that created nodes are automatically owned by the right user, without the need of changing the 'name' form field.
- Temporarily get 'administer nodes' access rights for the anonymous user, so that the specified 'name' field is actually respected.
- Change the owner after creating the node, but before writing the {usernode} table row. Which involves remembering the uid somewhere and use hook_submit() to actually set it.
I don't know how to do the second approach, but it doesn't seem less hacky than the current one. So maybe I can find a way to get a solution with the third approach. Thoughts?
Comment #11
fagoah yep, that's right. solution three sounds to be the best way, but what about this one:
* don't create usernodes on hook_user 'insert' anymore, but on hook_user $op login. then the user should be already logged in (;) and so we should have permission to create the usernode for him, if he hasn't already one. We could use hook_user to autoload the usernode id into the object, so it will be there after login. (otherwise not, because the session system doesn't invoke hook_user when it rebuilds the user object).
perhaps solution three is still better.. ;)
Comment #12
jpetso commentedTada! Let's have a type 3 solution :D
Comment #13
fagoI agree, solution 3 is the best one :)
However I'd love to see some improvements on the patch.
1. I think it would be cleaner if we remove the realuid field and just set $node->user (through a form field of type value) like the module does it, when a node is loaded. Then we could just set the usernode uid from $node->user->uid
2. For backward compatibility we can write back the uid from there on node submit, so that the node author still defaults to the usernode's owner, but please make sure that this is done only for usernodes. (content-type)
Comment #14
jpetso commentedSomething like this?
Comment #15
fagoyep, thanks. committed :)
Comment #16
(not verified) commentedComment #17
liquidcms commentedsorry to open.. but otherwise i guess no one see this...
AND.. i guess not a big deal since the cck nodes that get added as part of usernode (with regprofile) and the usernode itself is a custom type... but the entries for these nodes that does get entered into the node_revisions table still has uid = 0
Comment #18
fagothat's the task of the registerprofile and has nothing to do with the usernode. so please open an issue there.
Comment #19
socialnicheguru commentedsubscribing
Comment #20
fagodon't reopen old issues.