Revision: 51574 Author: siebrand Date: 2009-06-07 19:49:56 +0000 (Sun, 07 Jun 2009)
Log Message: ----------- 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? Modified Paths: -------------- trunk/phase3/includes/specials/SpecialSearch.php Modified: trunk/phase3/includes/specials/SpecialSearch.php =================================================================== --- trunk/phase3/includes/specials/SpecialSearch.php 2009-06-07 19:08:06 UTC (rev 51573) +++ trunk/phase3/includes/specials/SpecialSearch.php 2009-06-07 19:49:56 UTC (rev 51574) @@ -177,9 +177,14 @@ $this->powerSearchOptions() ); + $suggestionSnippet = $textMatches->getSuggestionSnippet(); + + if( $suggestionSnippet == '' ) + $suggestionSnippet = null; + $suggestLink = $sk->linkKnown( $st, - $textMatches->getSuggestionSnippet(), + $suggestionSnippet, array(), $stParams ); @@ -413,9 +418,14 @@ $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 @@ $sectionText = $result->getSectionSnippet($terms); $redirect = ''; - if( !is_null($redirectTitle) ) + if( !is_null($redirectTitle) ) { + if( $redirectText == '' ) + $redirectText = null; + $redirect = "<span class='searchalttitle'>" . wfMsg( 'search-redirect', @@ -451,10 +464,15 @@ ) ) . "</span>"; + } $section = ''; - if( !is_null($sectionTitle) ) + + if( !is_null($sectionTitle) ) { + if( $sectionText == '' ) + $sectionText = null; + $section = "<span class='searchalttitle'>" . wfMsg( 'search-section', $this->sk->linkKnown( @@ -463,6 +481,7 @@ ) ) . "</span>"; + } // format text extract $extract = "<div class='searchresult'>".$result->getTextSnippet($terms)."</div>"; @@ -603,16 +622,24 @@ $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 = "<span class='searchalttitle'>" . wfMsg( 'search-redirect', @@ -622,6 +649,7 @@ ) ) . "</span>"; + } $out = ""; // display project name @@ -1041,9 +1069,14 @@ $this->powerSearchOptions() ); + $suggestionSnippet = $textMatches->getSuggestionSnippet(); + + if( $suggestionSnippet ) + $suggestionSnippet = null; + $suggestLink = $sk->linkKnown( $st, - $textMatches->getSuggestionSnippet(), + $suggestionSnippet, array(), $stParams ); @@ -1273,9 +1306,14 @@ $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 @@ $sectionTitle = $result->getSectionTitle(); $sectionText = $result->getSectionSnippet($terms); $redirect = ''; - if( !is_null($redirectTitle) ) + if( !is_null($redirectTitle) ) { + if( $redirectText == '' ) + $redirectText = null; + $redirect = "<span class='searchalttitle'>" . wfMsg( 'search-redirect', @@ -1311,8 +1352,14 @@ ) ) . "</span>"; + } + $section = ''; - if( !is_null($sectionTitle) ) + + if( !is_null($sectionTitle) ) { + if( $sectionText == '' ) + $sectionText = null; + $section = "<span class='searchalttitle'>" . wfMsg( 'search-section', @@ -1322,6 +1369,7 @@ ) ) . "</span>"; + } // format text extract $extract = "<div class='searchresult'>".$result->getTextSnippet($terms)."</div>"; @@ -1463,16 +1511,24 @@ $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 = "<span class='searchalttitle'>" . wfMsg( 'search-redirect', @@ -1482,6 +1538,7 @@ ) ) . "</span>"; + } $out = ""; // display project name _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs