postgreSQL compatibility
JamieR - September 5, 2006 - 22:41
| Project: | Subscriptions |
| Version: | 4.7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | dziemecki |
| Status: | closed |
Description
This module is not working in a postgreSQL environment yet. Here is the error I get when I post a comment onto a subscribed node:
* warning: Invalid argument supplied for foreach() in /usr/share/drupal/modules/node.module on line 359.
* warning: implode() [function.implode]: Bad arguments. in /usr/share/drupal/modules/node.module on line 363.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at end of input at character 317 in /usr/share/drupal/includes/database.pgsql.inc on line 84.
* user warning: query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, 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 in /usr/share/drupal/includes/database.pgsql.inc on line 103.
* warning: Invalid argument supplied for foreach() in /usr/share/drupal/modules/node.module on line 359.
* warning: implode() [function.implode]: Bad arguments. in /usr/share/drupal/modules/node.module on line 363.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at end of input at character 317 in /usr/share/drupal/includes/database.pgsql.inc on line 84.
* user warning: query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, 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 in /usr/share/drupal/includes/database.pgsql.inc on line 103.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: column "124" does not exist in /usr/share/drupal/includes/database.pgsql.inc on line 84.
* user warning: query: SELECT tid FROM term_node WHERE nid = "124" in /usr/share/drupal/includes/database.pgsql.inc on line 103.
* warning: Invalid argument supplied for foreach() in /usr/share/drupal/modules/node.module on line 359.
* warning: implode() [function.implode]: Bad arguments. in /usr/share/drupal/modules/node.module on line 363.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at end of input at character 317 in /usr/share/drupal/includes/database.pgsql.inc on line 84.
* user warning: query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, 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 in /usr/share/drupal/includes/database.pgsql.inc on line 103.
#1
Are you using the code I checked in last night?
#2
This feels like a kludge.. Why we are alternately receiving objects or arrays (or sometimes just nothing), I do not know.. but this fixes it for the time being, and hopefully exposes the real issue to someone who knows better than I.
Also, note the first change in the diff. Postgres doesn't like double quotes around values.
Thanks,
Damian
--- subscriptions.module.orig 2006-09-06 13:49:06.000000000 -0700
+++ subscriptions.module 2006-09-06 13:50:17.000000000 -0700
@@ -527,7 +527,7 @@
* given a comment, return an array of associated taxonomies
*/
function subscriptions_comment_taxa($comment){
- $result = db_query('SELECT tid FROM {term_node} WHERE nid = "%s"', $comment['nid']);
+ $result = db_query('SELECT tid FROM {term_node} WHERE nid = \'%s\'', $comment['nid']);
return db_fetch_object($result);
}
@@ -537,7 +537,7 @@
function subscriptions_comment($comment, $op) {
global $user;
$strsent = '!';
- $nid = $comment->nid;
+ $nid = (is_array($comment)) ? $comment['nid'] : $comment->nid;
if ($op == 'insert' || ($op == 'update' && $comment->status == 1)) { // ignore deactivated comments
// if use_cron is set, insert node actions into holding table
if(variable_get('subscriptions_usecron', 0)){
#3
Hi, Damian's patch has been working now without problem for a few days. Seems this issue may have been sorted out. I did upgrade to the latest distribution of the module - and the problem persisted. The patch was written for the latest 4.7 release. I hope this helps others - this module is an invaluable part of drupal. Thanks for all your work on it!
Jamie.
FYI, Damian and I work together.
#4
I just ran across the quoting problem that was mentioned above as well. Attached is an alternative patch, reversing the quotes rather than escaping them, which may be a little easier to read.
(Strictly speaking, since the nid should always be an integer, the quotes should be unnecessary in the first place, so that could be another possibility.)
#5
Hi all,
This is a module, but I stumbled on this page through the issue queue. I'm of the mind that the variable be changed to %d and quotes removed. Please adjust this and i'll review the patch. I recommend always using double quotes around queries.
Cheers,
Sammy Spets
Synerger
http://synerger.com
#6
Modified patch attached.
#7
Which version of the module is this patch against? Something like the patch listed at the top was already committed.
#8
It was against the version that was commited on the night of Sept 5th... I'm not at work currently so I can't look at the file. Thanks!
#9
The patch is broken and doesn't apply. Please resubmit the patch with the proper unified patch header.
#10
I ran into this, fixed it in 4.7.0, and fixed it (untested) in cvs.
The 4.7.0 patch based on the 2006-09-09 version is here...
#11
And here is the cvs patch based on the 2006-10-20 cvs version:
#12
Corrected code committed.
#13
Thank you. This latest 4.7.0 works for my postgresql install.
#14