Last modified: 2013-06-11 12:28:27 UTC
Created attachment 12507 [details] SMW_DV_Number.php with corrected regex in parseNumberValue A template call with a decimal property assignment whose value is between 0 and 1 without a leading 0 strips the decimal point and incorrectly parses the result as though it were an integer value. For example, an assignment like this: |Myproperty=.1200 is parsed and stored in the database as Myproperty = 1200 instead of Myproperty = 0.12. The bug is in the regex in extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Number.php in the parseNumberValue function. The fixed version is attached.
Thanks for your report. Generally it would be better to provide a Gerrit patch as it will accelerate the review process and help to resolve the issue as quick as possible. PS: The attached file (SMW_DV_Number) was not based on the current master making it difficult for a reviewer to come to an assertion but a quick diff analysis showed that the only thing that changed was: - $parts = preg_split( '/([-+]?\s*\d+(?:\\' . $kiloseparator . '\d\d\d)*' . + $parts = preg_split( '/([-+]?\s*(?:\d+(?:\\' . $kiloseparator . '\d{3})*)?' . PSS: Changes like this need to be verified using a unit test (small changes like this are critical as they can have a lasting impact on the data conversion) in order to ensure that for a range of conditions results are as expected. I don't have time to write a unit test for this to verify its validity and I assume Jeroen will be busy meaning it can take some time before this change will be merged unless a unit test is provided. Again, thanks for your effort.
http://www.mediawiki.org/wiki/Gerrit/Tutorial Step by step tutorial to learn contribute using Gerrit. http://www.mediawiki.org/wiki/Gerrit/Getting_started Quicker version of the same.