Merge "Don't offer create link for searches with syntax"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 5 Feb 2014 17:59:14 +0000 (17:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 5 Feb 2014 17:59:14 +0000 (17:59 +0000)
1  2 
includes/specials/SpecialSearch.php

@@@ -199,7 -199,7 +199,7 @@@ class SpecialSearch extends SpecialPag
                if ( !is_null( $t ) ) {
                        global $wgGoToEdit;
                        wfRunHooks( 'SpecialSearchNogomatch', array( &$t ) );
 -                      wfDebugLog( 'nogomatch', $t->getText(), false );
 +                      wfDebugLog( 'nogomatch', $t->getText(), 'private' );
  
                        # If the feature is enabled, go straight to the edit page
                        if ( $wgGoToEdit ) {
                // prev/next links
                if ( $num || $this->offset ) {
                        // Show the create link ahead
-                       $this->showCreateLink( $t, $num );
+                       $this->showCreateLink( $t, $num, $titleMatches, $textMatches );
                        $prevnext = $this->getLanguage()->viewPrevNext( $this->getPageTitle(), $this->offset, $this->limit,
                                $this->powerSearchOptions() + array( 'search' => $term ),
                                max( $titleMatchesNum, $textMatchesNum ) < $this->limit
                        } else {
                                $out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>",
                                        array( 'search-nonefound', wfEscapeWikiText( $term ) ) );
-                               $this->showCreateLink( $t, $num );
+                               $this->showCreateLink( $t, $num, $titleMatches, $textMatches );
                        }
                }
                $out->addHtml( "</div>" );
        /**
         * @param $t Title
         * @param int $num The number of search results found
+        * @param $titleMatches null|SearchResultSet results from title search
+        * @param $textMatches null|SearchResultSet results from text search
         */
-       protected function showCreateLink( $t, $num ) {
+       protected function showCreateLink( $t, $num, $titleMatches, $textMatches ) {
                // show direct page/create link if applicable
  
                // Check DBkey !== '' in case of fragment link only.
-               if ( is_null( $t ) || $t->getDBkey() === '' ) {
+               if ( is_null( $t ) || $t->getDBkey() === '' ||
+                               ( $titleMatches !== null && $titleMatches->searchContainedSyntax() ) ||
+                               ( $textMatches !== null && $textMatches->searchContainedSyntax() ) ) {
                        // invalid title
                        // preserve the paragraph for margins etc...
                        $this->getOutput()->addHtml( '<p></p>' );