Steps to reproduce:
- Create a node and make sure it's a group.
- Edit the node and remove the author (making it anonymous)
- FAIL.
When I first remove the checkbox for 'Group', then remove the author and re-enable de Group checkbox, it works.
So somewhere in the code, OG tries to add the anonymous user to the user table?
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name': INSERT INTO {users} (uid, name, pass, mail, theme, signature, signature_format, created, access, login, status, timezone, language, picture, init, data, vid, ip) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17); Array ( [:db_insert_placeholder_0] => 299 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => 0 [:db_insert_placeholder_8] => 0 [:db_insert_placeholder_9] => 0 [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => [:db_insert_placeholder_12] => [:db_insert_placeholder_13] => 0 [:db_insert_placeholder_14] => [:db_insert_placeholder_15] => b:0; [:db_insert_placeholder_16] => 316 [:db_insert_placeholder_17] => ) in drupal_write_record() (line 6975 of /includes/common.inc).
Comment | File | Size | Author |
---|---|---|---|
#11 | 1516108-11-og-removing-node-author-triggers-PDO.patch | 626 bytes | BarisW |
#2 | 1516108-og-removing-node-author-triggers-PDO.patch | 511 bytes | BarisW |
Comments
Comment #1
BarisW CreditAttribution: BarisW commentedAnyone?
Comment #2
BarisW CreditAttribution: BarisW commentedDigging through the code, I found the following:
og_node_update()
callsog_group()
when the author of a node has changed. It doesn't check if UID == 0.In the end of
og_group()
aentity_save()
is called which does auser_save()
.I'm not sure if this is a core bug (user_save() tries to create the user (and fails, as uid '' already exists).
I came up with the following, which works. I cannot determine if this has consequences somewhere else in the module logics, so please review.
Comment #4
BarisW CreditAttribution: BarisW commented#2: 1516108-og-removing-node-author-triggers-PDO.patch queued for re-testing.
Comment #6
Nephele CreditAttribution: Nephele commented#2: 1516108-og-removing-node-author-triggers-PDO.patch queued for re-testing.
Comment #8
Nephele CreditAttribution: Nephele commented#2: 1516108-og-removing-node-author-triggers-PDO.patch queued for re-testing.
The patch was failing originally because of #1748782: Existing 7.x-1.x-dev code always fails QA tests. The most recent failure was a testbot client malfunction. It now appears to have passed testing.
Comment #9
BarisW CreditAttribution: BarisW commentedAh, that explains.
Would love to get some feedback on this from amibutai, whether this is the correct way to do it.
Comment #10
amitaibuIt's probably better to move the $uid check directly into
OgMembership->save
Comment #11
BarisW CreditAttribution: BarisW commentedIt doesn't seem to get to
OgEntity->save()
. When I insert adie()
in that place, it keeps working fine.I've now added it just before
<code>entity_save($entity_type, $entity);
is called.Is that any better?