Voting starts in March for the Drupal Association Board election.
Today while working with the db, i realized that some users had multiple bio nodes. I don't know how they were able to do this. Does anybody have the same problem?
Yes; I'm seeing exactly the same problem. I'll have a look at the code.
Ok; I looked at the code in bio_nodeapi, and there are only three operations, 'validate', 'insert' and 'delete'.
Validate checks that there's not an existing bio node for the user and exits with a form_set_error notifying the user that a bio already exists and giving a link to that node, which is fine.
Insert inserts the nid and uid into the table 'bio' even if there is already a bio node associated with that user.
Delete simply deletes the nid and uid record from the bio table.
The attached patch will check for a pre-existing bio node for the user and creates a new entry in bio if there isn't one already; otherwise it creates a log entry with details of the error and doesn't create a new record.
This doesn't fix the problem (though it will stop it recurring) but it should give some clues as to where the code is being called from.
I've installed it on our site, and will be keeping a close eye on the system log!
I'll also be writing some code to remove the duplicate nodes and all references to them, but not today: it's 02:53!
Investigation sponsored by Charity Rallies
Thanks, i've applied the patch and will be checking the log.
I've managed to reproduce the problem:
- enable automatic creation of bio nodes on registration
- log out of your site
- create a new account page
- enter all your information
- click submit
- while the page is loading, click submit again three times in a row.
- at this point, three bio nodes have been created for this user.
I am having this problem on a client site and will try to submit a patch.
A more consistent way of reproducing the bug is to do as in #4, but rather than reload the page while it is loading, wait until you get your confirmation message, then hit the back button on your browser, then click submit again. Using this technique it is possible to create any number of bio nodes for a single user.
Here is a patch that does two things:
(1) upon registration, create a bio node *only* if one does not already exist.
(2) when calling bio_for_user(), put a message in the watchdog in case more than one bio exists for a user.
Drupal is a registered trademark of Dries Buytaert.