jenkins-bot has submitted this change and it was merged.
Change subject: Backend support for test swapping second and third result
......................................................................
Backend support for test swapping second and third result
Bug: T127878
Change-Id: Ie198bc73e17db182af8402c6934a9f93845f3e7e
---
M includes/CirrusSearch.php
M includes/Search/ResultSet.php
2 files changed, 26 insertions(+), 2 deletions(-)
Approvals:
DCausse: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/CirrusSearch.php b/includes/CirrusSearch.php
index 2b969e4..7bdf754 100644
--- a/includes/CirrusSearch.php
+++ b/includes/CirrusSearch.php
@@ -140,6 +140,12 @@
$matches->isQueryRewriteAllowed(
$GLOBALS['wgCirrusSearchInterwikiThreshold'] ) ) {
$matches = $this->searchTextSecondTry( $term, $matches
);
}
+
+ if ( $this->request && $this->request->getVal( 'cirrusSRTest' )
=== 'yes' ) {
+ // note these are 0 indexed, so swap second and third
+ $matches->swapResults( 1, 2 );
+ }
+
return $matches;
}
diff --git a/includes/Search/ResultSet.php b/includes/Search/ResultSet.php
index af51d04..32f6c19 100644
--- a/includes/Search/ResultSet.php
+++ b/includes/Search/ResultSet.php
@@ -32,6 +32,7 @@
private $searchContainedSyntax;
private $interwikiPrefix,$interwikiResults;
private $rewrittenQuery;
+ private $swappedResultIter;
public function __construct( $suggestPrefixes, $suggestSuffixes, $res,
$searchContainedSyntax, $interwiki = '' ) {
$this->result = $res;
@@ -189,12 +190,29 @@
}
/**
+ * @param integer $first 0-indexed result to swap with $second
+ * @param integer $second 0-indexed result to swap with $first
+ */
+ public function swapResults( $first, $second ) {
+ $iter = $this->swappedResultIter ?: $this->result;
+ if ( $iter->count() <= max( $first, $second ) ) {
+ return;
+ }
+ $results = iterator_to_array( $iter );
+ $firstElem = $results[$first];
+ $results[$first] = $results[$second];
+ $results[$second] = $firstElem;
+ $this->swappedResultIter = new \ArrayIterator( $results );
+ }
+
+ /**
* @return Result|false
*/
public function next() {
- $current = $this->result->current();
+ $iter = $this->swappedResultIter ?: $this->result;
+ $current = $iter->current();
if ( $current ) {
- $this->result->next();
+ $iter->next();
return new Result( $this->result, $current,
$this->interwikiPrefix );
}
return false;
--
To view, visit https://gerrit.wikimedia.org/r/279083
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie198bc73e17db182af8402c6934a9f93845f3e7e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: Cindy-the-browser-test-bot <[email protected]>
Gerrit-Reviewer: DCausse <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Gehel <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits