Last modified: 2007-05-29 20:08:22 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 9503 - Providing an invalid date leads to wrong outputs in ask queries.
Providing an invalid date leads to wrong outputs in ask queries.
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
PC Windows XP
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
  Show dependency treegraph
Reported: 2007-04-05 11:30 UTC by Markus Nitsche
Modified: 2007-05-29 20:08 UTC (History)
1 user (show)

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


Description Markus Nitsche 2007-04-05 11:30:13 UTC
If you annotate an attribute with Type:Date and provide an invalid date (month
>12) it is misinterpreted within ask queries.

Reproduce with following steps:
1) Create an attribute with Type:date and use it in some article
2) Use an invalid date with month > 12 (for example: born in:=1970-15-04)
3) Create an ask-query which is asking for the attribute

The result table will show a wrong date and a time (for example: 1970-04-06

Expected result:
Show an empty filed or an error message "invalid date".
The first solution seems to be the more consistent one because if you provide a
correct month but an invalid day (for example 2007-04-35) SMW seems to recognise
this and the field in the result table is empty.

# MediaWiki: 1.8.2
# PHP: 5.1.6
# MySQL: 4.1.21-community-nt
# Extensions:
   o Cite, adds <ref[ name=id]> and <references/> tags, for citations, by Ævar
Arnfjörð Bjarmason
   o ParserFunctions by Tim Starling
   o Semantic MediaWiki (version 0.5)
Comment 1 S Page 2007-05-28 09:21:43 UTC
What is displayed in the factbox of the page with the two dates?

Hmm, I tried this at and both bad months and bad days result in "[Oops! The date “1970-15-04” was not understood." errors in the factbox and no value is stored in the database.  That's the expected behavior.

However, and my local site are both running PHP 5.2.
I suspect strtotime() in PHP 5.1.6 handles dates differently.  PHP is strongly motivated to do all kinds of odd unexpected date arithmetic.

Can you save the following 6 lines somewhere on your site as strtotime.php, load it in a browser, and give me the results?

  echo "Good date: strtotime('1970-11-04') gives " . strtotime('1970-11-04') . '<br />';
  echo "Bad month: strtotime('1970-15-04') gives " . strtotime('1970-15-04') . '<br />';
  echo "Bad day: strtotime('2007-04-35') gives " . strtotime('2007-04-35') . '<br />';

They return
Good date: strtotime('1970-11-04') gives 26553600
Bad month: strtotime('1970-15-04') gives
Bad day: strtotime('2007-04-35') gives 
[and then phpinfo]

on my site, i.e. the bad dates fail.
Comment 2 S Page 2007-05-29 20:08:22 UTC
Mr. Nitsche confirmed this is an issue with PHP version 5.1.2.

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