r51574 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51573‎ | r51574 | r51575 >
Date:19:49, 7 June 2009
Author:siebrand
Status:ok
Tags:
Comment:
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) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -177,9 +177,14 @@
178178 $this->powerSearchOptions()
179179 );
180180
 181+ $suggestionSnippet = $textMatches->getSuggestionSnippet();
 182+
 183+ if( $suggestionSnippet == '' )
 184+ $suggestionSnippet = null;
 185+
181186 $suggestLink = $sk->linkKnown(
182187 $st,
183 - $textMatches->getSuggestionSnippet(),
 188+ $suggestionSnippet,
184189 array(),
185190 $stParams
186191 );
@@ -413,9 +418,14 @@
414419 $sk = $wgUser->getSkin();
415420 $t = $result->getTitle();
416421
 422+ $titleSnippet = $result->getTitleSnippet($terms);
 423+
 424+ if( $titleSnippet == '' )
 425+ $titleSnippet = null;
 426+
417427 $link = $this->sk->linkKnown(
418428 $t,
419 - $result->getTitleSnippet($terms)
 429+ $titleSnippet
420430 );
421431
422432 //If page content is not readable, just return the title.
@@ -441,7 +451,10 @@
442452 $sectionText = $result->getSectionSnippet($terms);
443453 $redirect = '';
444454
445 - if( !is_null($redirectTitle) )
 455+ if( !is_null($redirectTitle) ) {
 456+ if( $redirectText == '' )
 457+ $redirectText = null;
 458+
446459 $redirect = "<span class='searchalttitle'>" .
447460 wfMsg(
448461 'search-redirect',
@@ -451,10 +464,15 @@
452465 )
453466 ) .
454467 "</span>";
 468+ }
455469
456470 $section = '';
457471
458 - if( !is_null($sectionTitle) )
 472+
 473+ if( !is_null($sectionTitle) ) {
 474+ if( $sectionText == '' )
 475+ $sectionText = null;
 476+
459477 $section = "<span class='searchalttitle'>" .
460478 wfMsg(
461479 'search-section', $this->sk->linkKnown(
@@ -463,6 +481,7 @@
464482 )
465483 ) .
466484 "</span>";
 485+ }
467486
468487 // format text extract
469488 $extract = "<div class='searchresult'>".$result->getTextSnippet($terms)."</div>";
@@ -603,16 +622,24 @@
604623
605624 $t = $result->getTitle();
606625
 626+ $titleSnippet = $result->getTitleSnippet($terms);
 627+
 628+ if( $titleSnippet == '' )
 629+ $titleSnippet = null;
 630+
607631 $link = $this->sk->linkKnown(
608632 $t,
609 - $result->getTitleSnippet($terms)
 633+ $titleSnippet
610634 );
611635
612636 // format redirect if any
613637 $redirectTitle = $result->getRedirectTitle();
614638 $redirectText = $result->getRedirectSnippet($terms);
615639 $redirect = '';
616 - if( !is_null($redirectTitle) )
 640+ if( !is_null($redirectTitle) ) {
 641+ if( $redirectText == '' )
 642+ $redirectText = null;
 643+
617644 $redirect = "<span class='searchalttitle'>" .
618645 wfMsg(
619646 'search-redirect',
@@ -622,6 +649,7 @@
623650 )
624651 ) .
625652 "</span>";
 653+ }
626654
627655 $out = "";
628656 // display project name
@@ -1041,9 +1069,14 @@
10421070 $this->powerSearchOptions()
10431071 );
10441072
 1073+ $suggestionSnippet = $textMatches->getSuggestionSnippet();
 1074+
 1075+ if( $suggestionSnippet )
 1076+ $suggestionSnippet = null;
 1077+
10451078 $suggestLink = $sk->linkKnown(
10461079 $st,
1047 - $textMatches->getSuggestionSnippet(),
 1080+ $suggestionSnippet,
10481081 array(),
10491082 $stParams
10501083 );
@@ -1273,9 +1306,14 @@
12741307 $t = $result->getTitle();
12751308 $sk = $wgUser->getSkin();
12761309
 1310+ $titleSnippet = $result->getTitleSnippet($terms);
 1311+
 1312+ if( $titleSnippet == '' )
 1313+ $titleSnippet = null;
 1314+
12771315 $link = $sk->linkKnown(
12781316 $t,
1279 - $result->getTitleSnippet($terms)
 1317+ $titleSnippet
12801318 );
12811319
12821320 //If page content is not readable, just return the title.
@@ -1301,7 +1339,10 @@
13021340 $sectionTitle = $result->getSectionTitle();
13031341 $sectionText = $result->getSectionSnippet($terms);
13041342 $redirect = '';
1305 - if( !is_null($redirectTitle) )
 1343+ if( !is_null($redirectTitle) ) {
 1344+ if( $redirectText == '' )
 1345+ $redirectText = null;
 1346+
13061347 $redirect = "<span class='searchalttitle'>" .
13071348 wfMsg(
13081349 'search-redirect',
@@ -1311,8 +1352,14 @@
13121353 )
13131354 ) .
13141355 "</span>";
 1356+ }
 1357+
13151358 $section = '';
1316 - if( !is_null($sectionTitle) )
 1359+
 1360+ if( !is_null($sectionTitle) ) {
 1361+ if( $sectionText == '' )
 1362+ $sectionText = null;
 1363+
13171364 $section = "<span class='searchalttitle'>" .
13181365 wfMsg(
13191366 'search-section',
@@ -1322,6 +1369,7 @@
13231370 )
13241371 ) .
13251372 "</span>";
 1373+ }
13261374
13271375 // format text extract
13281376 $extract = "<div class='searchresult'>".$result->getTextSnippet($terms)."</div>";
@@ -1463,16 +1511,24 @@
14641512 $t = $result->getTitle();
14651513 $sk = $wgUser->getSkin();
14661514
 1515+ $titleSnippet = $result->getTitleSnippet($terms);
 1516+
 1517+ if( $titleSnippet == '' )
 1518+ $titleSnippet = null;
 1519+
14671520 $link = $sk->linkKnown(
14681521 $t,
1469 - $result->getTitleSnippet( $terms )
 1522+ $titleSnippet
14701523 );
14711524
14721525 // format redirect if any
14731526 $redirectTitle = $result->getRedirectTitle();
14741527 $redirectText = $result->getRedirectSnippet($terms);
14751528 $redirect = '';
1476 - if( !is_null($redirectTitle) )
 1529+ if( !is_null($redirectTitle) ) {
 1530+ if( $redirectText == '' )
 1531+ $redirectText = null;
 1532+
14771533 $redirect = "<span class='searchalttitle'>" .
14781534 wfMsg(
14791535 'search-redirect',
@@ -1482,6 +1538,7 @@
14831539 )
14841540 ) .
14851541 "</span>";
 1542+ }
14861543
14871544 $out = "";
14881545 // display project name

Follow-up revisions

RevisionCommit summaryAuthorDate
r51871Fix for r51574: did you mean.. links were broken, the original change seem to...rainman09:44, 15 June 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r51572* replace use of deprecated makeKnownLinkObj() by linkKnown() in core special...siebrand18:45, 7 June 2009

Status & tagging log