Commit 572de058 authored by greggles's avatar greggles

bug #409850 by greggles: Anonymous subscription affects comment_notify_user_settings table

parent 5edec7c6
......@@ -41,7 +41,8 @@ function comment_notify_schema() {
'description' => t('Stores information about which commenters on the site have subscriped to followup emails.'),
'fields' => array(
'cid' => array(
'type' => 'serial',
'type' => 'int',
'unsigned' => TRUE,
'description' => 'The comment id from {comments}.cid',
'not null' => TRUE,
'disp-width' => '11'),
......@@ -72,7 +73,7 @@ function comment_notify_schema() {
$schema['comment_notify_user_settings'] = array(
'fields' => array(
'uid' => array(
'type' => 'serial',
'type' => 'int',
'unsigned' => TRUE,
'description' => 'The user id from {users}.cid',
'not null' => TRUE,
......@@ -274,5 +275,28 @@ function comment_notify_update_6004() {
// Set the value in the notified column to 1 for all existing records.
$ret[] = update_sql('UPDATE {comment_notify} SET notified = 1');
return $ret;
}
/**
* Having our foreign keys auto_increment could lead to unexpected results.
*/
function comment_notify_update_6005() {
$ret = array();
db_change_field($ret, 'comment_notify', 'cid', 'cid',
array('type' => 'int',
'unsigned' => TRUE,
'description' => 'The comment id from {comments}.cid',
'not null' => TRUE,
'disp-width' => '11'));
db_change_field($ret, 'comment_notify_user_settings', 'uid', 'uid',
array('type' => 'int',
'unsigned' => TRUE,
'description' => 'The user id from {users}.cid',
'not null' => TRUE,
'disp-width' => '11'));
return $ret;
}
\ No newline at end of file
......@@ -260,7 +260,7 @@ function comment_notify_comment($comment, $op) {
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) {
if ($current == 0 && $user->uid) {
db_query("INSERT INTO {comment_notify_user_settings} (uid, comment_notify) VALUES (%d, %d)", $user->uid, $comment['notify_type']);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment