MediaWiki REL1_33
RangeChronologicalPager.php
Go to the documentation of this file.
1<?php
21use Wikimedia\Timestamp\TimestampException;
22
28
30 protected $rangeConds = [];
31
43 public function getDateRangeCond( $startStamp, $endStamp ) {
44 $this->rangeConds = [];
45
46 try {
47 if ( $startStamp !== '' ) {
48 $startTimestamp = MWTimestamp::getInstance( $startStamp );
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 $endOffset = $this->mDb->timestamp( $endTimestamp->getTimestamp() );
56 $this->rangeConds[] = $this->mIndexField . '<=' . $this->mDb->addQuotes( $endOffset );
57
58 // populate existing variables for compatibility with parent
59 $this->mYear = (int)$endTimestamp->format( 'Y' );
60 $this->mMonth = (int)$endTimestamp->format( 'm' );
61 $this->mDay = (int)$endTimestamp->format( 'd' );
62 $this->mOffset = $endOffset;
63 }
64 } catch ( TimestampException $ex ) {
65 return null;
66 }
67
68 return $this->rangeConds;
69 }
70
80 public function getDateCond( $year, $month, $day = -1 ) {
81 // run through getDateRangeCond so rangeConds, mOffset, ... are set
82 $legacyTimestamp = self::getOffsetDate( $year, $month, $day );
83 // ReverseChronologicalPager uses strict inequality for the end date ('<'),
84 // but this class uses '<=' and expects extending classes to handle modifying the end date.
85 // Therefore, we need to subtract one second from the output of getOffsetDate to make it
86 // work with the '<=' inequality used in this class.
87 $legacyTimestamp->timestamp = $legacyTimestamp->timestamp->modify( '-1 second' );
88 $this->getDateRangeCond( '', $legacyTimestamp->getTimestamp( TS_MW ) );
89 return $this->mOffset;
90 }
91
100 protected function buildQueryInfo( $offset, $limit, $order ) {
101 list( $tables, $fields, $conds, $fname, $options, $join_conds ) = parent::buildQueryInfo(
102 $offset,
103 $limit,
104 $order
105 );
106
107 if ( $this->rangeConds ) {
108 $conds = array_merge( $conds, $this->rangeConds );
109 }
110
111 return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
112 }
113}
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:123
mixed $mOffset
The starting point to enumerate entries.
Pager for filtering by a range of dates.
buildQueryInfo( $offset, $limit, $order)
Build variables to use by the database wrapper.
getDateRangeCond( $startStamp, $endStamp)
Set and return a date range condition using timestamps provided by the user.
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
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:1999
this hook is for auditing only 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:996
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