I wonder if you could help me.

I have downloaded recently the http://ftp.drupal.org/files/projects/comment_notify-5.x-1.3.tar.gz and tried to install on my drupal (5.0).

I use Postgresql-8.1 on Debian Etch.

I have followed the INSTALL.TXT then I enabled the modul.

First the database update was not successful

"query: ALTER TABLE comments ADD COLUMN `notify` tinyint(1) NOT NULL DEFAULT '1'"

but I managed to alter the comment table with the command:

ALTER TABLE comments ADD column notify smallint NOT NULL DEFAULT '1';

After that all seemed all well but...

I tested it, after I send a comment the Drupal page wrote:

"Invalid argument supplied for foreach() - /srv/www/linuxbox.hu/www.linuxbox.hu/modules/node/node.module - 504. sor.

implode() [function.implode]: Bad arguments. - /srv/www/linuxbox.hu/www.linuxbox.hu/modules/node/node.module - 508. sor.
pg_query() [function.pg-query]: Query failed: ERROR: syntax error at end of input at character 305 - /srv/www/linuxbox.hu/www.linuxbox.hu/includes/database.pgsql.inc - 125. sor.

query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE - /srv/www/linuxbox.hu/www.linuxbox.hu/includes/database.pgsql.inc - 144. sor.

pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "mail" at character 101 - /srv/www/linuxbox.hu/www.linuxbox.hu/includes/database.pgsql.inc - 125. sor.

query: SELECT DISTINCT c.cid,u.init,c.uid,c.name,c.nid ,IF(length(c.mail)<1, ifnull(u.mail,u.init),c.mail) mail,c.uid,c.name,max(cid) cid,md5( concat( c.mail,ifnull(u.mail,u.init),c.uid,c.name,c.nid ) ) mymd5 FROM comments c LEFT OUTER JOIN users u ON u.uid=c.uid WHERE nid=0 AND notify=1 AND c.status=0 AND LENGTH(IF(LENGTH(c.mail)<1, ifnull(u.mail,u.init),c.mail))>1 AND IF(LENGTH(c.mail)<1, ifnull(u.mail,u.init),c.mail) like '%@%.%' GROUP BY IF(LENGTH(c.mail)<1, ifnull(u.mail,u.init),c.mail),c.name - /srv/www/linuxbox.hu/www.linuxbox.hu/includes/database.pgsql.inc - 144. sor."

But there is no "ifnull", "contact" function defined in my database system...

Anyway, great module. I'm looking forward to see a fix for this issue...

Comments

michal.cihar’s picture

The first errors are probably not at all related to PostgreSQL as the erros seems to be pretty same as with MySQL - see http://drupal.org/node/191313

szimszon’s picture

No, after the patch I had the same error :(

greggles’s picture

I marked http://drupal.org/node/206748 as a duplicate of this. It has ideas on how to fix it for Postgresql. szimszon - can you try it out? Thanks.

David Goodwin’s picture

PostgreSQL problems are related to use the of ifnull() which PostgreSQL doesn't support. It does have a 'coalesce' function instead, which appears to do the same 'sort of thing'.

David Goodwin’s picture

The closest I seem to be able to get the SQL is something like :

$result = db_query("SELECT c.cid,u.init,c.uid,c.name,c.nid,c.notify,c.status,
CAST(if(length(c.mail)<1, coalesce(u.mail,u.init),c.mail) AS text) as mymail,
c.uid,c.name AS cid, md5(c.mail || CAST(coalesce(u.mail, u.init) AS TEXT) || c.uid || c.name || c.nid ) as mymd5
FROM comments c
LEFT OUTER JOIN users u on u.uid=c.uid
WHERE nid = %d AND c.notify = 1 AND c.status = 0", $nid);

But that still doesn't work....

Note the requirement to cast strings.

I used || instead of concat - I believe the result is the same, but || is cross db, while concat isn't. Annoyingly PgSQL doesn't seem too keen on allowing me to add a "AND mymail like '%@%.%'" on the end and comes back with an 'unknown column' sort of error.

(that's for around line 368 on comment_notify.module).

Perhaps I should find the CVS repos for this module.

greggles’s picture

Thanks for your help.

From the project homepage you can see the link to Browse the CVS repository.

David Goodwin’s picture

StatusFileSize
new5.41 KB

Hi,
See attached; this _appears_ to make it work with PgSQL etc.

1) I fixed the PGSQL query, in a sort of way. I don't think it does the same as the MySQL query, but PgSQL is a bit more strict / fussy so I couldn't do some things :-/

2) the drupal_mail() call seemed to be broken; in that I wasn't receiving mail from it. This was fixed by adding a $header['To'] = blah@blah... I'm wondering if some other MTAs patched this behaviour up silently, and my MTA (Postfix) doesn't?

3) It won't send an email to the same email address twice... as this seems pointless/annoying.

4) The original code checked to make sure both commenters names were different before sending an email. I don't think this is that good a check, and instead I've changed it to do a simple comparison on both email addresses.

Bugs remaining:

1) If a signed in member of a site posts a comment, no emails are sent as notification(s) to $users. This is because the publish hook(s) (or whatever) aren't being fired. This is annoying - as I don't have moderation turned on for registered users.

Some of the lines changes are purely whitespace changes.... blame me/vim; sorry.

Created with :

diff -uw comment_notify.module comment_notify.module.new

greggles’s picture

This is great!

...but it would be much easier to review and commit this if it were provided as separate patches. I know that makes it harder for you, but as it is this whole patch is unlikely to get in. There are separate issues for some of these (mail not getting sent is one for sure).

David Goodwin’s picture

StatusFileSize
new451 bytes

fix for mail ....

David Goodwin’s picture

StatusFileSize
new639 bytes

patch to stop duplicate emails - incase someone has commented twice in a thread.

David Goodwin’s picture

StatusFileSize
new2.84 KB

patch to fix postgresql issues - queries should now work....

David Goodwin’s picture

(Sorry I'm too lazy to post them as seperate issues/tickets/whatever)

greggles’s picture

Status: Active » Closed (duplicate)

The postgresql piece has been split out to http://drupal.org/node/211684 right?

greggles’s picture

In case anyone else is interested, please note that I'm working on this in #232564: refactor data structure so core tables are not altered and move towards PostgreSQL compliance and would love to have some reviewers help test it.

Thanks.