Last modified: 2013-06-11 12:28:27 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T51397, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 49397 - Template call property assignment of a decimal without a digit before decimal misinterprets value
Template call property assignment of a decimal without a digit before decimal...
Status: UNCONFIRMED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
master
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-10 18:26 UTC by jayhuggins
Modified: 2013-06-11 12:28 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
SMW_DV_Number.php with corrected regex in parseNumberValue (11.39 KB, text/x-wiki)
2013-06-10 18:26 UTC, jayhuggins
Details

Description jayhuggins 2013-06-10 18:26:13 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.
Comment 1 MWJames 2013-06-10 19:01:33 UTC
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.
Comment 2 Nischay Nahata 2013-06-11 12:28:27 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links