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

       Web browser: ---
            Bug ID: 47259
           Summary: Three-digit years parsed as Unix timestamps
           Product: MediaWiki extensions
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: Semantic MediaWiki
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]
    Classification: Unclassified
   Mobile Platform: ---

When I set a property of type Date to a 3-digit year (or any other number that
doesn't have 4 digits), it is parsed not as a year, but as a time offset from 1
Jan 1970:

"910" becomes "1 January 1970 00:15:10"
"1910" becomes "1910"
"11910" becomes "1 January 1970 03:18:30"

Problems:

- Nothing in the documentation suggests this behavior.  There's no description
of simple numbers being interpreted as Unix timestamps.  It seems at odds with
the goal to "allow year numbers in the order of 10^9" (from Help:Type_Date).

- I tried "910 AD" as a workaround, and this sets the property value correctly,
but it is displayed without the "AD" -- "910 AD" becomes "910" (in contrast,
"910 BC" becomes "910 BC").  This is a problem because I sometimes want set
other properties based on a query of existing values.  Taking a date,
displaying it, and the re-parsing it should not change the meaning of the date.

- This seems to be a regression.  I haven't tested it, but I found the
offending code, and it doesn't exist in an older version I have lying around
(1.5).  The implication is that the interpretation of valid (and reasonable)
dates on an existing wiki will change with an SMW upgrade.

My configuration:
Semantic MediaWiki 1.8.0.4
MediaWiki 1.20.3
PHP 5.3.15
MySQL 5.5.28

Here's the code that causes the problem (in SMW_DV_Time.php):

protected function parseUserValue( $value ) {
    ...
    // Check if it's parseable by wfTimestamp when it's not a year (which is
wrongly interpreted).
    if ( strlen( $value ) != 4 && wfTimestamp( TS_MW, $value ) !== false ) {
        $this->m_dataitem = SMWDITime::newFromTimestamp( $value );
    }
    elseif ( ...

-- 
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