MediaWiki REL1_30
RangeChronologicalPager.php
Go to the documentation of this file.
1<?php
21use Wikimedia\Timestamp\TimestampException;
22
28
29 protected $rangeConds = [];
30
42 public function getDateRangeCond( $startStamp, $endStamp ) {
43 $this->rangeConds = [];
44
45 try {
46 if ( $startStamp !== '' ) {
47 $startTimestamp = MWTimestamp::getInstance( $startStamp );
48 $startTimestamp->setTimezone( $this->getConfig()->get( 'Localtimezone' ) );
49 $startOffset = $this->mDb->timestamp( $startTimestamp->getTimestamp() );
50 $this->rangeConds[] = $this->mIndexField . '>=' . $this->mDb->addQuotes( $startOffset );
51 }
52
53 if ( $endStamp !== '' ) {
54 $endTimestamp = MWTimestamp::getInstance( $endStamp );
55 $endTimestamp->setTimezone( $this->getConfig()->get( 'Localtimezone' ) );
56 $endOffset = $this->mDb->timestamp( $endTimestamp->getTimestamp() );
57 $this->rangeConds[] = $this->mIndexField . '<=' . $this->mDb->addQuotes( $endOffset );
58
59 // populate existing variables for compatibility with parent
60 $this->mYear = (int)$endTimestamp->format( 'Y' );
61 $this->mMonth = (int)$endTimestamp->format( 'm' );
62 $this->mDay = (int)$endTimestamp->format( 'd' );
63 $this->mOffset = $endOffset;
64 }
65 } catch ( TimestampException $ex ) {
66 return null;
67 }
68
69 return $this->rangeConds;
70 }
71
81 public function getDateCond( $year, $month, $day = -1 ) {
82 // run through getDateRangeCond so rangeConds, mOffset, ... are set
83 $legacyTimestamp = self::getOffsetDate( $year, $month, $day );
84 // ReverseChronologicalPager uses strict inequality for the end date ('<'),
85 // but this class uses '<=' and expects extending classes to handle modifying the end date.
86 // Therefore, we need to subtract one second from the output of getOffsetDate to make it
87 // work with the '<=' inequality used in this class.
88 $legacyTimestamp->timestamp = $legacyTimestamp->timestamp->modify( '-1 second' );
89 $this->getDateRangeCond( '', $legacyTimestamp->getTimestamp( TS_MW ) );
90 return $this->mOffset;
91 }
92
101 protected function buildQueryInfo( $offset, $limit, $descending ) {
102 list( $tables, $fields, $conds, $fname, $options, $join_conds ) = parent::buildQueryInfo(
103 $offset,
104 $limit,
105 $descending
106 );
107
108 if ( $this->rangeConds ) {
109 $conds = array_merge( $conds, $this->rangeConds );
110 }
111
112 return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
113 }
114}
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition Setup.php:36
getConfig()
Get the Config object.
static getInstance( $ts=false)
Get a timestamp instance in GMT.
Pager for filtering by a range of dates.
getDateRangeCond( $startStamp, $endStamp)
Set and return a date range condition using timestamps provided by the user.
buildQueryInfo( $offset, $limit, $descending)
Build variables to use by the database wrapper.
getDateCond( $year, $month, $day=-1)
Takes ReverseChronologicalPager::getDateCond parameters and repurposes them to work with timestamp-ba...
Efficient paging for SQL queries.
static getOffsetDate( $year, $month, $day=-1)
Core logic of determining the mOffset timestamp such that we can get all items with a timestamp up to...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition hooks.txt:1013
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:1971