Merge "Perform a permission check on the title when changing the page language"
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index e89dbc9..85b4572 100644 (file)
@@ -352,7 +352,7 @@ class SpecialSearch extends SpecialPage {
                        $out->addHTML( $dymWidget->render( $term, $textMatches ) );
                }
 
-               $hasErrors = $textStatus && $textStatus->getErrors();
+               $hasErrors = $textStatus && $textStatus->getErrors() !== [];
                $hasOtherResults = $textMatches &&
                        $textMatches->hasInterwikiResults( SearchResultSet::INLINE_RESULTS );
 
@@ -399,7 +399,6 @@ class SpecialSearch extends SpecialPage {
                $mainResultWidget = new FullSearchResultWidget( $this, $linkRenderer );
 
                if ( $search->getFeatureData( 'enable-new-crossproject-page' ) ) {
-
                        $sidebarResultWidget = new InterwikiSearchResultWidget( $this, $linkRenderer );
                        $sidebarResultsWidget = new InterwikiSearchResultSetWidget(
                                $this,
@@ -436,9 +435,17 @@ class SpecialSearch extends SpecialPage {
 
                // 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
@@ -548,7 +555,7 @@ class SpecialSearch extends SpecialPage {
         * Extract "power search" namespace settings from the request object,
         * returning a list of index numbers to search.
         *
-        * @param WebRequest $request
+        * @param WebRequest &$request
         * @return array
         */
        protected function powerSearch( &$request ) {