strider72 / spam-karma

A flexible and modular anti-spam plugin for WordPress
GNU General Public License v2.0
3 stars 3 forks source link

Conversion from float to string is dependent on locale #27

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
String cast gives floats like "1,12" with the german locale and MySQL doesn't 
like that.

Possible Patch:

--- sk2/sk2_core_class.php      2009-05-14 12:40:20.000000000 +0200
+++ spam-karma2/sk2_core_class.php      2011-12-14 11:25:57.000000000 +0100
@@ -663,8 +663,10 @@
                                continue;
                        if (is_array($val))
                                $val = serialize($val);
-                       if (is_int($val) || is_float($val))
+                       if (is_int($val))
                                $query .= "`$key` = " . $val . ",";
+                       elseif (is_float($val))
+                               $query .= "`$key` = " . sprintf("%F", $val) . 
",";
                        else
                                $query .= "`$key` = '" . sk2_escape_string($val) . "', ";

Original issue reported on code.google.com by philipp....@gmail.com on 14 Dec 2011 at 10:34

GoogleCodeExporter commented 9 years ago
Attaching patch per Philipp's suggestion.

Original comment by stephen....@gmail.com on 4 Mar 2012 at 5:08

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by stephen....@gmail.com on 4 Mar 2012 at 5:09

strider72 commented 9 years ago

Marked "Help Wanted". Would be great if a German speaker could test this patch.

strider72 commented 9 years ago

New branch to test this: See "stutz-patch" branch