* @file
*/
+use Wikimedia\Timestamp\TimestampException;
+
class ImageHistoryPseudoPager extends ReverseChronologicalPager {
protected $preventClickjacking = false;
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
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