* (bug 20049) Fixed in PHP notice in search highlighter that occurs in some cases
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 6 Apr 2010 09:08:22 +0000 (09:08 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 6 Apr 2010 09:08:22 +0000 (09:08 +0000)
Please correct this if this is not the correct way to do it :)

RELEASE-NOTES
includes/search/SearchEngine.php

index 4130f2f..910872f 100644 (file)
@@ -85,6 +85,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   parameter no longer makes the page displayed as being the redirect target
 * (bug 22918) Feed cache keys now use $wgRenderHashAppend
 * (bug 21916) Last-Modified header is now correct when outputting cached feed
+* (bug 20049) Fixed in PHP notice in search highlighter that occurs in some
+  cases
 
 === API changes in 1.17 ===
 * (bug 22738) Allow filtering by action type on query=logevent
index 28a85ae..b8db2ec 100644 (file)
@@ -934,12 +934,14 @@ class SearchHighlighter {
 
                // add extra chars to each snippet to make snippets constant size
                $extended = array();
-               if( count( $snippets ) == 0){
+               if( count( $snippets ) == 0 ){
                        // couldn't find the target words, just show beginning of article
-                       $targetchars = $contextchars * $contextlines;
-                       $snippets[$first] = '';
-                       $offsets[$first] = 0;
-               } else{
+                       if ( array_key_exists( $first, $all ) ) {
+                               $targetchars = $contextchars * $contextlines;
+                               $snippets[$first] = '';
+                               $offsets[$first] = 0;
+                       }
+               } else {
                        // if begin of the article contains the whole phrase, show only that !!
                        if( array_key_exists($first,$snippets) && preg_match($pat1,$snippets[$first])
                            && $offsets[$first] < $contextchars * 2 ){