Last modified: 2007-05-29 20:08:22 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 T11503, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 9503 - Providing an invalid date leads to wrong outputs in ask queries.
Providing an invalid date leads to wrong outputs in ask queries.
Status: RESOLVED WORKSFORME
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
PC Windows XP
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  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: ---


Attachments

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

Result:
The result table will show a wrong date and a time (for example: 1970-04-06
13:07:00)

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.

Platform:
# 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 http://ontoworld.org/wiki/SMW_unit_test:Test_dates#Invalid_dates 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, ontoworld.org 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?

<?php
  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 />';
  phpinfo();
?>

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.


Navigation
Links