From: Alexandre Emsenhuber Date: Tue, 6 Apr 2010 09:08:22 +0000 (+0000) Subject: * (bug 20049) Fixed in PHP notice in search highlighter that occurs in some cases X-Git-Tag: 1.31.0-rc.0~37240 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=5bcf51aff08406cc1ffe2b6f97dcb196ae22c400;p=lhc%2Fweb%2Fwiklou.git * (bug 20049) Fixed in PHP notice in search highlighter that occurs in some cases Please correct this if this is not the correct way to do it :) --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 4130f2f598..910872fadd 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 28a85ae2ad..b8db2ec349 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -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 ){