Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi everyone,
I am experiencing a problem where a duplicate node of a content profile is being created for users every now and then. Users fill out one content profile type 'Profile' and when they save they have, for example, node 25 and node 26 both with the exact same fields filled out. This happens once about ever 50 'Profile' nodes created. This is strange not only because a duplicate is being created each time but because it also has content profile checked in the settings.
Can anyone please assist?
Comment | File | Size | Author |
---|---|---|---|
#12 | duplicate_nodes-964490-12.patch | 617 bytes | fuzzy76 |
Comments
Comment #1
Bilmar CreditAttribution: Bilmar commentedHello,
I have confirmed this is happening as well.
When creating the content profile node for the first time, if you click the SAVE button 5 times, then I get 5 duplicate content profile nodes. Looks to be a problem as many users tend to press the SAVE at least twice usually so the common problem is 2 nodes appearing with the same content, different node, both content profiles.
I am marking this as priority 'major' as this issue makes the purpose of this module (one content profile node of type x per user) not work properly.
I hope this issue can be looked into with the information provided.
Thank you very much in advance
Comment #2
rutiolmaI confirm this issue too.
Comment #3
dmetzcher CreditAttribution: dmetzcher commentedI am seeing this issue as well. It just happened the other day on one of my sites.
I'm assuming that it's OK to delete it (Is this correct?), but I am wondering why it's there in the first place. Other users seem to have confirmed my suspicion that it was created when a user clicked the Save button more than once. Can anything be done about this to stop it from happening?
Here's a little more detail, in case it helps...
When I edit both of these nodes (example:
node/305/edit
andnode/306/edit
), the user's profile page is only updated when I edit the first one that was created (in my example it has a lower node ID of 305, whereas the second one has a node ID of 306). Editing the second profile node that was created does not change the user's actual profile page (user/123
). Also, when I update the user profile node via an edit to the user's actual profile page (user/123/edit
), the first user profile node is updated. The second node just seems to be sitting out there, orphaned. It was identical to the first one when they were both created, but it's not being updated now and appears to be an orphan ("duplicate-orphan"?).Comment #4
osopolarI guess this is still active. I wondered why a user had two profile nodes. There needs to be a check on node validate or submission (before node_save()) if there is a already a profile node of the current type and user. In this case just give an error.
I guess there are two ways how a user currently could create two or more accounts: 1) hit save button more than once; 2) first open two node/add/profile pages and than submit each.
Comment #5
scttnlsn CreditAttribution: scttnlsn commentedIt looks to me like there is already validation code in the nodapi hook that checks for the existence of a content profile for a particular type. If one already exists it sets an error on the form. The problem is that the validation is only performed if the current user has the permission "administer nodes". Is there a reason for this? I feel like the validation should be applied to anyone submitting the form.
Comment #6
AaronBaumanAnother problem is that if node_save is called directly, no validation is performed at all.
The attached patch implements nodeapi::presave, looks for existing profile nodes, and assigns the existing nid to the node if it's not already set.
Note this will not eliminate existing duplicate profile nodes, but will prevent duplicate future profile nodes from being created by node_save().
Comment #7
AaronBaumanComment #8
jrstmartin CreditAttribution: jrstmartin commentedI haven't had issues with duplicate nodes on the latest dev release yet. I do have that issue with other node types, so I was going to apply your patch just to be safe, but it doesn't apply to the latest dev release.
elseif
statements are used instead ofswitch
, so I'm not sure what was changed/improved here. Can you try the latest dev release without your patch and see if you get any dupes? Thanks!Comment #9
fuzzy76 CreditAttribution: fuzzy76 commentedThe patch in #6 won't apply. Actually, the nodeapi implementation in content_profile.module looks completely different from the one in the patch (uses if instead of switch and the line numbers are way off)? I also checked the changes done in the dev release, and couldn't find any that should be related to this bug.
Comment #10
fuzzy76 CreditAttribution: fuzzy76 commentedRewrote and added to the end of hook_nodeapi():
Too early to tell my results.
Comment #11
jvieille CreditAttribution: jvieille commentedI also get many duplicates when setting field values by rules, calling node_save.
I'll give a try to https://www.drupal.org/node/964490#comment-8660347
This code needs to be corrected though (missing "}"):
Comment #12
fuzzy76 CreditAttribution: fuzzy76 commentedPatch format
Comment #13
jukka792 CreditAttribution: jukka792 as a volunteer commentedHi,
I am getting this when a user has administrator role.
Creating a page or taxonomy term creates a duplicate. create taxonomy term, click save and you get it twice.
UPDATE: The reason was MAC Safari 11.1, which caused the double submits when creating a node or taxonomy term etc.
Comment #14
mrgoodfellow CreditAttribution: mrgoodfellow commentedI am getting the same thing when creating any new content type.
At the '/node/add/content-type' page for any content type, when clicking 'Save' multiple times, multiple items are created.
Ideally the save button only allows one submit and all further 'obsessive' clicking is ignored.
This is occurring on a clean install (Drupal 7, not occuring in 8)