MediaWiki master
MediaWiki\Pager\IndexPager Class Reference

Efficient paging for SQL queries that use a (roughly unique) index. More...

Inherits MediaWiki\Context\ContextSource, and MediaWiki\Pager\Pager.

Inherited by MediaWiki\Pager\AlphabeticPager, MediaWiki\Pager\ReverseChronologicalPager, and MediaWiki\Pager\TablePager.

Collaboration diagram for MediaWiki\Pager\IndexPager:

Public Member Functions

 __construct (IContextSource $context=null, LinkRenderer $linkRenderer=null)
 
 doQuery ()
 Do the query, using information from the object context.
 
 formatRow ( $row)
 Returns an HTML string representing the result row $row.
 
 getBody ()
 Get the formatted result list.
 
 getDatabase ()
 Get the Database object in use.
 
 getDefaultQuery ()
 Get an array of query parameters that should be put into self-links.
 
 getIndexField ()
 Returns the name of the index field.
 
 getLimit ()
 Get the current limit.
 
 getModuleStyles ()
 ResourceLoader modules that must be loaded to provide correct styling for this pager.
 
 getNavigationBuilder ()
 
 getNumRows ()
 Get the number of rows in the result set.
 
 getOffsetQuery ()
 Get the current offset for the URL query parameter.
 
 getPagingQueries ()
 Get a URL query array for the prev, next, first and last links.
 
 getQueryInfo ()
 Provides all parameters needed for the main paged query.
 
 getResult ()
 
 getResultOffset ()
 
 reallyDoQuery ( $offset, $limit, $order)
 Do a query with specified parameters, rather than using the object context.
 
 setIncludeOffset ( $include)
 Set whether a row matching exactly the offset should be also included in the result or not.
 
 setLimit ( $limit)
 Set the limit from an other source than the request.
 
 setOffset ( $offset)
 Set the offset from an other source than the request.
 
- Public Member Functions inherited from MediaWiki\Context\ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage().
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID.
 
 getActionName ()
 Get the action name for the current web request.
 
 getAuthority ()
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object.
 
 getCsrfTokenSet ()
 Get a repository to obtain and match CSRF tokens.
 
 getLanguage ()
 
 getLanguageCode ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object.
 
 msg ( $key,... $params)
 Get a Message object with context set Parameters are the same as wfMessage()
 
 setContext (IContextSource $context)
 
- Public Member Functions inherited from MediaWiki\Pager\Pager
 getNavigationBar ()
 

Public Attributes

IReadableDatabase $mDb
 
bool $mDefaultDirection
 $mDefaultDirection gives the direction to use when sorting results: DIR_ASCENDING or DIR_DESCENDING.
 
int $mDefaultLimit = 50
 The default entry limit choosen for clients.
 
bool $mIsBackwards
 
bool $mIsFirst
 True if the current result set is the first one.
 
bool $mIsLast
 
int $mLimit
 The maximum number of entries to show.
 
int[] $mLimitsShown = [ 20, 50, 100, 250, 500 ]
 List of default entry limit options to be presented to clients.
 
mixed $mOffset
 The starting point to enumerate entries.
 
stdClass bool null $mPastTheEndRow
 Extra row fetched at the end to see if the end was reached.
 
bool $mQueryDone = false
 Whether the listing query completed.
 
WebRequest $mRequest
 
IResultWrapper $mResult
 Result object for the query.
 
const DIR_ASCENDING = false
 Backwards-compatible constant for $mDefaultDirection field (do not change)
 
const DIR_DESCENDING = true
 Backwards-compatible constant for $mDefaultDirection field (do not change)
 
const QUERY_ASCENDING = true
 Backwards-compatible constant for reallyDoQuery() (do not change)
 
const QUERY_DESCENDING = false
 Backwards-compatible constant for reallyDoQuery() (do not change)
 

Protected Member Functions

 buildQueryInfo ( $offset, $limit, $order)
 Build variables to use by the database wrapper.
 
 doBatchLookups ()
 Called from getBody(), before getStartBody() is called and after doQuery() was called.
 
 extractResultInfo ( $isFirst, $limit, IResultWrapper $res)
 Extract some useful data from the result object for use by the navigation bar, put it into $this.
 
 getDefaultDirections ()
 Return the default sorting direction: DIR_ASCENDING or DIR_DESCENDING.
 
 getEmptyBody ()
 Hook into getBody(), for the bit between the start and the end when there are no rows.
 
 getEndBody ()
 Hook into getBody() for the end of the list.
 
 getExtraSortFields ()
 Returns the names of secondary columns to order by in addition to the column in getIndexField().
 
 getFooter ()
 Classes can extend to output a footer at the bottom of the pager list.
 
 getLinkRenderer ()
 
 getRow ( $row)
 Get the HTML of a pager row.
 
 getSqlComment ()
 Get some text to go in brackets in the "function name" part of the SQL comment.
 
 getStartBody ()
 Hook into getBody(), allows text to be inserted at the start.
 
 isNavigationBarShown ()
 Returns whether to show the "navigation bar".
 
 makeLink ( $text, array $query=null, $type=null)
 Make a self-link.
 
 preprocessResults ( $result)
 Pre-process results; useful for performing batch existence checks, etc.
 

Static Protected Member Functions

static oppositeOrder ( $order)
 

Protected Attributes

array $mDefaultQuery
 
string[] $mExtraSortFields
 An array of secondary columns to order by.
 
array $mFirstShown
 
bool $mIncludeOffset = false
 Whether to include the offset in the query.
 
string string[] $mIndexField
 The index to actually be used for ordering.
 
array $mLastShown
 
string $mNavigationBar
 
string null $mOrderType
 For pages that support multiple types of ordering, which one to use.
 
array $mPastTheEndIndex
 

Detailed Description

Efficient paging for SQL queries that use a (roughly unique) index.

This is for paging through data sets stored in tables with a unique index, instead of a naive "LIMIT offset,limit" clause.

In MySQL, such a limit/offset clause requires counting through the specified number of offset rows to find the desired data, which can be expensive for large offsets.

ReverseChronologicalPager is a child class of the abstract IndexPager, and contains some formatting and display code which is specific to the use of timestamps as indexes. Here is a synopsis of its operation:

  • The query is specified by the offset, limit and direction (dir) parameters, in addition to any subclass-specific parameters.
  • The offset is the non-inclusive start of the DB query. A row with an index value equal to the offset will never be shown.
  • The query may either be done backwards, where the rows are returned by the database in the opposite order to which they are displayed to the user, or forwards. This is specified by the "dir" parameter, dir=prev means backwards, anything else means forwards. The offset value specifies the start of the database result set, which may be either the start or end of the displayed data set. This allows "previous" links to be implemented without knowledge of the index value at the start of the previous page.
  • An additional row beyond the user-specified limit is always requested. This allows us to tell whether we should display a "next" link in the case of forwards mode, or a "previous" link in the case of backwards mode. Determining whether to display the other link (the one for the page before the start of the database result set) can be done heuristically by examining the offset.
  • An empty offset indicates that the offset condition should be omitted from the query. This naturally produces either the first page or the last page depending on the dir parameter.

Subclassing the pager to implement concrete functionality should be fairly simple, please see the examples in HistoryAction.php and SpecialBlockList.php. You just need to override formatRow(), getQueryInfo() and getIndexField(). Don't forget to call the parent constructor if you override it.

Stability: stable
to extend

Definition at line 81 of file IndexPager.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ buildQueryInfo()

MediaWiki\Pager\IndexPager::buildQueryInfo ( $offset,
$limit,
$order )
protected

Build variables to use by the database wrapper.

Note
For b/c, query direction is true for ascending and false for descending
Stability: stable
to override
Parameters
int | string | null$offsetIndex offset, inclusive
int$limitExact query limit
bool$orderIndexPager::QUERY_ASCENDING or IndexPager::QUERY_DESCENDING
Returns
array

Reimplemented in MediaWiki\Pager\RangeChronologicalPager, MediaWiki\Pager\ReverseChronologicalPager, and MediaWiki\Pager\ActiveUsersPager.

Definition at line 489 of file IndexPager.php.

References MediaWiki\Pager\IndexPager\getQueryInfo(), and MediaWiki\Pager\IndexPager\getSqlComment().

Referenced by MediaWiki\Pager\IndexPager\reallyDoQuery(), and MediaWiki\Pager\ImageListPager\reallyDoQuery().

◆ doBatchLookups()

MediaWiki\Pager\IndexPager::doBatchLookups ( )
protected

Called from getBody(), before getStartBody() is called and after doQuery() was called.

This will be called only if there are rows in the result set.

Stability: stable
to override
Returns
void

Reimplemented in MediaWiki\Pager\HistoryPager, MediaWiki\Pager\LogPager, MediaWiki\Pager\ContributionsPager, MediaWiki\Pager\ActiveUsersPager, MediaWiki\Pager\ImageListPager, MediaWiki\Pager\MergeHistoryPager, MediaWiki\Pager\NewFilesPager, MediaWiki\Pager\NewPagesPager, MediaWiki\Pager\ProtectedTitlesPager, and MediaWiki\Pager\UsersPager.

Definition at line 680 of file IndexPager.php.

◆ doQuery()

MediaWiki\Pager\IndexPager::doQuery ( )

Do the query, using information from the object context.

This function has been kept minimal to make it overridable if necessary, to allow for result sets formed from multiple DB queries.

Stability: stable
to override

Reimplemented in ImageHistoryPseudoPager.

Definition at line 267 of file IndexPager.php.

References MediaWiki\Pager\IndexPager\$mIncludeOffset, MediaWiki\Pager\IndexPager\DIR_ASCENDING, MediaWiki\Pager\IndexPager\extractResultInfo(), MediaWiki\Pager\IndexPager\oppositeOrder(), MediaWiki\Pager\IndexPager\preprocessResults(), MediaWiki\Pager\IndexPager\QUERY_DESCENDING, and MediaWiki\Pager\IndexPager\reallyDoQuery().

◆ extractResultInfo()

MediaWiki\Pager\IndexPager::extractResultInfo ( $isFirst,
$limit,
IResultWrapper $res )
protected

Extract some useful data from the result object for use by the navigation bar, put it into $this.

Stability: stable
to override
Parameters
bool$isFirstFalse if there are rows before those fetched (i.e. if a "previous" link would make sense)
int$limitExact query limit
IResultWrapper$res

Definition at line 385 of file IndexPager.php.

References Wikimedia\Rdbms\IResultWrapper\fetchObject(), Wikimedia\Rdbms\IResultWrapper\fetchRow(), Wikimedia\Rdbms\IResultWrapper\numRows(), and Wikimedia\Rdbms\IResultWrapper\seek().

Referenced by MediaWiki\Pager\IndexPager\doQuery().

◆ formatRow()

MediaWiki\Pager\IndexPager::formatRow ( $row)
abstract

◆ getBody()

MediaWiki\Pager\IndexPager::getBody ( )

Get the formatted result list.

Calls getStartBody(), formatRow() and getEndBody(), concatenates the results and returns them.

Stability: stable
to override
Returns
string

Implements MediaWiki\Pager\Pager.

Reimplemented in ImageHistoryPseudoPager, and MediaWiki\Pager\CategoryPager.

Definition at line 575 of file IndexPager.php.

◆ getDatabase()

◆ getDefaultDirections()

MediaWiki\Pager\IndexPager::getDefaultDirections ( )
protected

Return the default sorting direction: DIR_ASCENDING or DIR_DESCENDING.

You can also have an associative array of ordertype => dir, if multiple order types are supported. In this case getIndexField() must return an array, and the keys of that must exactly match the keys of this.

For backward compatibility, this method's return value will be ignored if $this->mDefaultDirection is already set when the constructor is called, for instance if it's statically initialized. In that case the value of that variable (which must be a boolean) will be used.

Note that despite its name, this does not return the value of the $this->mDefaultDirection member variable. That's the default for this particular instantiation, which is a single value. This is the set of all defaults for the class.

Stability: stable
to override
Returns
bool

Definition at line 960 of file IndexPager.php.

Referenced by MediaWiki\Pager\IndexPager\__construct().

◆ getDefaultQuery()

MediaWiki\Pager\IndexPager::getDefaultQuery ( )

Get an array of query parameters that should be put into self-links.

By default, all parameters passed in the URL are used, apart from a few exceptions.

Stability: stable
to override
Returns
array Associative array

Reimplemented in MediaWiki\Pager\LogPager, MediaWiki\Pager\ContributionsPager, MediaWiki\Pager\CategoryPager, MediaWiki\Pager\ImageListPager, and MediaWiki\Pager\UsersPager.

Definition at line 725 of file IndexPager.php.

◆ getEmptyBody()

MediaWiki\Pager\IndexPager::getEmptyBody ( )
protected

Hook into getBody(), for the bit between the start and the end when there are no rows.

Stability: stable
to override
Returns
string

Reimplemented in MediaWiki\Pager\HistoryPager, and MediaWiki\Pager\TablePager.

Definition at line 712 of file IndexPager.php.

◆ getEndBody()

MediaWiki\Pager\IndexPager::getEndBody ( )
protected

◆ getExtraSortFields()

MediaWiki\Pager\IndexPager::getExtraSortFields ( )
protected

Returns the names of secondary columns to order by in addition to the column in getIndexField().

These fields will not be used in the pager offset or in any links for users.

If getIndexField() returns an array of 'querykey' => 'indexfield' pairs then this must return a corresponding array of 'querykey' => [ fields... ] pairs in order for a request with &order=querykey to use [ fields... ] to sort.

If getIndexField() returns a string with the field to sort by, this must either: 1 - return an associative array like above, but only the elements for the current field will be used. 2 - return a non-associative array, for secondary keys to use always.

This is useful for pagers that GROUP BY a unique column (say page_id) and ORDER BY another (say page_len). Using GROUP BY and ORDER BY both on page_len,page_id avoids temp tables (given a page_len index). This would also work if page_id was non-unique but we had a page_len,page_id index.

Stability: stable
to override
Returns
string[]|array[]

Reimplemented in MediaWiki\Pager\ContribsPager, and MediaWiki\Pager\DeletedContribsPager.

Definition at line 935 of file IndexPager.php.

Referenced by MediaWiki\Pager\IndexPager\__construct().

◆ getFooter()

MediaWiki\Pager\IndexPager::getFooter ( )
protected

Classes can extend to output a footer at the bottom of the pager list.

Since
1.38
Returns
string

Reimplemented in MediaWiki\Pager\ReverseChronologicalPager.

Definition at line 629 of file IndexPager.php.

◆ getIndexField()

MediaWiki\Pager\IndexPager::getIndexField ( )
abstract

Returns the name of the index field.

If the pager supports multiple orders, it may return an array of 'querykey' => 'indexfield' pairs, so that a request with &order=querykey will use indexfield to sort. In this case, the first returned key is the default.

Needless to say, it's really not a good idea to use a non-unique index for this! That won't page right.

The pager may paginate on multiple fields in combination. If paginating on multiple fields, they should be unique in combination (e.g. when paginating on user and timestamp, rows may have the same user, rows may have the same timestamp, but rows should all have a different combination of user and timestamp).

Examples:

  • Always paginate on the user field: 'user'
  • Paginate on either the user or the timestamp field (default to user): [ 'name' => 'user', 'time' => 'timestamp', ]
  • Always paginate on the combination of user and timestamp: [ [ 'user', 'timestamp' ] ]
  • Paginate on the user then timestamp, or the timestamp then user: [ 'nametime' => [ 'user', 'timestamp' ], 'timename' => [ 'timestamp', 'user' ], ]
Returns
string|string[]|array[]

Reimplemented in MediaWiki\Pager\HistoryPager, MediaWiki\Pager\LogPager, ImageHistoryPseudoPager, MediaWiki\Pager\TablePager, MediaWiki\Pager\ActiveUsersPager, MediaWiki\Pager\BlockListPager, MediaWiki\Pager\CategoryPager, MediaWiki\Pager\ContribsPager, MediaWiki\Pager\DeletedContribsPager, MediaWiki\Pager\ImageListPager, MediaWiki\Pager\MergeHistoryPager, MediaWiki\Pager\NewFilesPager, MediaWiki\Pager\NewPagesPager, MediaWiki\Pager\ProtectedPagesPager, MediaWiki\Pager\ProtectedTitlesPager, MediaWiki\Pager\UploadStashPager, and MediaWiki\Pager\UsersPager.

Referenced by MediaWiki\Pager\IndexPager\__construct(), and MediaWiki\Pager\ContributionsPager\reallyDoQuery().

◆ getLimit()

MediaWiki\Pager\IndexPager::getLimit ( )

Get the current limit.

Returns
int

Definition at line 359 of file IndexPager.php.

References MediaWiki\Pager\IndexPager\$mLimit.

◆ getLinkRenderer()

◆ getModuleStyles()

MediaWiki\Pager\IndexPager::getModuleStyles ( )

ResourceLoader modules that must be loaded to provide correct styling for this pager.

Stability: stable
to override
Since
1.38
Returns
string[]

Reimplemented in MediaWiki\Pager\TablePager.

Definition at line 619 of file IndexPager.php.

◆ getNavigationBuilder()

MediaWiki\Pager\IndexPager::getNavigationBuilder ( )
Stability: stable
to override
Since
1.39
Returns
PagerNavigationBuilder

Definition at line 813 of file IndexPager.php.

Referenced by MediaWiki\Pager\AlphabeticPager\getNavigationBar().

◆ getNumRows()

◆ getOffsetQuery()

MediaWiki\Pager\IndexPager::getOffsetQuery ( )

Get the current offset for the URL query parameter.

Stability: stable
to override
Since
1.39
Returns
string

Definition at line 800 of file IndexPager.php.

◆ getPagingQueries()

MediaWiki\Pager\IndexPager::getPagingQueries ( )

Get a URL query array for the prev, next, first and last links.

Stability: stable
to override
Returns
array

Reimplemented in MediaWiki\Pager\ImageListPager.

Definition at line 758 of file IndexPager.php.

Referenced by MediaWiki\Pager\TablePager\getNavigationBar().

◆ getQueryInfo()

MediaWiki\Pager\IndexPager::getQueryInfo ( )
abstract

Provides all parameters needed for the main paged query.

It returns an associative array with the following elements: tables => Table(s) for passing to Database::select() fields => Field(s) for passing to Database::select(), may be * conds => WHERE conditions options => option array join_conds => JOIN conditions

Returns
array

Reimplemented in MediaWiki\Pager\HistoryPager, MediaWiki\Pager\LogPager, ImageHistoryPseudoPager, MediaWiki\Pager\ContributionsPager, MediaWiki\Pager\AllMessagesTablePager, MediaWiki\Pager\BlockListPager, MediaWiki\Pager\CategoryPager, MediaWiki\Pager\ImageListPager, MediaWiki\Pager\MergeHistoryPager, MediaWiki\Pager\NewFilesPager, MediaWiki\Pager\NewPagesPager, MediaWiki\Pager\ProtectedPagesPager, MediaWiki\Pager\ProtectedTitlesPager, MediaWiki\Pager\UploadStashPager, and MediaWiki\Pager\UsersPager.

Referenced by MediaWiki\Pager\IndexPager\buildQueryInfo().

◆ getResult()

MediaWiki\Pager\IndexPager::getResult ( )
Returns
IResultWrapper The result wrapper.

Definition at line 314 of file IndexPager.php.

References MediaWiki\Pager\IndexPager\$mResult.

◆ getResultOffset()

MediaWiki\Pager\IndexPager::getResultOffset ( )
Returns
int The current offset into the result. Valid during formatRow().

Definition at line 321 of file IndexPager.php.

Referenced by MediaWiki\Pager\HistoryPager\formatRow(), and MediaWiki\Pager\BlockListPager\formatValue().

◆ getRow()

MediaWiki\Pager\IndexPager::getRow ( $row)
protected

Get the HTML of a pager row.

Stability: stable
to override
Since
1.38
Parameters
stdClass$row
Returns
string

Reimplemented in MediaWiki\Pager\ReverseChronologicalPager.

Definition at line 563 of file IndexPager.php.

◆ getSqlComment()

MediaWiki\Pager\IndexPager::getSqlComment ( )
protected

Get some text to go in brackets in the "function name" part of the SQL comment.

Stability: stable
to override
Returns
string

Reimplemented in MediaWiki\Pager\HistoryPager, and MediaWiki\Pager\ContributionsPager.

Definition at line 447 of file IndexPager.php.

Referenced by MediaWiki\Pager\IndexPager\buildQueryInfo(), MediaWiki\Pager\ActiveUsersPager\buildQueryInfo(), and MediaWiki\Pager\ActiveUsersPager\getQueryInfo().

◆ getStartBody()

MediaWiki\Pager\IndexPager::getStartBody ( )
protected

Hook into getBody(), allows text to be inserted at the start.

This will be called even if there are no rows in the result set.

Returns
string

Reimplemented in MediaWiki\Pager\HistoryPager, MediaWiki\Pager\ContributionsPager, MediaWiki\Pager\TablePager, MediaWiki\Pager\AllMessagesTablePager, MediaWiki\Pager\MergeHistoryPager, MediaWiki\Pager\NewFilesPager, and MediaWiki\Pager\NewPagesPager.

Definition at line 689 of file IndexPager.php.

◆ isNavigationBarShown()

MediaWiki\Pager\IndexPager::isNavigationBarShown ( )
protected

Returns whether to show the "navigation bar".

Stability: stable
to override
Returns
bool

Reimplemented in MediaWiki\Pager\HistoryPager.

Definition at line 844 of file IndexPager.php.

Referenced by MediaWiki\Pager\AlphabeticPager\getNavigationBar(), and MediaWiki\Pager\TablePager\getNavigationBar().

◆ makeLink()

MediaWiki\Pager\IndexPager::makeLink ( $text,
array $query = null,
$type = null )
protected

Make a self-link.

Stability: stable
to call (since 1.39)
Parameters
string$textText displayed on the link
array | null$queryAssociative array of parameter to be in the query string. If null, no link is generated.
string | null$typeLink type used to create additional attributes, like "rel", "class" or "title". Valid values (non-exhaustive list): 'first', 'last', 'prev', 'next', 'asc', 'desc'.
Returns
string HTML fragment

Definition at line 645 of file IndexPager.php.

References getTitle().

Referenced by MediaWiki\Pager\TablePager\getStartBody().

◆ oppositeOrder()

static MediaWiki\Pager\IndexPager::oppositeOrder ( $order)
staticfinalprotected
Parameters
bool$orderOne of the IndexPager::QUERY_* class constants
Returns
bool The opposite query order as an IndexPager::QUERY_ constant

Definition at line 305 of file IndexPager.php.

References MediaWiki\Pager\IndexPager\QUERY_ASCENDING, and MediaWiki\Pager\IndexPager\QUERY_DESCENDING.

Referenced by MediaWiki\Pager\IndexPager\doQuery().

◆ preprocessResults()

MediaWiki\Pager\IndexPager::preprocessResults ( $result)
protected

Pre-process results; useful for performing batch existence checks, etc.

Stability: stable
to override
Parameters
IResultWrapper$result

Reimplemented in MediaWiki\Pager\BlockListPager, and MediaWiki\Pager\ProtectedPagesPager.

Definition at line 552 of file IndexPager.php.

Referenced by MediaWiki\Pager\IndexPager\doQuery().

◆ reallyDoQuery()

MediaWiki\Pager\IndexPager::reallyDoQuery ( $offset,
$limit,
$order )

Do a query with specified parameters, rather than using the object context.

Note
For b/c, query direction is true for ascending and false for descending
Stability: stable
to override
Parameters
string$offsetIndex offset, inclusive
int$limitExact query limit
bool$orderIndexPager::QUERY_ASCENDING or IndexPager::QUERY_DESCENDING
Returns
IResultWrapper

Reimplemented in MediaWiki\Pager\ContributionsPager, MediaWiki\Pager\AllMessagesTablePager, and MediaWiki\Pager\ImageListPager.

Definition at line 463 of file IndexPager.php.

References MediaWiki\Pager\IndexPager\buildQueryInfo().

Referenced by MediaWiki\Pager\IndexPager\doQuery().

◆ setIncludeOffset()

MediaWiki\Pager\IndexPager::setIncludeOffset ( $include)

Set whether a row matching exactly the offset should be also included in the result or not.

By default this is not the case, but when the offset is user-supplied this might be wanted.

Parameters
bool$include

Definition at line 370 of file IndexPager.php.

Referenced by MediaWiki\Pager\CategoryPager\__construct().

◆ setLimit()

MediaWiki\Pager\IndexPager::setLimit ( $limit)

Set the limit from an other source than the request.

Verifies limit is between 1 and 5000

Stability: stable
to override
Parameters
int | string$limit

Definition at line 343 of file IndexPager.php.

Referenced by MediaWiki\Pager\NewFilesPager\__construct().

◆ setOffset()

MediaWiki\Pager\IndexPager::setOffset ( $offset)

Set the offset from an other source than the request.

Parameters
int | string$offset

Definition at line 330 of file IndexPager.php.

Referenced by MediaWiki\Pager\CategoryPager\__construct().

Member Data Documentation

◆ $mDb

IReadableDatabase MediaWiki\Pager\IndexPager::$mDb

Definition at line 106 of file IndexPager.php.

Referenced by MediaWiki\Pager\IndexPager\getDatabase().

◆ $mDefaultDirection

bool MediaWiki\Pager\IndexPager::$mDefaultDirection

$mDefaultDirection gives the direction to use when sorting results: DIR_ASCENDING or DIR_DESCENDING.

If $mIsBackwards is set, we start from the opposite end, but we still sort the page itself according to $mDefaultDirection. For example, if $mDefaultDirection is DIR_ASCENDING but we're going backwards, we'll display the last page of results, but the last result will be at the bottom, not the top.

Like $mIndexField, $mDefaultDirection will be a single value even if the class supports multiple default directions for different order types.

Definition at line 139 of file IndexPager.php.

Referenced by MediaWiki\Pager\UsersPager\getPageHeader().

◆ $mDefaultLimit

int MediaWiki\Pager\IndexPager::$mDefaultLimit = 50

The default entry limit choosen for clients.

Definition at line 98 of file IndexPager.php.

◆ $mDefaultQuery

array MediaWiki\Pager\IndexPager::$mDefaultQuery
protected

Definition at line 155 of file IndexPager.php.

Referenced by MediaWiki\Pager\CategoryPager\getDefaultQuery().

◆ $mExtraSortFields

string [] MediaWiki\Pager\IndexPager::$mExtraSortFields
protected

An array of secondary columns to order by.

These fields are not part of the offset. This is a column list for one ordering, even if multiple orderings are supported.

Definition at line 122 of file IndexPager.php.

◆ $mFirstShown

array MediaWiki\Pager\IndexPager::$mFirstShown
protected

Definition at line 151 of file IndexPager.php.

◆ $mIncludeOffset

bool MediaWiki\Pager\IndexPager::$mIncludeOffset = false
protected

Whether to include the offset in the query.

Definition at line 163 of file IndexPager.php.

Referenced by MediaWiki\Pager\IndexPager\doQuery().

◆ $mIndexField

string string [] MediaWiki\Pager\IndexPager::$mIndexField
protected

The index to actually be used for ordering.

This can be a single column, an array of single columns, or an array of arrays of columns. See getIndexField for more details.

Definition at line 116 of file IndexPager.php.

Referenced by MediaWiki\Pager\ImageListPager\reallyDoQuery().

◆ $mIsBackwards

bool MediaWiki\Pager\IndexPager::$mIsBackwards

Definition at line 141 of file IndexPager.php.

◆ $mIsFirst

bool MediaWiki\Pager\IndexPager::$mIsFirst

True if the current result set is the first one.

Definition at line 144 of file IndexPager.php.

◆ $mIsLast

bool MediaWiki\Pager\IndexPager::$mIsLast

Definition at line 146 of file IndexPager.php.

◆ $mLastShown

array MediaWiki\Pager\IndexPager::$mLastShown
protected

Definition at line 149 of file IndexPager.php.

◆ $mLimit

◆ $mLimitsShown

int [] MediaWiki\Pager\IndexPager::$mLimitsShown = [ 20, 50, 100, 250, 500 ]

List of default entry limit options to be presented to clients.

Definition at line 96 of file IndexPager.php.

◆ $mNavigationBar

string MediaWiki\Pager\IndexPager::$mNavigationBar
protected

Definition at line 157 of file IndexPager.php.

Referenced by MediaWiki\Pager\AlphabeticPager\getNavigationBar().

◆ $mOffset

mixed MediaWiki\Pager\IndexPager::$mOffset

The starting point to enumerate entries.

Definition at line 100 of file IndexPager.php.

◆ $mOrderType

string null MediaWiki\Pager\IndexPager::$mOrderType
protected

For pages that support multiple types of ordering, which one to use.

Definition at line 126 of file IndexPager.php.

Referenced by MediaWiki\Pager\IndexPager\__construct().

◆ $mPastTheEndIndex

array MediaWiki\Pager\IndexPager::$mPastTheEndIndex
protected

Definition at line 153 of file IndexPager.php.

◆ $mPastTheEndRow

stdClass bool null MediaWiki\Pager\IndexPager::$mPastTheEndRow

Extra row fetched at the end to see if the end was reached.

Definition at line 108 of file IndexPager.php.

◆ $mQueryDone

bool MediaWiki\Pager\IndexPager::$mQueryDone = false

Whether the listing query completed.

Definition at line 104 of file IndexPager.php.

◆ $mRequest

WebRequest MediaWiki\Pager\IndexPager::$mRequest

Definition at line 94 of file IndexPager.php.

◆ $mResult

IResultWrapper MediaWiki\Pager\IndexPager::$mResult

Result object for the query.

Warning: seek before use.

Definition at line 170 of file IndexPager.php.

Referenced by MediaWiki\Pager\IndexPager\getResult().

◆ DIR_ASCENDING

const MediaWiki\Pager\IndexPager::DIR_ASCENDING = false

Backwards-compatible constant for $mDefaultDirection field (do not change)

Definition at line 84 of file IndexPager.php.

Referenced by MediaWiki\Pager\ImageListPager\__construct(), MediaWiki\Pager\UsersPager\__construct(), MediaWiki\Pager\TablePager\__construct(), and MediaWiki\Pager\IndexPager\doQuery().

◆ DIR_DESCENDING

const MediaWiki\Pager\IndexPager::DIR_DESCENDING = true

◆ QUERY_ASCENDING

const MediaWiki\Pager\IndexPager::QUERY_ASCENDING = true

Backwards-compatible constant for reallyDoQuery() (do not change)

Definition at line 89 of file IndexPager.php.

Referenced by MediaWiki\Pager\IndexPager\oppositeOrder(), and MediaWiki\Pager\AllMessagesTablePager\reallyDoQuery().

◆ QUERY_DESCENDING

const MediaWiki\Pager\IndexPager::QUERY_DESCENDING = false

Backwards-compatible constant for reallyDoQuery() (do not change)

Definition at line 91 of file IndexPager.php.

Referenced by MediaWiki\Pager\IndexPager\doQuery(), and MediaWiki\Pager\IndexPager\oppositeOrder().


The documentation for this class was generated from the following file: