[search] Don't show the create link twice on results page
authorErik Bernhardson <ebernhardson@wikimedia.org>
Mon, 7 Nov 2016 21:49:09 +0000 (13:49 -0800)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Mon, 7 Nov 2016 22:00:21 +0000 (14:00 -0800)
Due to how things flow through the rendering if an offset is provided
and there are no results, SpecialSearch::showCreateLink gets run twice
and the user gets an odd output.

Bug: T149269
Change-Id: Ifed921207f82cc0d1c1cb621a81127486d4dd03e

includes/specials/SpecialSearch.php

index 6daf19f..ef514c7 100644 (file)
@@ -422,7 +422,12 @@ class SpecialSearch extends SpecialPage {
                                $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 )