Warning pg_query

wa2nlinux - January 4, 2009 - 04:00
Project:Blog Theme
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

I installed drupal, for Multiple user, but warning error is show up :

* warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid input syntax for integer: "" in /home/xxx/drupal-6.8/includes/database.pgsql.inc on line 139.
* user warning: query: SELECT n.nid, n.type, n.language, n.uid, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, n.tnid, n.translate, r.vid, r.uid AS revision_uid, r.title, r.body, r.teaser, r.log, r.timestamp AS revision_timestamp, r.format, 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 n.nid = '' in /home/xxx/drupal-6.8/modules/node/node.module on line 749.

#1

wa2nlinux - January 5, 2009 - 02:56
Project:Drupal» Block Theme
Version:6.8» 6.x-1.0-beta1
Component:base system» Code

#2

wa2nlinux - January 5, 2009 - 02:56

error show up when I install blogtheme

#3

wa2nlinux - January 5, 2009 - 13:39
Project:Block Theme» Blog Theme
Version:6.x-1.0-beta1» 6.x-1.4

#4

beginner - January 5, 2009 - 14:09

I'll try to have a look at this issue soon. Do you have a suggested fix?

#5

wa2nlinux - January 5, 2009 - 16:36
Status:active» postponed (maintainer needs more info)

Yes .. I did not know about drupal code ( newbie in here :D )
but I know little bit know about php and postgreSQL.
I hacked node.module ( I dunno this is wise option or not :D ), now the error warning is gone.

I add simple code to replace null value with 0.

I suggest this because I used PostgreSQL not Mysql and they have different way to look at null value.

#6

beginner - January 6, 2009 - 06:26

blogtheme does not have a single SQL query, so this module cannot be responsible.
Hacking Drupal core is never a wise thing to do ;) Be careful!

Could you investigate the issue further and reassign this issue to the proper module?

#7

wa2nlinux - January 6, 2009 - 13:04

Ok, ... I'll try to learn on it :D ..

Found it !! on case "node"
the if $nid value is_null then Prostgres don't like it, because it ilegal !!, nid is INT NOT NULL, so I add checking not null value for $nid if yes give it 0 instead not hull.

Here portion of blog_theme.module, I add smal code on below $nid = arg(1)
case 'node':

    $nid = arg(1);
//check if $nid is_null, give it 0 instead null
        if ( !isset ($nid)) $nid=0;

#8

wa2nlinux - January 6, 2009 - 13:05
Status:postponed (maintainer needs more info)» needs work

#9

beginner - January 6, 2009 - 13:30

Thanks for investigating the problem and finding the cause. It's very helpful.

Node $nid = 0 does not exist. If $nid is NULL then there is no reason to proceed. Try the attached patch, instead.
See this: http://drupal.org/patch

Since you say you are a newbie with Drupal, here are a couple of advice which will help you to communicate better with module maintainers:

1) On an issue, edit your own comment only to fix typos. Add additional information in a new comment. The practical reason for this is that we are subscribed to the issue and receive email notifications. In this case, the email I received when you posted #7, only had the text Ok, ... I'll try to learn on it :D ... If you hadn't posted #8, I wouldn't have come back online and wouldn't have seen the additional very useful and relevant information.

2) In your original report, there is one key information missing: how to reproduce the bug. It is always VERY helpful to have a step by step instructions to reproduce the bug. It helps to find which part of the code is involved.

The attached patch should solve the issue. Thanks for the feedback.

AttachmentSize
pgsql-warning-at-node.patch 737 bytes

#10

wa2nlinux - January 6, 2009 - 16:52
Status:needs work» closed

OK thanks for advices :D

At first post I dunno what causing error I enabled many modules, after that I try to check it one by one. So I post the #2.

Thanks

#11

beginner - January 6, 2009 - 17:30
Status:closed» needs work

Don't close yet. I haven't committed the fix.

#12

wa2nlinux - January 7, 2009 - 00:48

Something wrong ?

blog@wwwserv2:~/web$ patch -p0 < pgsql-warning-at-node.patch
can't find file to patch at input line 8
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: blog_theme.module
|===================================================================
|RCS file: /cvs/drupal-contrib/contributions/modules/blogtheme/blog_theme.module,v
|retrieving revision 1.20.2.8
|diff -u -p -r1.20.2.8 blog_theme.module
|--- blog_theme.module 30 Sep 2008 08:58:26 -0000 1.20.2.8
|+++ blog_theme.module 6 Jan 2009 13:20:14 -0000
--------------------------
File to patch:

#13

wa2nlinux - January 7, 2009 - 00:52

Ok done, The patch must on module directory, cannot do on drupal root directory, the problem was fix using your patch :D. Here the web, http://blog.akprind.ac.id,

#14

beginner - January 7, 2009 - 10:58
Version:6.x-1.4» 6.x-1.x-dev
Status:needs work» reviewed & tested by the community

Thanks for the feedback.
Usually Drupal core patches are applied from the Drupal root directory, but contrib module patches are applied from within their own directory.

I have committed the fix in HEAD and D6. D5 didn't need this.

I'll set this issue as fixed when I have made a new release: #355440: Make new D5 and D6 releases.

 
 

Drupal is a registered trademark of Dries Buytaert.