
maxsem at svn
Nov 4, 2009, 7:18 AM
Post #1 of 1
(31 views)
Permalink
|
|
SVN: [58548] trunk/phase3
|
|
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/58548 Revision: 58548 Author: maxsem Date: 2009-11-04 15:18:30 +0000 (Wed, 04 Nov 2009) Log Message: ----------- (bug 18609) Search index was empty for some pages Modified Paths: -------------- trunk/phase3/RELEASE-NOTES trunk/phase3/includes/search/SearchUpdate.php Added Paths: ----------- trunk/phase3/t/DatabaseMock.inc trunk/phase3/t/inc/SearchUpdate.t Modified: trunk/phase3/RELEASE-NOTES =================================================================== --- trunk/phase3/RELEASE-NOTES 2009-11-04 14:36:26 UTC (rev 58547) +++ trunk/phase3/RELEASE-NOTES 2009-11-04 15:18:30 UTC (rev 58548) @@ -619,6 +619,7 @@ * 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 == Modified: trunk/phase3/includes/search/SearchUpdate.php =================================================================== --- trunk/phase3/includes/search/SearchUpdate.php 2009-11-04 14:36:26 UTC (rev 58547) +++ trunk/phase3/includes/search/SearchUpdate.php 2009-11-04 15:18:30 UTC (rev 58548) @@ -46,7 +46,7 @@ $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 Added: trunk/phase3/t/DatabaseMock.inc =================================================================== --- trunk/phase3/t/DatabaseMock.inc (rev 0) +++ trunk/phase3/t/DatabaseMock.inc 2009-11-04 15:18:30 UTC (rev 58548) @@ -0,0 +1,33 @@ +<?php +/** + * Mock database class for tests, does nothing. + * Include after LocalSettings.php + */ + +$wgDBtype = 'mock'; + +class DatabaseMock extends DatabaseBase { + function __construct( $server = false, $user = false, $password = false, $dbName = false, + $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) + { + $this->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 Property changes on: trunk/phase3/t/DatabaseMock.inc ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/phase3/t/inc/SearchUpdate.t =================================================================== --- trunk/phase3/t/inc/SearchUpdate.t (rev 0) +++ trunk/phase3/t/inc/SearchUpdate.t 2009-11-04 15:18:30 UTC (rev 58548) @@ -0,0 +1,61 @@ +#!/usr/bin/env php +<?php + +require 't/Test.php'; + +plan( 4 ); + +define( 'MEDIAWIKI', 1 ); +require 'includes/Defines.php'; +require 'includes/ProfilerStub.php'; +require 'includes/AutoLoader.php'; +require 'LocalSettings.php'; + +require 't/DatabaseMock.inc'; + +$wgSearchType = 'MockSearch'; + +require 'includes/Setup.php'; + + +class MockSearch extends SearchEngine { + public static $id; + public static $title; + public static $text; + + public function __construct( $db ) { + } + + public function update( $id, $title, $text ) { + self::$id = $id; + self::$title = $title; + self::$text = $text; + } +} + +function update( $text, $title = 'Test', $id = 1 ) { + $u = new SearchUpdate( $id, $title, $text ); + $u->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( '<div>TeSt</div>' ), 'test', 'HTML stripped, text lowercased' ); + +is( updateText( <<<EOT +<table style="color:red; font-size:100px"> + <tr class="scary"><td><div>foo</div></td><tr>bar</td></tr> + <tr><td>boz</td><tr>quux</td></tr> +</table> +EOT +), 'foo bar boz quux', 'Stripping HTML tables' ); + +is( updateText( 'a > b' ), 'a b', 'Handle unclosed tags' ); + +$text = str_pad( "foo <barbarbar \n", 10000, 'x' ); +ok( updateText( $text ) != '', 'Bug 18609' ); \ No newline at end of file _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS[at]lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|