Last modified: 2013-09-18 17:02:01 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 T49259, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 47259 - Three-digit years parsed as Unix timestamps
Three-digit years parsed as Unix timestamps
Status: REOPENED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
: 54151 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-04-15 20:47 UTC by Dan Smith
Modified: 2013-09-18 17:02 UTC (History)
5 users (show)

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


Attachments

Description Dan Smith 2013-04-15 20:47:20 UTC
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 ( ...
Comment 1 contrafibularity 2013-09-18 15:50:07 UTC

*** This bug has been marked as a duplicate of bug 54151 ***
Comment 2 contrafibularity 2013-09-18 17:02:01 UTC
*** Bug 54151 has been marked as a duplicate of this bug. ***

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


Navigation
Links