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
// 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
$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;
}
}