Page MenuHomePhabricator

Exception: DateTime::__construct(): Failed to parse time string*: Double time specification
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Exception: DateTime::__construct(): Failed to parse time string *: Double time specification
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.15/includes/specials/pagers/ContribsPager.php(859)
#0 /srv/mediawiki/php-1.37.0-wmf.15/includes/specials/pagers/ContribsPager.php(859): DateTime->__construct(string)
#1 /srv/mediawiki/php-1.37.0-wmf.15/includes/specials/SpecialContributions.php(229): ContribsPager::processDateFilter(array)
#2 /srv/mediawiki/php-1.37.0-wmf.15/includes/specialpage/SpecialPage.php(646): SpecialContributions->execute(NULL)
#3 /srv/mediawiki/php-1.37.0-wmf.15/includes/specialpage/SpecialPageFactory.php(1363): SpecialPage->run(NULL)
#4 /srv/mediawiki/php-1.37.0-wmf.15/includes/MediaWiki.php(314): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#5 /srv/mediawiki/php-1.37.0-wmf.15/includes/MediaWiki.php(925): MediaWiki->performRequest()
#6 /srv/mediawiki/php-1.37.0-wmf.15/includes/MediaWiki.php(559): MediaWiki->main()
#7 /srv/mediawiki/php-1.37.0-wmf.15/index.php(53): MediaWiki->run()
#8 /srv/mediawiki/php-1.37.0-wmf.15/index.php(46): wfIndexMain()
#9 /srv/mediawiki/w/index.php(3): require(string)
#10 {main}
Impact
  • Throwing an exception on user input
Notes

Details

Request URL
https://en.wikipedia.org/w/index.php?title=*&limit=*&contribs=*&target=*&namespace=*&year=*&month=*
Related Changes in Gerrit:

Event Timeline

Similar to T149257, but it seems the value is redacted here. I can use letters for the query parameter and it does not give fatal.

DateTime is getting a TS_ISO_8601 timestamp. There must be a way to create invalid iso timestamps with the user input. It is possible to get some more information about the values for year/month?

this is still happening - reproducible - see url string in request id below

stack trace:

Error
normalized_message
[{reqId}] {exception_url}   Exception: DateTime::__construct(): Failed to parse time string (230132-03-30T14:40:00Z) at position 12 (T): Double time specification
exception.trace
from /srv/mediawiki/php-1.38.0-wmf.12/includes/pager/ReverseChronologicalPager.php(99)
#0 /srv/mediawiki/php-1.38.0-wmf.12/includes/pager/ReverseChronologicalPager.php(99): DateTime->__construct(string)
#1 /srv/mediawiki/php-1.38.0-wmf.12/includes/actions/pagers/HistoryPager.php(105): ReverseChronologicalPager->getDateCond(integer, integer, integer)
#2 /srv/mediawiki/php-1.38.0-wmf.12/includes/actions/HistoryAction.php(316): HistoryPager->__construct(HistoryAction, string, string, string, array, string, MediaWiki\Cache\LinkBatchFactory, MediaWiki\Watchlist\WatchlistManager, MediaWiki\CommentFormatter\CommentFormatter)
#3 /srv/mediawiki/php-1.38.0-wmf.12/includes/actions/FormlessAction.php(48): HistoryAction->onView()
#4 /srv/mediawiki/php-1.38.0-wmf.12/includes/MediaWiki.php(543): FormlessAction->show()
#5 /srv/mediawiki/php-1.38.0-wmf.12/includes/MediaWiki.php(320): MediaWiki->performAction(Article, Title)
#6 /srv/mediawiki/php-1.38.0-wmf.12/includes/MediaWiki.php(903): MediaWiki->performRequest()
#7 /srv/mediawiki/php-1.38.0-wmf.12/includes/MediaWiki.php(563): MediaWiki->main()
#8 /srv/mediawiki/php-1.38.0-wmf.12/index.php(53): MediaWiki->run()
#9 /srv/mediawiki/php-1.38.0-wmf.12/index.php(46): wfIndexMain()
#10 /srv/mediawiki/w/index.php(3): require(string)
#11 {main}
normalized_message
[{reqId}] {exception_url}   Exception: DateTime::__construct(): Failed to parse time string (230132-03-30T14:40:00Z) at position 12 (T): Double time specification

The value is strange, but when converting it back to unix it is 7200105000000 or better 0720-01-05 00:00:00. Using the year/month/date for year/month or date-range-to parameter gives the exception.

Reason:
For the following code

MWTimestamp::getInstance( "${ymd}000000" )

the timestamp only has a length of 13 and that is interpreted as unix timestamp, because only length 14 is valid TS_MW.

The used sprintf gives a string with leading zero (for the 14 length), but there is a int cast - which was done in f6a93e08b81d00720b95b218b09e864e9d1ac0dd

There is much string -> int -> string happens, which gives the invalid time here.

Change 747938 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/core@master] Improve 2YK38 check for 3-number years

https://gerrit.wikimedia.org/r/747938

Umherirrender triaged this task as Low priority.

Change 747938 merged by jenkins-bot:

[mediawiki/core@master] pager: Improve Y2K38 check to keep leading zero in 3-digit years

https://gerrit.wikimedia.org/r/747938