Merge "RevisionStoreDbTestBase, remove redundant needsDB override"
[lhc/web/wiklou.git] / includes / pager / IndexPager.php
1 <?php
2 /**
3 * Efficient paging for SQL queries.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Pager
22 */
23
24 use Wikimedia\Rdbms\IResultWrapper;
25 use Wikimedia\Rdbms\IDatabase;
26
27 /**
28 * IndexPager is an efficient pager which uses a (roughly unique) index in the
29 * data set to implement paging, rather than a "LIMIT offset,limit" clause.
30 * In MySQL, such a limit/offset clause requires counting through the
31 * specified number of offset rows to find the desired data, which can be
32 * expensive for large offsets.
33 *
34 * ReverseChronologicalPager is a child class of the abstract IndexPager, and
35 * contains some formatting and display code which is specific to the use of
36 * timestamps as indexes. Here is a synopsis of its operation:
37 *
38 * * The query is specified by the offset, limit and direction (dir)
39 * parameters, in addition to any subclass-specific parameters.
40 * * The offset is the non-inclusive start of the DB query. A row with an
41 * index value equal to the offset will never be shown.
42 * * The query may either be done backwards, where the rows are returned by
43 * the database in the opposite order to which they are displayed to the
44 * user, or forwards. This is specified by the "dir" parameter, dir=prev
45 * means backwards, anything else means forwards. The offset value
46 * specifies the start of the database result set, which may be either
47 * the start or end of the displayed data set. This allows "previous"
48 * links to be implemented without knowledge of the index value at the
49 * start of the previous page.
50 * * An additional row beyond the user-specified limit is always requested.
51 * This allows us to tell whether we should display a "next" link in the
52 * case of forwards mode, or a "previous" link in the case of backwards
53 * mode. Determining whether to display the other link (the one for the
54 * page before the start of the database result set) can be done
55 * heuristically by examining the offset.
56 *
57 * * An empty offset indicates that the offset condition should be omitted
58 * from the query. This naturally produces either the first page or the
59 * last page depending on the dir parameter.
60 *
61 * Subclassing the pager to implement concrete functionality should be fairly
62 * simple, please see the examples in HistoryAction.php and
63 * SpecialBlockList.php. You just need to override formatRow(),
64 * getQueryInfo() and getIndexField(). Don't forget to call the parent
65 * constructor if you override it.
66 *
67 * @ingroup Pager
68 */
69 abstract class IndexPager extends ContextSource implements Pager {
70 /**
71 * Constants for the $mDefaultDirection field.
72 *
73 * These are boolean for historical reasons and should stay boolean for backwards-compatibility.
74 */
75 const DIR_ASCENDING = false;
76 const DIR_DESCENDING = true;
77
78 public $mRequest;
79 public $mLimitsShown = [ 20, 50, 100, 250, 500 ];
80 public $mDefaultLimit = 50;
81 public $mOffset, $mLimit;
82 public $mQueryDone = false;
83 /** @var IDatabase */
84 public $mDb;
85 public $mPastTheEndRow;
86
87 /**
88 * The index to actually be used for ordering. This is a single column,
89 * for one ordering, even if multiple orderings are supported.
90 */
91 protected $mIndexField;
92 /**
93 * An array of secondary columns to order by. These fields are not part of the offset.
94 * This is a column list for one ordering, even if multiple orderings are supported.
95 */
96 protected $mExtraSortFields;
97 /** For pages that support multiple types of ordering, which one to use.
98 */
99 protected $mOrderType;
100 /**
101 * $mDefaultDirection gives the direction to use when sorting results:
102 * DIR_ASCENDING or DIR_DESCENDING. If $mIsBackwards is set, we
103 * start from the opposite end, but we still sort the page itself according
104 * to $mDefaultDirection. E.g., if $mDefaultDirection is false but we're
105 * going backwards, we'll display the last page of results, but the last
106 * result will be at the bottom, not the top.
107 *
108 * Like $mIndexField, $mDefaultDirection will be a single value even if the
109 * class supports multiple default directions for different order types.
110 */
111 public $mDefaultDirection;
112 public $mIsBackwards;
113
114 /** True if the current result set is the first one */
115 public $mIsFirst;
116 public $mIsLast;
117
118 protected $mLastShown, $mFirstShown, $mPastTheEndIndex, $mDefaultQuery, $mNavigationBar;
119
120 /**
121 * Whether to include the offset in the query
122 */
123 protected $mIncludeOffset = false;
124
125 /**
126 * Result object for the query. Warning: seek before use.
127 *
128 * @var IResultWrapper
129 */
130 public $mResult;
131
132 public function __construct( IContextSource $context = null ) {
133 if ( $context ) {
134 $this->setContext( $context );
135 }
136
137 $this->mRequest = $this->getRequest();
138
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' );
143
144 # Use consistent behavior for the limit options
145 $this->mDefaultLimit = $this->getUser()->getIntOption( 'rclimit' );
146 if ( !$this->mLimit ) {
147 // Don't override if a subclass calls $this->setLimit() in its constructor.
148 list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset();
149 }
150
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
153 $this->mDb = $this->mDb ?: wfGetDB( DB_REPLICA );
154
155 $index = $this->getIndexField(); // column to sort on
156 $extraSort = $this->getExtraSortFields(); // extra columns to sort on for query planning
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]
163 : [];
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]
170 : [];
171 } else {
172 # $index is not an array
173 $this->mOrderType = null;
174 $this->mIndexField = $index;
175 $this->mExtraSortFields = (array)$extraSort;
176 }
177
178 if ( !isset( $this->mDefaultDirection ) ) {
179 $dir = $this->getDefaultDirections();
180 $this->mDefaultDirection = is_array( $dir )
181 ? $dir[$this->mOrderType]
182 : $dir;
183 }
184 }
185
186 /**
187 * Get the Database object in use
188 *
189 * @return IDatabase
190 */
191 public function getDatabase() {
192 return $this->mDb;
193 }
194
195 /**
196 * Do the query, using information from the object context. This function
197 * has been kept minimal to make it overridable if necessary, to allow for
198 * result sets formed from multiple DB queries.
199 */
200 public function doQuery() {
201 # Use the child class name for profiling
202 $fname = __METHOD__ . ' (' . static::class . ')';
203 $section = Profiler::instance()->scopedProfileIn( $fname );
204
205 // @todo This should probably compare to DIR_DESCENDING and DIR_ASCENDING constants
206 $descending = ( $this->mIsBackwards == $this->mDefaultDirection );
207 # Plus an extra row so that we can tell the "next" link should be shown
208 $queryLimit = $this->mLimit + 1;
209
210 if ( $this->mOffset == '' ) {
211 $isFirst = true;
212 } else {
213 // If there's an offset, we may or may not be at the first entry.
214 // The only way to tell is to run the query in the opposite
215 // direction see if we get a row.
216 $oldIncludeOffset = $this->mIncludeOffset;
217 $this->mIncludeOffset = !$this->mIncludeOffset;
218 $isFirst = !$this->reallyDoQuery( $this->mOffset, 1, !$descending )->numRows();
219 $this->mIncludeOffset = $oldIncludeOffset;
220 }
221
222 $this->mResult = $this->reallyDoQuery(
223 $this->mOffset,
224 $queryLimit,
225 $descending
226 );
227
228 $this->extractResultInfo( $isFirst, $queryLimit, $this->mResult );
229 $this->mQueryDone = true;
230
231 $this->preprocessResults( $this->mResult );
232 $this->mResult->rewind(); // Paranoia
233 }
234
235 /**
236 * @return IResultWrapper The result wrapper.
237 */
238 function getResult() {
239 return $this->mResult;
240 }
241
242 /**
243 * Set the offset from an other source than the request
244 *
245 * @param int|string $offset
246 */
247 function setOffset( $offset ) {
248 $this->mOffset = $offset;
249 }
250
251 /**
252 * Set the limit from an other source than the request
253 *
254 * Verifies limit is between 1 and 5000
255 *
256 * @param int|string $limit
257 */
258 function setLimit( $limit ) {
259 $limit = (int)$limit;
260 // WebRequest::getLimitOffset() puts a cap of 5000, so do same here.
261 if ( $limit > 5000 ) {
262 $limit = 5000;
263 }
264 if ( $limit > 0 ) {
265 $this->mLimit = $limit;
266 }
267 }
268
269 /**
270 * Get the current limit
271 *
272 * @return int
273 */
274 function getLimit() {
275 return $this->mLimit;
276 }
277
278 /**
279 * Set whether a row matching exactly the offset should be also included
280 * in the result or not. By default this is not the case, but when the
281 * offset is user-supplied this might be wanted.
282 *
283 * @param bool $include
284 */
285 public function setIncludeOffset( $include ) {
286 $this->mIncludeOffset = $include;
287 }
288
289 /**
290 * Extract some useful data from the result object for use by
291 * the navigation bar, put it into $this
292 *
293 * @param bool $isFirst False if there are rows before those fetched (i.e.
294 * if a "previous" link would make sense)
295 * @param int $limit Exact query limit
296 * @param IResultWrapper $res
297 */
298 function extractResultInfo( $isFirst, $limit, IResultWrapper $res ) {
299 $numRows = $res->numRows();
300 if ( $numRows ) {
301 # Remove any table prefix from index field
302 $parts = explode( '.', $this->mIndexField );
303 $indexColumn = end( $parts );
304
305 $row = $res->fetchRow();
306 $firstIndex = $row[$indexColumn];
307
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];
316 } else {
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];
326 }
327 } else {
328 $firstIndex = '';
329 $lastIndex = '';
330 $this->mPastTheEndRow = null;
331 $this->mPastTheEndIndex = '';
332 }
333
334 if ( $this->mIsBackwards ) {
335 $this->mIsFirst = ( $numRows < $limit );
336 $this->mIsLast = $isFirst;
337 $this->mLastShown = $firstIndex;
338 $this->mFirstShown = $lastIndex;
339 } else {
340 $this->mIsFirst = $isFirst;
341 $this->mIsLast = ( $numRows < $limit );
342 $this->mLastShown = $lastIndex;
343 $this->mFirstShown = $firstIndex;
344 }
345 }
346
347 /**
348 * Get some text to go in brackets in the "function name" part of the SQL comment
349 *
350 * @return string
351 */
352 function getSqlComment() {
353 return static::class;
354 }
355
356 /**
357 * Do a query with specified parameters, rather than using the object
358 * context
359 *
360 * @param string $offset Index offset, inclusive
361 * @param int $limit Exact query limit
362 * @param bool $descending Query direction, false for ascending, true for descending
363 * @return IResultWrapper
364 */
365 public function reallyDoQuery( $offset, $limit, $descending ) {
366 list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
367 $this->buildQueryInfo( $offset, $limit, $descending );
368
369 return $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
370 }
371
372 /**
373 * Build variables to use by the database wrapper.
374 *
375 * @param string $offset Index offset, inclusive
376 * @param int $limit Exact query limit
377 * @param bool $descending Query direction, false for ascending, true for descending
378 * @return array
379 */
380 protected function buildQueryInfo( $offset, $limit, $descending ) {
381 $fname = __METHOD__ . ' (' . $this->getSqlComment() . ')';
382 $info = $this->getQueryInfo();
383 $tables = $info['tables'];
384 $fields = $info['fields'];
385 $conds = $info['conds'] ?? [];
386 $options = $info['options'] ?? [];
387 $join_conds = $info['join_conds'] ?? [];
388 $sortColumns = array_merge( [ $this->mIndexField ], $this->mExtraSortFields );
389 if ( $descending ) {
390 $options['ORDER BY'] = $sortColumns;
391 $operator = $this->mIncludeOffset ? '>=' : '>';
392 } else {
393 $orderBy = [];
394 foreach ( $sortColumns as $col ) {
395 $orderBy[] = $col . ' DESC';
396 }
397 $options['ORDER BY'] = $orderBy;
398 $operator = $this->mIncludeOffset ? '<=' : '<';
399 }
400 if ( $offset != '' ) {
401 $conds[] = $this->mIndexField . $operator . $this->mDb->addQuotes( $offset );
402 }
403 $options['LIMIT'] = intval( $limit );
404 return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
405 }
406
407 /**
408 * Pre-process results; useful for performing batch existence checks, etc.
409 *
410 * @param IResultWrapper $result
411 */
412 protected function preprocessResults( $result ) {
413 }
414
415 /**
416 * Get the formatted result list. Calls getStartBody(), formatRow() and
417 * getEndBody(), concatenates the results and returns them.
418 *
419 * @return string
420 */
421 public function getBody() {
422 if ( !$this->mQueryDone ) {
423 $this->doQuery();
424 }
425
426 if ( $this->mResult->numRows() ) {
427 # Do any special query batches before display
428 $this->doBatchLookups();
429 }
430
431 # Don't use any extra rows returned by the query
432 $numRows = min( $this->mResult->numRows(), $this->mLimit );
433
434 $s = $this->getStartBody();
435 if ( $numRows ) {
436 if ( $this->mIsBackwards ) {
437 for ( $i = $numRows - 1; $i >= 0; $i-- ) {
438 $this->mResult->seek( $i );
439 $row = $this->mResult->fetchObject();
440 $s .= $this->formatRow( $row );
441 }
442 } else {
443 $this->mResult->seek( 0 );
444 for ( $i = 0; $i < $numRows; $i++ ) {
445 $row = $this->mResult->fetchObject();
446 $s .= $this->formatRow( $row );
447 }
448 }
449 } else {
450 $s .= $this->getEmptyBody();
451 }
452 $s .= $this->getEndBody();
453 return $s;
454 }
455
456 /**
457 * Make a self-link
458 *
459 * @param string $text Text displayed on the link
460 * @param array|null $query Associative array of parameter to be in the query string
461 * @param string|null $type Link type used to create additional attributes, like "rel", "class" or
462 * "title". Valid values (non-exhaustive list): 'first', 'last', 'prev', 'next', 'asc', 'desc'.
463 * @return string HTML fragment
464 */
465 function makeLink( $text, array $query = null, $type = null ) {
466 if ( $query === null ) {
467 return $text;
468 }
469
470 $attrs = [];
471 if ( in_array( $type, [ 'prev', 'next' ] ) ) {
472 $attrs['rel'] = $type;
473 }
474
475 if ( in_array( $type, [ 'asc', 'desc' ] ) ) {
476 $attrs['title'] = $this->msg( $type == 'asc' ? 'sort-ascending' : 'sort-descending' )->text();
477 }
478
479 if ( $type ) {
480 $attrs['class'] = "mw-{$type}link";
481 }
482
483 return Linker::linkKnown(
484 $this->getTitle(),
485 $text,
486 $attrs,
487 $query + $this->getDefaultQuery()
488 );
489 }
490
491 /**
492 * Called from getBody(), before getStartBody() is called and
493 * after doQuery() was called. This will be called only if there
494 * are rows in the result set.
495 *
496 * @return void
497 */
498 protected function doBatchLookups() {
499 }
500
501 /**
502 * Hook into getBody(), allows text to be inserted at the start. This
503 * will be called even if there are no rows in the result set.
504 *
505 * @return string
506 */
507 protected function getStartBody() {
508 return '';
509 }
510
511 /**
512 * Hook into getBody() for the end of the list
513 *
514 * @return string
515 */
516 protected function getEndBody() {
517 return '';
518 }
519
520 /**
521 * Hook into getBody(), for the bit between the start and the
522 * end when there are no rows
523 *
524 * @return string
525 */
526 protected function getEmptyBody() {
527 return '';
528 }
529
530 /**
531 * Get an array of query parameters that should be put into self-links.
532 * By default, all parameters passed in the URL are used, except for a
533 * short blacklist.
534 *
535 * @return array Associative array
536 */
537 function getDefaultQuery() {
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'] );
547 }
548 return $this->mDefaultQuery;
549 }
550
551 /**
552 * Get the number of rows in the result set
553 *
554 * @return int
555 */
556 function getNumRows() {
557 if ( !$this->mQueryDone ) {
558 $this->doQuery();
559 }
560 return $this->mResult->numRows();
561 }
562
563 /**
564 * Get a URL query array for the prev, next, first and last links.
565 *
566 * @return array
567 */
568 function getPagingQueries() {
569 if ( !$this->mQueryDone ) {
570 $this->doQuery();
571 }
572
573 # Don't announce the limit everywhere if it's the default
574 $urlLimit = $this->mLimit == $this->mDefaultLimit ? null : $this->mLimit;
575
576 if ( $this->mIsFirst ) {
577 $prev = false;
578 $first = false;
579 } else {
580 $prev = [
581 'dir' => 'prev',
582 'offset' => $this->mFirstShown,
583 'limit' => $urlLimit
584 ];
585 $first = [ 'limit' => $urlLimit ];
586 }
587 if ( $this->mIsLast ) {
588 $next = false;
589 $last = false;
590 } else {
591 $next = [ 'offset' => $this->mLastShown, 'limit' => $urlLimit ];
592 $last = [ 'dir' => 'prev', 'limit' => $urlLimit ];
593 }
594 return [
595 'prev' => $prev,
596 'next' => $next,
597 'first' => $first,
598 'last' => $last
599 ];
600 }
601
602 /**
603 * Returns whether to show the "navigation bar"
604 *
605 * @return bool
606 */
607 function isNavigationBarShown() {
608 if ( !$this->mQueryDone ) {
609 $this->doQuery();
610 }
611 // Hide navigation by default if there is nothing to page
612 return !( $this->mIsFirst && $this->mIsLast );
613 }
614
615 /**
616 * Get paging links. If a link is disabled, the item from $disabledTexts
617 * will be used. If there is no such item, the unlinked text from
618 * $linkTexts will be used. Both $linkTexts and $disabledTexts are arrays
619 * of HTML.
620 *
621 * @param array $linkTexts
622 * @param array $disabledTexts
623 * @return array
624 */
625 function getPagingLinks( $linkTexts, $disabledTexts = [] ) {
626 $queries = $this->getPagingQueries();
627 $links = [];
628
629 foreach ( $queries as $type => $query ) {
630 if ( $query !== false ) {
631 $links[$type] = $this->makeLink(
632 $linkTexts[$type],
633 $queries[$type],
634 $type
635 );
636 } elseif ( isset( $disabledTexts[$type] ) ) {
637 $links[$type] = $disabledTexts[$type];
638 } else {
639 $links[$type] = $linkTexts[$type];
640 }
641 }
642
643 return $links;
644 }
645
646 function getLimitLinks() {
647 $links = [];
648 if ( $this->mIsBackwards ) {
649 $offset = $this->mPastTheEndIndex;
650 } else {
651 $offset = $this->mOffset;
652 }
653 foreach ( $this->mLimitsShown as $limit ) {
654 $links[] = $this->makeLink(
655 $this->getLanguage()->formatNum( $limit ),
656 [ 'offset' => $offset, 'limit' => $limit ],
657 'num'
658 );
659 }
660 return $links;
661 }
662
663 /**
664 * Abstract formatting function. This should return an HTML string
665 * representing the result row $row. Rows will be concatenated and
666 * returned by getBody()
667 *
668 * @param array|stdClass $row Database row
669 * @return string
670 */
671 abstract function formatRow( $row );
672
673 /**
674 * This function should be overridden to provide all parameters
675 * needed for the main paged query. It returns an associative
676 * array with the following elements:
677 * tables => Table(s) for passing to Database::select()
678 * fields => Field(s) for passing to Database::select(), may be *
679 * conds => WHERE conditions
680 * options => option array
681 * join_conds => JOIN conditions
682 *
683 * @return array
684 */
685 abstract function getQueryInfo();
686
687 /**
688 * This function should be overridden to return the name of the index fi-
689 * eld. If the pager supports multiple orders, it may return an array of
690 * 'querykey' => 'indexfield' pairs, so that a request with &count=querykey
691 * will use indexfield to sort. In this case, the first returned key is
692 * the default.
693 *
694 * Needless to say, it's really not a good idea to use a non-unique index
695 * for this! That won't page right.
696 *
697 * @return string|array
698 */
699 abstract function getIndexField();
700
701 /**
702 * This function should be overridden to return the names of secondary columns
703 * to order by in addition to the column in getIndexField(). These fields will
704 * not be used in the pager offset or in any links for users.
705 *
706 * If getIndexField() returns an array of 'querykey' => 'indexfield' pairs then
707 * this must return a corresponding array of 'querykey' => [ fields... ] pairs
708 * in order for a request with &count=querykey to use [ fields... ] to sort.
709 *
710 * This is useful for pagers that GROUP BY a unique column (say page_id)
711 * and ORDER BY another (say page_len). Using GROUP BY and ORDER BY both on
712 * page_len,page_id avoids temp tables (given a page_len index). This would
713 * also work if page_id was non-unique but we had a page_len,page_id index.
714 *
715 * @return array
716 */
717 protected function getExtraSortFields() {
718 return [];
719 }
720
721 /**
722 * Return the default sorting direction: DIR_ASCENDING or DIR_DESCENDING.
723 * You can also have an associative array of ordertype => dir,
724 * if multiple order types are supported. In this case getIndexField()
725 * must return an array, and the keys of that must exactly match the keys
726 * of this.
727 *
728 * For backward compatibility, this method's return value will be ignored
729 * if $this->mDefaultDirection is already set when the constructor is
730 * called, for instance if it's statically initialized. In that case the
731 * value of that variable (which must be a boolean) will be used.
732 *
733 * Note that despite its name, this does not return the value of the
734 * $this->mDefaultDirection member variable. That's the default for this
735 * particular instantiation, which is a single value. This is the set of
736 * all defaults for the class.
737 *
738 * @return bool
739 */
740 protected function getDefaultDirections() {
741 return self::DIR_ASCENDING;
742 }
743 }