(bug 18609) Search index was empty for some pages
This commit is contained in:
parent
37a8e9a147
commit
b860851631
4 changed files with 96 additions and 1 deletions
|
|
@ -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 ==
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
33
t/DatabaseMock.inc
Normal file
33
t/DatabaseMock.inc
Normal file
|
|
@ -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() {}
|
||||
}
|
||||
61
t/inc/SearchUpdate.t
Normal file
61
t/inc/SearchUpdate.t
Normal file
|
|
@ -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' );
|
||||
Loading…
Reference in a new issue