From 2000cf05c117fdddce5255b6faef37756d767c49 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sun, 7 Jun 2009 19:49:56 +0000 Subject: [PATCH] Follow-up to r51572. SpecialSearch.php was a bit broken, because methods like getTitleSnippet() will return an empty string which is used as text in link() which fails, because link will only linkText( $title ) if text is null. P.s. could we change line 217 in Linker.php to something like "if( is_null( $text ) || $text == '' ) {" to work around this? --- includes/specials/SpecialSearch.php | 81 ++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 12 deletions(-) diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 0055495b76..7f19c26d59 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -177,9 +177,14 @@ class SpecialSearch { $this->powerSearchOptions() ); + $suggestionSnippet = $textMatches->getSuggestionSnippet(); + + if( $suggestionSnippet == '' ) + $suggestionSnippet = null; + $suggestLink = $sk->linkKnown( $st, - $textMatches->getSuggestionSnippet(), + $suggestionSnippet, array(), $stParams ); @@ -413,9 +418,14 @@ class SpecialSearch { $sk = $wgUser->getSkin(); $t = $result->getTitle(); + $titleSnippet = $result->getTitleSnippet($terms); + + if( $titleSnippet == '' ) + $titleSnippet = null; + $link = $this->sk->linkKnown( $t, - $result->getTitleSnippet($terms) + $titleSnippet ); //If page content is not readable, just return the title. @@ -441,7 +451,10 @@ class SpecialSearch { $sectionText = $result->getSectionSnippet($terms); $redirect = ''; - if( !is_null($redirectTitle) ) + if( !is_null($redirectTitle) ) { + if( $redirectText == '' ) + $redirectText = null; + $redirect = "" . wfMsg( 'search-redirect', @@ -451,10 +464,15 @@ class SpecialSearch { ) ) . ""; + } $section = ''; - if( !is_null($sectionTitle) ) + + if( !is_null($sectionTitle) ) { + if( $sectionText == '' ) + $sectionText = null; + $section = "" . wfMsg( 'search-section', $this->sk->linkKnown( @@ -463,6 +481,7 @@ class SpecialSearch { ) ) . ""; + } // format text extract $extract = "
".$result->getTextSnippet($terms)."
"; @@ -603,16 +622,24 @@ class SpecialSearch { $t = $result->getTitle(); + $titleSnippet = $result->getTitleSnippet($terms); + + if( $titleSnippet == '' ) + $titleSnippet = null; + $link = $this->sk->linkKnown( $t, - $result->getTitleSnippet($terms) + $titleSnippet ); // format redirect if any $redirectTitle = $result->getRedirectTitle(); $redirectText = $result->getRedirectSnippet($terms); $redirect = ''; - if( !is_null($redirectTitle) ) + if( !is_null($redirectTitle) ) { + if( $redirectText == '' ) + $redirectText = null; + $redirect = "" . wfMsg( 'search-redirect', @@ -622,6 +649,7 @@ class SpecialSearch { ) ) . ""; + } $out = ""; // display project name @@ -1041,9 +1069,14 @@ class SpecialSearchOld { $this->powerSearchOptions() ); + $suggestionSnippet = $textMatches->getSuggestionSnippet(); + + if( $suggestionSnippet ) + $suggestionSnippet = null; + $suggestLink = $sk->linkKnown( $st, - $textMatches->getSuggestionSnippet(), + $suggestionSnippet, array(), $stParams ); @@ -1273,9 +1306,14 @@ class SpecialSearchOld { $t = $result->getTitle(); $sk = $wgUser->getSkin(); + $titleSnippet = $result->getTitleSnippet($terms); + + if( $titleSnippet == '' ) + $titleSnippet = null; + $link = $sk->linkKnown( $t, - $result->getTitleSnippet($terms) + $titleSnippet ); //If page content is not readable, just return the title. @@ -1301,7 +1339,10 @@ class SpecialSearchOld { $sectionTitle = $result->getSectionTitle(); $sectionText = $result->getSectionSnippet($terms); $redirect = ''; - if( !is_null($redirectTitle) ) + if( !is_null($redirectTitle) ) { + if( $redirectText == '' ) + $redirectText = null; + $redirect = "" . wfMsg( 'search-redirect', @@ -1311,8 +1352,14 @@ class SpecialSearchOld { ) ) . ""; + } + $section = ''; - if( !is_null($sectionTitle) ) + + if( !is_null($sectionTitle) ) { + if( $sectionText == '' ) + $sectionText = null; + $section = "" . wfMsg( 'search-section', @@ -1322,6 +1369,7 @@ class SpecialSearchOld { ) ) . ""; + } // format text extract $extract = "
".$result->getTextSnippet($terms)."
"; @@ -1463,16 +1511,24 @@ class SpecialSearchOld { $t = $result->getTitle(); $sk = $wgUser->getSkin(); + $titleSnippet = $result->getTitleSnippet($terms); + + if( $titleSnippet == '' ) + $titleSnippet = null; + $link = $sk->linkKnown( $t, - $result->getTitleSnippet( $terms ) + $titleSnippet ); // format redirect if any $redirectTitle = $result->getRedirectTitle(); $redirectText = $result->getRedirectSnippet($terms); $redirect = ''; - if( !is_null($redirectTitle) ) + if( !is_null($redirectTitle) ) { + if( $redirectText == '' ) + $redirectText = null; + $redirect = "" . wfMsg( 'search-redirect', @@ -1482,6 +1538,7 @@ class SpecialSearchOld { ) ) . ""; + } $out = ""; // display project name -- 2.20.1