https://bugzilla.wikimedia.org/show_bug.cgi?id=32661

Edward Akerboom <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |e.akerboom+bugzillamediawik
                   |                            |[email protected]

--- Comment #4 from Edward Akerboom <[email protected]> 
2012-02-07 09:43:53 UTC ---
Hi guys,

At the request of Francis I've looked into this problem, and found an actual
bug and an actual solution.


In extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Number.php, line 67,
change

    static protected function parseNumberValue( $value, &$number, &$unit ) {

to

    static public function parseNumberValue( $value, &$number, &$unit ) {




And then (here's the bug), in
extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_Number.php, from line 55
onwards, change

    /**
     * Create a data item from the provided serialization string and type
     * ID.
     * @note PHP can convert any string to some number, so we do not do
     * validation here (because this would require less efficient parsing).
     * @return SMWDINumber
     */
    public static function doUnserialize( $serialization ) {
        return new SMWDINumber( floatval( $serialization ) );
    }

to

    /**
     * Create a data item from the provided serialization string and type
     * ID.
     * @return SMWDINumber
     */
    public static function doUnserialize( $serialization ) {
        if (SMWNumberValue::parseNumberValue( $serialization, $value, $unit )
== 0) {
            return new SMWDINumber( $value );
        }
        return new SMWDINumber( floatVal( $value ) );
    }

As you can see, the problem here was the indiscriminatory 'floatVal' that was
blindly applied regardless of internationalization settings. I've added 3 lines
of code that prevents that, and... tadaa! The 'Attributen anzeigen' page now
shows the correct number - no longer "3 l/100km" but "3.8 l/100km" (for the
Audi A1 1.6 TDI example). Also note that I removed the snarky & incorrect
comment from the function's heading ("we don't do any validation here because
it's inefficient").

Can you please confirm this problem and this solution? Thanks.

All the best,
Ed

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to