From: Kunal Mehta Date: Thu, 27 Oct 2016 19:06:30 +0000 (-0700) Subject: Don't fatal on invalid timestamps X-Git-Tag: 1.31.0-rc.0~4965^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=153d117b60f48218f8a90b0220061f330e4f45c3 Don't fatal on invalid timestamps Database::timestamp() intentionally lets errors bubble up, so catch invalid user-provided timestamps in ReverseChronologicalPage::getDateCond(), and avoid using an offset in that case. Bug: T149257 Change-Id: Ida85eb44b66e8a0166e7f68a101ff094e04b1c8e --- diff --git a/includes/pager/ReverseChronologicalPager.php b/includes/pager/ReverseChronologicalPager.php index 4895b4ff2d..6f325c967c 100644 --- a/includes/pager/ReverseChronologicalPager.php +++ b/includes/pager/ReverseChronologicalPager.php @@ -80,7 +80,7 @@ abstract class ReverseChronologicalPager extends IndexPager { // If year and month are false, don't update the mOffset if ( !$this->mYear && !$this->mMonth ) { - return; + return null; } // Given an optional year, month, and day, we need to generate a timestamp @@ -150,7 +150,13 @@ abstract class ReverseChronologicalPager extends IndexPager { $timestamp = MWTimestamp::getInstance( "${ymd}000000" ); $timestamp->setTimezone( $this->getConfig()->get( 'Localtimezone' ) ); - $this->mOffset = $this->mDb->timestamp( $timestamp->getTimestamp() ); + try { + $this->mOffset = $this->mDb->timestamp( $timestamp->getTimestamp() ); + } catch ( TimestampException $e ) { + // Invalid user provided timestamp (T149257) + return null; + } + return $this->mOffset; } }