VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: MarioP on January 29, 2014, 16:00:46 PM

Title: Bug: Custom fields ignore numbers with comma
Post by: MarioP on January 29, 2014, 16:00:46 PM
Hi,
As in topic (please see the attachment). When we insert some number with comma, everything that was inserted after comma sign, disappears on the website. What can be wrong?

[attachment cleanup by admin]
Title: Re: Bug: Custom fields ignore numbers with comma
Post by: lindapowers on January 29, 2014, 17:01:55 PM
Doesnt work with . instead of , ?

We never use commas in VM.
Title: Re: Bug: Custom fields ignore numbers with comma
Post by: MarioP on January 29, 2014, 17:33:53 PM
Quote from: lindapowers on January 29, 2014, 17:01:55 PM
We never use commas in VM.
Strange.. There is no problem with numbers separated by comma in VM 2.0.18a ( I have one website with this version) and I'm almost convinced that the problem wasn't appeared in VM.2.0.26a ( I updated the site to 26d so I'm not sure). The dot sign (.) works but I guess that is more clear to write e.g. 'battery operation time (hours)': 3,5-7 than 3.5-7. Or when we have something like speaker size (inch) - it's widely accepted to write 1,75" not 1.75".  Now I don't know myself  what is better :) Maybe you have a point but as I've mentioned, I haven't encountered that problem in the previous VM versions, so I thought this is a bug...
Title: Re: Bug: Custom fields ignore numbers with comma
Post by: MarioP on January 29, 2014, 19:21:58 PM
By the way I'm testing VM 2.1 now and the problem with commas doesn't occur...
Title: Re: Bug: Custom fields ignore numbers with comma
Post by: Milbo on January 29, 2014, 19:58:37 PM
The reason is that joomla guys meant to overload the robust function JText with a extra test if it should do a vsprintf,...
read here http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=32612&start=0

The reason it works with vm2.1 again is our vmText, the robust and fast replacement for JText. It works also correctly in vm2.0.26D, you just need to replace the JText with one of an older joomla version.
Title: Re: Bug: Custom fields ignore numbers with comma
Post by: MarioP on January 30, 2014, 09:04:35 AM
Please someone to confirm or correct me if I'm doing wrong (I'm not a programmer I don't know exactly what was the purpose of this change by Joomla team). So what I need to do is to remove the code specified in the diff file below or simply replace the /libraries/joomla/methods.php wtih this from elder version e.g. from J!2.5.11?
diff --git a/libraries/joomla/methods.php b/libraries/joomla/methods.php
index ff5bc2f..7ad9bb8 100644
--- a/libraries/joomla/methods.php
+++ b/libraries/joomla/methods.php
@@ -151,25 +151,5 @@
}
}
- if (!(strpos($string, ',') === false))
- {
- $test = substr($string, strpos($string, ','));
- if (strtoupper($test) === $test)
- {
- $strs = explode(',', $string);
- foreach ($strs as $i => $str)
- {
- $strs[$i] = $lang->_($str, $jsSafe, $interpretBackSlashes);
- if ($script)
- {
- self::$strings[$str] = $strs[$i];
- }
- }
- $str = array_shift($strs);
- $str = preg_replace('/\[\[%([0-9]+):[^\]]*\]\]/', '%\1$s', $str);
- $str = vsprintf($str, $strs);

- return $str;
- }
- }
if ($script)
{
@@ -339,5 +319,5 @@
$args[0] = $lang->_($string);
}
- $args[0] = preg_replace('/\[\[%([0-9]+):[^\]]*\]\]/', '%\1$s', $args[0]);
+
return call_user_func_array('sprintf', $args);
}
Title: Re: Bug: Custom fields ignore numbers with comma
Post by: Milbo on January 31, 2014, 03:34:20 AM
too lazy to check this. you can just replace the whole file. Or take a look on the vm2.1, which is using vmText everywhere,.. you can also now already use vmText instead of JText. Just replace it in the customfield model.

I will release a 2.0.27 maybe tomorrow. It has 3-4 mini fixes and I replaced already the JText against vmText