EBernhardson has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/366190 )
Change subject: Support custom offsets from SearchResultSet
......................................................................
Support custom offsets from SearchResultSet
Work to support interleaved AB testing of search will display
interleaved results of two search configurations on the first page of
results, but standard results on all pages other than the first page.
This means that while 20 results may be requested, the next 'new' result
of the primary query may be at position 10. Allow the SearchResultSet
to declare what the new offset is.
Bug: T150032
Change-Id: I14c0c33249fcdb66f72f5966e2aa72781a34daee
---
M includes/search/SearchResultSet.php
M includes/specials/SpecialSearch.php
2 files changed, 19 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/90/366190/1
diff --git a/includes/search/SearchResultSet.php
b/includes/search/SearchResultSet.php
index 978db27..89d2299 100644
--- a/includes/search/SearchResultSet.php
+++ b/includes/search/SearchResultSet.php
@@ -264,4 +264,14 @@
$result->setExtensionData( $this->extraData[$id] );
return $this->extraData[$id];
}
+
+ /**
+ * @return int|null The offset the current page starts at. Typically
+ * this should be null to allow the UI to decide on its own, but in
+ * special cases like interleaved AB tests specifying explicitly is
+ * necessary.
+ */
+ public function getOffset() {
+ return null;
+ }
}
diff --git a/includes/specials/SpecialSearch.php
b/includes/specials/SpecialSearch.php
index e89dbc9..b739c34 100644
--- a/includes/specials/SpecialSearch.php
+++ b/includes/specials/SpecialSearch.php
@@ -436,9 +436,17 @@
// prev/next links
if ( $totalRes > $this->limit || $this->offset ) {
+ // Allow matches to define the correct offset, as
interleaved
+ // AB testing may require a different next page offset.
+ if ( $textMatches && $textMatches->getOffset() !== null
) {
+ $offset = $textMatches->getOffset();
+ } else {
+ $offset = $this->offset;
+ }
+
$prevnext = $this->getLanguage()->viewPrevNext(
$this->getPageTitle(),
- $this->offset,
+ $offset,
$this->limit,
$this->powerSearchOptions() + [ 'search' =>
$term ],
$this->limit + $this->offset >= $totalRes
--
To view, visit https://gerrit.wikimedia.org/r/366190
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I14c0c33249fcdb66f72f5966e2aa72781a34daee
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits