MediaWiki REL1_31
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}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition Setup.php:112
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:1015
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:2001
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37