X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fpage%2FImageHistoryPseudoPager.php;h=20bc614b51d19f16d9fe7a60f8a636d9001d56fb;hb=fa0f6f34972c0e0f4aac24a03b3efdfc45f256f6;hp=4785ef1ad4196bd5cb21222cf663c6b64df80536;hpb=935f7e48d29e92efdd1078e1ad9804c071a50687;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/ImageHistoryPseudoPager.php b/includes/page/ImageHistoryPseudoPager.php index 4785ef1ad4..17a6d51a0b 100644 --- a/includes/page/ImageHistoryPseudoPager.php +++ b/includes/page/ImageHistoryPseudoPager.php @@ -18,6 +18,8 @@ * @file */ +use Wikimedia\Timestamp\TimestampException; + class ImageHistoryPseudoPager extends ReverseChronologicalPager { protected $preventClickjacking = false; @@ -55,8 +57,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager { public function __construct( $imagePage ) { parent::__construct( $imagePage->getContext() ); $this->mImagePage = $imagePage; - $this->mTitle = clone $imagePage->getTitle(); - $this->mTitle->setFragment( '#filehistory' ); + $this->mTitle = $imagePage->getTitle()->createFragmentTarget( 'filehistory' ); $this->mImg = null; $this->mHist = []; $this->mRange = [ 0, 0 ]; // display range @@ -76,7 +77,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager { } public function getQueryInfo() { - return false; + return []; } /** @@ -139,6 +140,14 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager { if ( !$this->mImg->exists() ) { return; } + // Make sure the date (probably from user input) is valid; if not, drop it. + if ( $this->mOffset !== null ) { + try { + $sadlyWeCannotPassThisTimestampDownTheStack = $this->mDb->timestamp( $this->mOffset ); + } catch ( TimestampException $e ) { + $this->mOffset = null; + } + } $queryLimit = $this->mLimit + 1; // limit plus extra row if ( $this->mIsBackwards ) { // Fetch the file history