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.

CommentFileSizeAuthor
#2 409850_prevent_uid_0_saving.patch2.9 KBgreggles
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggles’s picture

I agree, seems like a bug to me. I'll try to fix it soon. Thanks.

greggles’s picture

Status: Active » Needs work
FileSize
2.9 KB

Here'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.

greggles’s picture

Version: 6.x-1.2 » 5.x-2.x-dev
Status: Needs work » Postponed

Now fixed.

I'm not sure what the fix for 5.x is exactly...

greggles’s picture

Status: Postponed » Patch (to be ported)
greggles’s picture

Status: Patch (to be ported) » Closed (fixed)

This 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.