diff options
author | Func <Funcer@outlook.com> | 2023-01-23 00:00:32 +0800 |
---|---|---|
committer | Func <Funcer@outlook.com> | 2023-02-12 14:42:06 +0800 |
commit | d971f80700234cb3e3ca08d28a35f157268a48c3 (patch) | |
tree | 07f2a4cdfdef1b74f7f90ceb9774d178d672d6ab | |
parent | 1fa92f2a28c14611e4d4ea93bf59979a7ff451f2 (diff) | |
download | mediawikicore-d971f80700234cb3e3ca08d28a35f157268a48c3.tar.gz mediawikicore-d971f80700234cb3e3ca08d28a35f157268a48c3.zip |
pager: Allow getting range offsets outside the subclass context
Extensions implemented the onContribsPager__reallyDoQuery() hook can
use these new methods to limit the query range.
Bug: T167577
Change-Id: Ieda822f9ccffea179796f48929f02a75ee01fb95
-rw-r--r-- | includes/pager/RangeChronologicalPager.php | 11 | ||||
-rw-r--r-- | includes/pager/ReverseChronologicalPager.php | 10 | ||||
-rw-r--r-- | includes/specials/pagers/ContribsPager.php | 3 |
3 files changed, 24 insertions, 0 deletions
diff --git a/includes/pager/RangeChronologicalPager.php b/includes/pager/RangeChronologicalPager.php index 8e41340344c7..3d7c4134d7d6 100644 --- a/includes/pager/RangeChronologicalPager.php +++ b/includes/pager/RangeChronologicalPager.php @@ -83,6 +83,17 @@ abstract class RangeChronologicalPager extends ReverseChronologicalPager { } /** + * Return the range of date offsets, in the format of [ endOffset, startOffset ]. + * Extensions can use this to get the range if they are not in the context of subclasses. + * + * @since 1.40 + * @return string[] + */ + public function getRangeOffsets() { + return [ $this->endOffset, $this->startOffset ]; + } + + /** * @inheritDoc */ protected function buildQueryInfo( $offset, $limit, $order ) { diff --git a/includes/pager/ReverseChronologicalPager.php b/includes/pager/ReverseChronologicalPager.php index 5a189bd57ab3..d9966ec5770a 100644 --- a/includes/pager/ReverseChronologicalPager.php +++ b/includes/pager/ReverseChronologicalPager.php @@ -291,6 +291,16 @@ abstract class ReverseChronologicalPager extends IndexPager { } /** + * Return the end offset, extensions can use this if they are not in the context of subclass. + * + * @since 1.40 + * @return string + */ + public function getEndOffset() { + return $this->endOffset; + } + + /** * @inheritDoc */ protected function buildQueryInfo( $offset, $limit, $order ) { diff --git a/includes/specials/pagers/ContribsPager.php b/includes/specials/pagers/ContribsPager.php index e123f9b1778a..d2d72b02b6ea 100644 --- a/includes/specials/pagers/ContribsPager.php +++ b/includes/specials/pagers/ContribsPager.php @@ -301,6 +301,9 @@ class ContribsPager extends RangeChronologicalPager { $tables, $fields, $conds, $fname, $options, $join_conds ) ]; if ( !$this->revisionsOnly ) { + // TODO: Range offsets are fairly important and all handlers should take care of it. + // If this hook will be replaced (e.g. unified with the DeletedContribsPager one), + // please consider passing [ $this->endOffset, $this->startOffset ] to it (T167577). $this->hookRunner->onContribsPager__reallyDoQuery( $data, $this, $offset, $limit, $order ); } |