From: Max Semenik Date: Wed, 4 Nov 2009 15:18:30 +0000 (+0000) Subject: (bug 18609) Search index was empty for some pages X-Git-Tag: 1.31.0-rc.0~38977 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=b86085163121be5469fa42530b81f2b8ea362591;p=lhc%2Fweb%2Fwiklou.git (bug 18609) Search index was empty for some pages --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8c10923d02..a2316d23f5 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -619,6 +619,7 @@ Hopefully we will remove this configuration var soon) * Removed section edit links in edit conflict form * Allow SpecialActiveusers to work on non-MySQL databases * (bug 6579) Fixed protecting images from uploading only +* (bug 18609) Search index was empty for some pages == API changes in 1.16 == diff --git a/includes/search/SearchUpdate.php b/includes/search/SearchUpdate.php index edf2bcbb31..b9c2335151 100644 --- a/includes/search/SearchUpdate.php +++ b/includes/search/SearchUpdate.php @@ -46,7 +46,7 @@ class SearchUpdate { $text = $wgContLang->stripForSearch( $this->mText ); wfProfileIn( $fname.'-regexps' ); - $text = preg_replace( "/<\\/?\\s*[A-Za-z][A-Za-z0-9]*\\s*([^>]*?)>/", + $text = preg_replace( "/<\\/?\\s*[A-Za-z][^>]*?>/", ' ', $wgContLang->lc( " " . $text . " " ) ); # Strip HTML markup $text = preg_replace( "/(^|\\n)==\\s*([^\\n]+)\\s*==(\\s)/sD", "\\1\\2 \\2 \\2\\3", $text ); # Emphasize headings diff --git a/t/DatabaseMock.inc b/t/DatabaseMock.inc new file mode 100644 index 0000000000..59d380f5b0 --- /dev/null +++ b/t/DatabaseMock.inc @@ -0,0 +1,33 @@ +mConn = true; + $this->mOpened = true; + } + + function open( $server, $user, $password, $dbName ) { return true; } + function doQuery( $sql ) {} + function fetchObject( $res ) {} + function fetchRow( $res ) {} + function numRows( $res ) {} + function numFields( $res ) {} + function fieldName( $res, $n ) {} + function insertId() {} + function dataSeek( $res, $row ) {} + function lastErrno() { return 0; } + function lastError() { return ''; } + function affectedRows() {} + function fieldInfo( $table, $field ) {} + function strencode( $s ) {} + function getSoftwareLink() {} + function getServerVersion() {} +} \ No newline at end of file diff --git a/t/inc/SearchUpdate.t b/t/inc/SearchUpdate.t new file mode 100644 index 0000000000..da061f7c02 --- /dev/null +++ b/t/inc/SearchUpdate.t @@ -0,0 +1,61 @@ +#!/usr/bin/env php +doUpdate(); + return array( MockSearch::$title, MockSearch::$text ); +} + +function updateText( $text ) { + list( $title, $resultText ) = update( $text ); + $resultText = trim( $resultText ); // abstract from some implementation details + return $resultText; +} + +is( updateText( '
TeSt
' ), 'test', 'HTML stripped, text lowercased' ); + +is( updateText( << +
foo
bar + bozquux + +EOT +), 'foo bar boz quux', 'Stripping HTML tables' ); + +is( updateText( 'a > b' ), 'a b', 'Handle unclosed tags' ); + +$text = str_pad( "foo