Needs review
Project:
Watcher
Version:
6.x-1.3
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Apr 2010 at 16:31 UTC
Updated:
4 Feb 2012 at 00:18 UTC
Hi,
Open watcher.db.inc, go to line 197.
The code is:
$sql = "INSERT INTO {watcher_nodes} (uid, nid, added) VALUES(%d, %d, %d)";
$res = db_query($sql, $user->uid, $nid, time());
This causes a big error in pgsql, i don't know about mysql. The mail column in the table has primary key constraint which means that it cannot have null values, and the very same thing prouces error in pgsql, hence the row doesn't get inserted.
The possible fix for this is:
$sql = "INSERT INTO {watcher_nodes} (uid, nid, mail, added) VALUES(%d, %d, '%s', %d)";
$res = db_query($sql, $user->uid, $nid, $user->mail, time());
Comments
Comment #1
nileshgr commentedWell, before changing this, I want to ask the developer a question that - does the module find mail ids if a registered user is subscribed ?
In that case, we will have to change the database structure.
Comment #2
d.novikov commented'mail' field in watcher.install is specified as a part of a primary key. MySQL prohibits setting a column of a primary key to NULL. See for example http://dev.mysql.com/doc/refman/5.1/en/create-table.html:
As there is 'mail' field specified with NULL default value, we should change the DB structure. I suggest to use the default value '' instead of NULL. Changes are commited to the dev branch.
Any feedback will be greatly appreciated!