139 # NB: the offset is quoted, not validated. It is treated as an
140 # arbitrary string to support the widest variety of index types. Be
141 # careful outputting it into HTML!
142 $this->mOffset = $this->mRequest->getText(
'offset' );
144 # Use consistent behavior for the limit options
145 $this->mDefaultLimit = $this->
getUser()->getIntOption(
'rclimit' );
146 if ( !$this->mLimit ) {
148 list( $this->mLimit, ) = $this->mRequest->getLimitOffset();
151 $this->mIsBackwards = ( $this->mRequest->getVal(
'dir' ) ==
'prev' );
152 # Let the subclass set the DB here; otherwise use a replica DB for the current wiki
157 $order = $this->mRequest->getVal(
'order' );
158 if ( is_array( $index ) && isset( $index[$order] ) ) {
159 $this->mOrderType = $order;
160 $this->mIndexField = $index[$order];
161 $this->mExtraSortFields = isset( $extraSort[$order] )
162 ? (
array)$extraSort[$order]
164 } elseif ( is_array( $index ) ) {
165 # First element is the default
166 $this->mIndexField = reset( $index );
167 $this->mOrderType =
key( $index );
168 $this->mExtraSortFields = isset( $extraSort[$this->mOrderType] )
169 ? (
array)$extraSort[$this->mOrderType]
172 # $index is not an array
173 $this->mOrderType =
null;
174 $this->mIndexField = $index;
175 $this->mExtraSortFields = (
array)$extraSort;
178 if ( !isset( $this->mDefaultDirection ) ) {
180 $this->mDefaultDirection = is_array( $dir )
201 # Use the child class name for profiling
202 $fname = __METHOD__ .
' (' . static::class .
')';
207 # Plus an extra row so that we can tell the "next" link should be shown
208 $queryLimit = $this->mLimit + 1;
210 if ( $this->mOffset ==
'' ) {
218 $isFirst = !$this->
reallyDoQuery( $this->mOffset, 1, !$descending )->numRows();
219 $this->mIncludeOffset = $oldIncludeOffset;
229 $this->mQueryDone =
true;
232 $this->mResult->rewind();
248 $this->mOffset = $offset;
259 $limit = (int)$limit;
261 if ( $limit > 5000 ) {
265 $this->mLimit = $limit;
286 $this->mIncludeOffset = $include;
299 $numRows =
$res->numRows();
301 # Remove any table prefix from index field
302 $parts = explode(
'.', $this->mIndexField );
303 $indexColumn = end( $parts );
305 $row =
$res->fetchRow();
306 $firstIndex = $row[$indexColumn];
308 # Discard the extra result row if there is one
309 if ( $numRows > $this->mLimit && $numRows > 1 ) {
310 $res->seek( $numRows - 1 );
311 $this->mPastTheEndRow =
$res->fetchObject();
312 $this->mPastTheEndIndex = $this->mPastTheEndRow->$indexColumn;
313 $res->seek( $numRows - 2 );
314 $row =
$res->fetchRow();
315 $lastIndex = $row[$indexColumn];
317 $this->mPastTheEndRow =
null;
318 # Setting indexes to an empty string means that they will be
319 # omitted if they would otherwise appear in URLs. It just so
320 # happens that this is the right thing to do in the standard
321 # UI, in all the relevant cases.
322 $this->mPastTheEndIndex =
'';
323 $res->seek( $numRows - 1 );
324 $row =
$res->fetchRow();
325 $lastIndex = $row[$indexColumn];
330 $this->mPastTheEndRow =
null;
331 $this->mPastTheEndIndex =
'';
334 if ( $this->mIsBackwards ) {
335 $this->mIsFirst = ( $numRows < $limit );
336 $this->mIsLast = $isFirst;
337 $this->mLastShown = $firstIndex;
338 $this->mFirstShown = $lastIndex;
340 $this->mIsFirst = $isFirst;
341 $this->mIsLast = ( $numRows < $limit );
342 $this->mLastShown = $lastIndex;
343 $this->mFirstShown = $firstIndex;
353 return static::class;
384 $fields = $info[
'fields'];
385 $conds = $info[
'conds'] ?? [];
387 $join_conds = $info[
'join_conds'] ?? [];
388 $sortColumns = array_merge( [ $this->mIndexField ], $this->mExtraSortFields );
390 $options[
'ORDER BY'] = $sortColumns;
391 $operator = $this->mIncludeOffset ?
'>=' :
'>';
394 foreach ( $sortColumns as $col ) {
395 $orderBy[] = $col .
' DESC';
398 $operator = $this->mIncludeOffset ?
'<=' :
'<';
400 if ( $offset !=
'' ) {
401 $conds[] = $this->mIndexField . $operator . $this->mDb->addQuotes( $offset );
403 $options[
'LIMIT'] = intval( $limit );
422 if ( !$this->mQueryDone ) {
426 if ( $this->mResult->numRows() ) {
427 # Do any special query batches before display
431 # Don't use any extra rows returned by the query
432 $numRows = min( $this->mResult->numRows(), $this->mLimit );
436 if ( $this->mIsBackwards ) {
437 for ( $i = $numRows - 1; $i >= 0; $i-- ) {
438 $this->mResult->seek( $i );
439 $row = $this->mResult->fetchObject();
443 $this->mResult->seek( 0 );
444 for ( $i = 0; $i < $numRows; $i++ ) {
445 $row = $this->mResult->fetchObject();
471 if ( in_array(
$type, [
'prev',
'next' ] ) ) {
472 $attrs[
'rel'] =
$type;
475 if ( in_array(
$type, [
'asc',
'desc' ] ) ) {
476 $attrs[
'title'] = $this->
msg(
$type ==
'asc' ?
'sort-ascending' :
'sort-descending' )->
text();
480 $attrs[
'class'] =
"mw-{$type}link";
538 if ( !isset( $this->mDefaultQuery ) ) {
539 $this->mDefaultQuery = $this->
getRequest()->getQueryValues();
540 unset( $this->mDefaultQuery[
'title'] );
541 unset( $this->mDefaultQuery[
'dir'] );
542 unset( $this->mDefaultQuery[
'offset'] );
543 unset( $this->mDefaultQuery[
'limit'] );
544 unset( $this->mDefaultQuery[
'order'] );
545 unset( $this->mDefaultQuery[
'month'] );
546 unset( $this->mDefaultQuery[
'year'] );
557 if ( !$this->mQueryDone ) {
560 return $this->mResult->numRows();
569 if ( !$this->mQueryDone ) {
573 # Don't announce the limit everywhere if it's the default
574 $urlLimit = $this->mLimit == $this->mDefaultLimit ? null :
$this->mLimit;
576 if ( $this->mIsFirst ) {
585 $first = [
'limit' => $urlLimit ];
587 if ( $this->mIsLast ) {
592 $last = [
'dir' =>
'prev',
'limit' => $urlLimit ];
608 if ( !$this->mQueryDone ) {
636 } elseif ( isset( $disabledTexts[
$type] ) ) {
648 if ( $this->mIsBackwards ) {
653 foreach ( $this->mLimitsShown as $limit ) {
656 [
'offset' => $offset,
'limit' => $limit ],
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
setContext(IContextSource $context)
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
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
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
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message key
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
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Interface for objects which can provide a MediaWiki context on request.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))