Closed (won't fix)
Project:
Drupal core
Version:
5.15
Component:
search.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 Mar 2009 at 11:35 UTC
Updated:
3 Mar 2009 at 08:21 UTC
I've got SQL-errors with queries located in 'search/search.modules' using full-text search mode in german.
The problem is the german formated float number, e.g. '3,1415', in SQL statements.
SQL syntax requires the english representation, e.g. '3.1415'
I suppose, somewhere in drupal, you call 'setlocales(L_ALL,'de...').
'LC_NUMERIC' affects the deciamal point representation and is set to ','
by locales 'de_..'
So please check the following code:
---- in include/database.inc, _db_query_callback():
case '%f':
return (float) array_shift($args);
---- in modules/search/search.module
$total = log10(1 + 1/(max(1, $total)));
db_query("UPDATE {search_total} SET count = %f WHERE word = '%s'", $total, $word);
!!! there are some more lines affected in this module
Code snipplet for testing
<?php
$pi=3.1456;
$pi2=($pi*2);
echo "pi2 is $pi2<br>";
setlocale(LC_ALL,'de_DE.utf8');
echo "pi2 on de_DE is $pi2<br>";
echo 'db_query("SELECT pi_float * ' . $pi . ' FROM {table} WHERE pi_float * ' . $pi2 . ' > 234.567"';
/*
pi2 is 6.2912
pi2 on de_DE is 6,2912
// -> WRONG sql syntax, causes error
db_query("SELECT pi_float * 3,1456 FROM {table} WHERE pi_float * 6,2912 > 234.567"
*/
Bugfix in include/database.inc, _db_query_callback()
e.g. use the string represation of a float und replace ',' with '.'
case '%f':
//return (float) array_shift($args);
return str_replace( ',' , '.', array_shift($args));
Comments
Comment #1
damien tournoud commentedPlease search for "setlocales" in your Drupal installation. There is probably a module misbehaving somewhere (this is not a core issue).
Comment #2
jenger1965 commentedThanks Damien,
you're right there is no "setlocale" call in my D5 core and module installation.
I made a gallery2 integration using the bridge module "modules/gallery2.module".
I found G2 to be responsable for changes of locale to 'de_DE'.
So it makes sence to save the old locale state in the "modules/gallery2.module" init function,
or force setting LC_NUMERIC back to "C" -> setlocale(LC_NUMERIC,"C").
I bring this issue to the "modules/gallery2.module" owner...
Regards Jens