X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fpager%2FReverseChronologicalPager.php;h=6f325c967c34cd644d87941bf324787b32192b9c;hb=ce079cf6ad79ca8d3360817f809b219d166f9153;hp=af6d0394d75de623a0e04c92b4e3d076ae703f04;hpb=597a2063db031b95658abd3e12a2a13bce678f55;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/pager/ReverseChronologicalPager.php b/includes/pager/ReverseChronologicalPager.php index af6d0394d7..6f325c967c 100644 --- a/includes/pager/ReverseChronologicalPager.php +++ b/includes/pager/ReverseChronologicalPager.php @@ -64,12 +64,12 @@ abstract class ReverseChronologicalPager extends IndexPager { /** * Set and return the mOffset timestamp such that we can get all revisions with * a timestamp up to the specified parameters. - * @param int $year [optional] Year up to which we want revisions. Default is current year. - * @param int $month [optional] Month up to which we want revisions. Default is end of year. + * @param int $year Year up to which we want revisions + * @param int $month Month up to which we want revisions * @param int $day [optional] Day up to which we want revisions. Default is end of month. - * @return string Timestamp + * @return string|null Timestamp or null if year and month are false/invalid */ - function getDateCond( $year = -1, $month = -1, $day = -1 ) { + function getDateCond( $year, $month, $day = -1 ) { $year = intval( $year ); $month = intval( $month ); $day = intval( $day ); @@ -78,6 +78,11 @@ abstract class ReverseChronologicalPager extends IndexPager { $this->mYear = $year > 0 ? $year : false; $this->mMonth = ( $month > 0 && $month < 13 ) ? $month : false; + // If year and month are false, don't update the mOffset + if ( !$this->mYear && !$this->mMonth ) { + return null; + } + // Given an optional year, month, and day, we need to generate a timestamp // to use as "WHERE rev_timestamp <= result" // Examples: year = 2006 equals < 20070101 (+000000) @@ -145,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; } }