Merge "[search] Don't show the create link twice on results page"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 8 Nov 2016 18:36:57 +0000 (18:36 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 8 Nov 2016 18:36:57 +0000 (18:36 +0000)
1  2 
includes/specials/SpecialSearch.php

@@@ -234,6 -234,11 +234,6 @@@ class SpecialSearch extends SpecialPag
  
                        return;
                }
 -              # No match, generate an edit URL
 -              $title = Title::newFromText( $term );
 -              if ( !is_null( $title ) ) {
 -                      Hooks::run( 'SpecialSearchNogomatch', [ &$title ] );
 -              }
                $this->showResults( $term );
        }
  
                                $out->addHTML( '<div class="error">' .
                                        $textStatus->getMessage( 'search-error' ) . '</div>' );
                        } else {
-                               $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
+                               if ( !$this->offset ) {
+                                       // If we have an offset the create link was rendered earlier in this function.
+                                       // This class needs a good de-spaghettification, but for now this will
+                                       // do the job.
+                                       $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
+                               }
                                $out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>",
                                        [ $hasOtherResults ? 'search-nonefound-thiswiki' : 'search-nonefound',
                                                        wfEscapeWikiText( $term )
                $out->addHTML( "</div>" );
  
                Hooks::run( 'SpecialSearchResultsAppend', [ $this, $out, $term ] );
 -
        }
  
        /**
                return "<p class=\"mw-search-interwiki-header mw-search-visualclear\">\n$wikiMsg</p>";
        }
  
 -      /**
 -       * Decide if the suggested query should be run, and it's results returned
 -       * instead of the provided $textMatches
 -       *
 -       * @param SearchResultSet $textMatches The results of a users query
 -       * @return bool
 -       */
 -      protected function shouldRunSuggestedQuery( SearchResultSet $textMatches ) {
 -              if ( !$this->runSuggestion ||
 -                      !$textMatches->hasSuggestion() ||
 -                      $textMatches->numRows() > 0 ||
 -                      $textMatches->searchContainedSyntax()
 -              ) {
 -                      return false;
 -              }
 -
 -              return $this->getConfig()->get( 'SearchRunSuggestedQuery' );
 -      }
 -
        /**
         * Generates HTML shown to the user when we have a suggestion about a query
         * that might give more results than their current query.
         * @return string
         */
        protected function showHit( SearchResult $result, $terms, $position ) {
 -
                if ( $result->isBrokenTitle() ) {
                        return '';
                }
         * @return string
         */
        protected function showInterwikiHit( $result, $lastInterwiki, $query ) {
 -
                if ( $result->isBrokenTitle() ) {
                        return '';
                }
                return false;
        }
  
 -      /**
 -       * Check if query starts with all: prefix
 -       *
 -       * @param string $term The string to check
 -       * @return bool
 -       */
 -      protected function startsWithAll( $term ) {
 -
 -              $allkeyword = $this->msg( 'searchall' )->inContentLanguage()->text();
 -
 -              $parts = explode( ':', $term );
 -              if ( count( $parts ) > 1 ) {
 -                      return $parts[0] == $allkeyword;
 -              }
 -
 -              return false;
 -      }
 -
        /**
         * @since 1.18
         *