Using Php4.0.3 on Debian Woody and Postgresql 7.2.1 (default encoding is UNICODE). Also using Drupal 4.1. RC1.

After posting a comment to a story with the following in the Comment field:
'Dette er "Release Candidate 1", s

Comments

dries’s picture

This is a known problem when using Drupal 4.0.0 with PostgreSQL; see here. It should have been fixed in Drupal 4.1.0, so would you mind to investigate this a bit further? Make sure you are using the proper database scheme and if it still fails, play with the watchdog() function in includes/common.inc ...

teamonkey’s picture

This is in fact a bug within (or related to) the locales module. Not sure why it happens though, and I don't have a testbed to play with at the moment. I don't use locales module myself, but I'll try and see if I can work out what's going on by looking at the code.

[teamonkey]

hbell’s picture

Thanks to both of you for the replies.

I am not sure if this will help, but after a little investigation I found the following (Drupal 4.1 RC1):

In _db_query() (line 51 in includes/database.pear.inc), line 58, $result = $db_handle->query($query); seems to fail with the following query:


[SELECT COUNT(cid) FROM comments WHERE pid = '0' AND nid = '2' AND subject = 'Bugs' AND comment = 'Dette er "Release Candidate 1", s

dries’s picture

Let me know if there is anything else I can do to help resolve this.

Well, could you try to figure out why the watchdog's SQL query fails? Is the watchdog's query malformed as well?

What PHP settings do you use? In particular, are magic_quotes_gpc and magic_quotes_runtime disabled?

hbell’s picture

Some more information:


magic_quotes_gpc and magic_quotes_runtime are both disabled, as per the .htaccess file that comes with the Drupal tar ball.


Since I could not get the query strings to show up correctly with all its escaped and non escaped quotes here in this forum (naturally), I will give the url to a text file containing the raw SQL statement I refer to, so anyone interested can take a look.

The query that failes in _db_query() is as follows:


http://lerad.net/bell/drupal/_db_query_fails.txt

This query works fine when envoked directly in psql, but strangely causes DB::isError($result) to be true in _db_query() so that the watchdog() function is invoked.

The query created in the watchdog function is:


http://lerad.net/bell/drupal/watchdog_query_fails.txt

In this case it seems that the single quotes are messing up the query, and this also fails in psql, as expected. So, the watchdog is repeatedly called in an infinite loop. However, adding addslashes(stripslashes($message)) to make sure that the string meant for the message column is in a proper format should work in theory, but the DB::isError($result) is again true, and the watchdog function is again invoked in an infinite loop. The following is the properly escaped complete query then used in the watchdog function:

http://lerad.net/bell/drupal/watchdog_query_escaped_fails.txt

This also works fine directly in psql. I don't understand why DB::isError($result) is true, when the raw SQL works fine in psql. A problem in PEAR?

~ Hav.