first thanks for the great module. it is lightweight and powerful.
when an anonymous user subscribe a thread by posting comments,
the following code will run
if ($comment['notify']) {
$notify = $comment['notify_type'];
$current = db_result(db_query("SELECT count(1) from {comment_notify_user_settings} WHERE uid = %d", $user->uid));
if ($current == 0) {
db_query("INSERT INTO {comment_notify_user_settings} (uid, comment_notify) VALUES (%d, %d)", $user->uid, $comment['notify_type']);
exit;
}
the INSERT statement will try to insert uid as 0. however because the table was defined as the following
+----------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------------------+------+-----+---------+----------------+
| uid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| node_notify | tinyint(4) | NO | | 0 | |
| comment_notify | tinyint(4) | NO | | 0 | |
+----------------+------------------+------+-----+---------+----------------+
the above statement will indeed add the next available uid instead of 0. for example, if the max uid in this table is 123, then
INSERT INTO {comment_notify_user_settings} (uid, comment_notify) VALUES (0, 1)
will result a row as
+-------+-------------+----------------+
| uid | node_notify | comment_notify |
+-------+-------------+----------------+
| 124 | 0 | 1 |
so this anonymous user really helped user (with uid 124) set up his preference...
I believe for anonymous users, this DB INSERT call should be avoid because anonymous users really do not have a setting of their profile.
please advise. btw, my DB version is MySql 5.0.45
Thanks.
Comment | File | Size | Author |
---|---|---|---|
#2 | 409850_prevent_uid_0_saving.patch | 2.9 KB | greggles |
Comments
Comment #1
gregglesI agree, seems like a bug to me. I'll try to fix it soon. Thanks.
Comment #2
gregglesHere's an initial stab at this. The update function doesn't work due to #190027: db_change_field on a serial column in the primary key.
Comment #3
gregglesNow fixed.
I'm not sure what the fix for 5.x is exactly...
Comment #4
gregglesComment #5
gregglesThis module is no longer actively developed for Drupal 5. If someone wishes to take over as the 5.x maintainer I would consider it, but these days everyone should really upgrade to Drupal 6.x.