"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "includes/search/SearchDatabase.php" between
mediawiki-1.31.1.tar.gz and mediawiki-1.32.0.tar.gz

About: MediaWiki is a wiki engine (the collaborative editing software that runs for e.g. Wikipedia, the free encyclopedia).

SearchDatabase.php  (mediawiki-1.31.1):SearchDatabase.php  (mediawiki-1.32.0)
skipping to change at line 31 skipping to change at line 31
* @ingroup Search * @ingroup Search
*/ */
use Wikimedia\Rdbms\IDatabase; use Wikimedia\Rdbms\IDatabase;
/** /**
* Base search engine base class for database-backed searches * Base search engine base class for database-backed searches
* @ingroup Search * @ingroup Search
* @since 1.23 * @since 1.23
*/ */
class SearchDatabase extends SearchEngine { abstract class SearchDatabase extends SearchEngine {
/** /**
* @var IDatabase Slave database for reading from for results * @var IDatabase Slave database for reading from for results
*/ */
protected $db; protected $db;
/** /**
* @param IDatabase $db The database to search from * @param IDatabase|null $db The database to search from
*/ */
public function __construct( IDatabase $db = null ) { public function __construct( IDatabase $db = null ) {
if ( $db ) { if ( $db ) {
$this->db = $db; $this->db = $db;
} else { } else {
$this->db = wfGetDB( DB_REPLICA ); $this->db = wfGetDB( DB_REPLICA );
} }
} }
/** /**
* @param string $term
* @return SearchResultSet|Status|null
*/
final public function doSearchText( $term ) {
return $this->doSearchTextInDB( $this->extractNamespacePrefix( $t
erm ) );
}
/**
* Perform a full text search query and return a result set.
*
* @param string $term Raw search term
* @return SqlSearchResultSet
*/
abstract protected function doSearchTextInDB( $term );
/**
* @param string $term
* @return SearchResultSet|null
*/
final public function doSearchTitle( $term ) {
return $this->doSearchTitleInDB( $this->extractNamespacePrefix( $
term ) );
}
/**
* Perform a title-only search query and return a result set.
*
* @param string $term Raw search term
* @return SqlSearchResultSet
*/
abstract protected function doSearchTitleInDB( $term );
/**
* Return a 'cleaned up' search string * Return a 'cleaned up' search string
* *
* @param string $text * @param string $text
* @return string * @return string
*/ */
protected function filter( $text ) { protected function filter( $text ) {
// List of chars allowed in the search query. // List of chars allowed in the search query.
// This must include chars used in the search syntax. // This must include chars used in the search syntax.
// Usually " (phrase) or * (wildcards) if supported by the engine // Usually " (phrase) or * (wildcards) if supported by the engine
$lc = $this->legalSearchChars( self::CHARS_ALL ); $lc = $this->legalSearchChars( self::CHARS_ALL );
return trim( preg_replace( "/[^{$lc}]/", " ", $text ) ); return trim( preg_replace( "/[^{$lc}]/", " ", $text ) );
} }
/**
* Extract the optional namespace prefix and set self::namespaces
* accordingly and return the query string
* @param string $term
* @return string the query string without any namespace prefix
*/
final protected function extractNamespacePrefix( $term ) {
$queryAndNs = self::parseNamespacePrefixes( $term );
if ( $queryAndNs === false ) {
return $term;
}
$this->namespaces = $queryAndNs[1];
return $queryAndNs[0];
}
} }
 End of changes. 4 change blocks. 
2 lines changed or deleted 51 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)