'MySQLSearchResultSet' => 'includes/search/SearchMySQL.php',
'PostgresSearchResult' => 'includes/search/SearchPostgres.php',
'PostgresSearchResultSet' => 'includes/search/SearchPostgres.php',
+ 'SearchDatabase' => 'includes/search/SearchDatabase.php',
'SearchEngine' => 'includes/search/SearchEngine.php',
'SearchEngineDummy' => 'includes/search/SearchEngine.php',
'SearchHighlighter' => 'includes/search/SearchEngine.php',
--- /dev/null
+<?php
+/**
+ * Database search engine
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Search
+ */
+
+/**
+ * Base search engine base class for database-backed searches
+ * @ingroup Search
+ * @since 1.23
+ */
+class SearchDatabase extends SearchEngine {
+ /**
+ * @var DatabaseBase Slave database for reading from for results
+ */
+ protected $db;
+
+ /**
+ * Constructor
+ * @param DatabaseBase $db The database to search from
+ */
+ public function __construct( DatabaseBase $db = null ) {
+ if ( $db ) {
+ $this->db = $db;
+ } else {
+ $this->db = wfGetDB( DB_SLAVE );
+ }
+ }
+}
/// Feature values
protected $features = array();
- /**
- * @var DatabaseBase
- */
- protected $db;
-
- function __construct( $db = null ) {
- if ( $db ) {
- $this->db = $db;
- } else {
- $this->db = wfGetDB( DB_SLAVE );
- }
- }
-
/**
* Perform a full text search query and return a result set.
* If title searches are not supported or disabled, return null.
* Search engine hook base class for Mssql (ConText).
* @ingroup Search
*/
-class SearchMssql extends SearchEngine {
-
- /**
- * Creates an instance of this class
- * @param $db DatabaseMssql: database object
- */
- function __construct( $db ) {
- parent::__construct( $db );
- }
-
+class SearchMssql extends SearchDatabase {
/**
* Perform a full text search query and return a result set.
*
* Search engine hook for MySQL 4+
* @ingroup Search
*/
-class SearchMySQL extends SearchEngine {
+class SearchMySQL extends SearchDatabase {
var $strictMatching = true;
static $mMinSearchLength;
- /**
- * Creates an instance of this class
- * @param $db DatabaseMysql: database object
- */
- function __construct( $db ) {
- parent::__construct( $db );
- }
-
/**
* Parse the user's query and transform it into an SQL fragment which will
* become part of a WHERE clause
* Search engine hook base class for Oracle (ConText).
* @ingroup Search
*/
-class SearchOracle extends SearchEngine {
+class SearchOracle extends SearchDatabase {
private $reservedWords = array(
'ABOUT' => 1,
'WITHIN' => 1,
);
- /**
- * Creates an instance of this class
- * @param $db DatabasePostgres: database object
- */
- function __construct( $db ) {
- parent::__construct( $db );
- }
-
/**
* Perform a full text search query and return a result set.
*
* Search engine hook base class for Postgres
* @ingroup Search
*/
-class SearchPostgres extends SearchEngine {
-
- /**
- * @var DatabasePostgres
- */
- protected $db;
- /**
- * Creates an instance of this class
- * @param $db DatabaseSqlite: database object
- */
- function __construct( $db ) {
- parent::__construct( $db );
- }
-
+class SearchPostgres extends SearchDatabase {
/**
* Perform a full text search query via tsearch2 and return a result set.
* Currently searches a page's current title (page.page_title) and
* Search engine hook for SQLite
* @ingroup Search
*/
-class SearchSqlite extends SearchEngine {
-
- /**
- * @var DatabaseSqlite
- */
- protected $db;
-
- /**
- * Creates an instance of this class
- * @param $db DatabaseSqlite: database object
- */
- function __construct( $db ) {
- parent::__construct( $db );
- }
-
+class SearchSqlite extends SearchDatabase {
/**
* Whether fulltext search is supported by current schema
* @return Boolean
class CollationTest extends MediaWikiLangTestCase {
protected function setUp() {
parent::setUp();
- if ( !extension_loaded( 'intl' ) ) {
- $this->markTestSkipped( 'These tests require intl extension' );
- }
+ $this->checkPHPExtension( 'intl' );
}
/**
protected function setUp() {
parent::setUp();
- if ( !extension_loaded( 'xdiff' ) ) {
- $this->markTestSkipped( 'The xdiff extension is not available' );
+ $this->checkPHPExtension( 'hash' );
+ $this->checkPHPExtension( 'xdiff' );
- return;
- }
if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
$this->markTestSkipped( 'The version of xdiff extension is lower than 1.5.0' );
- return;
- }
- if ( !extension_loaded( 'hash' ) ) {
- $this->markTestSkipped( 'The hash extension is not available' );
-
return;
}
}
* @covers BitmapMetadataHandler::Jpeg
*/
public function testMultilingualCascade() {
- if ( !extension_loaded( 'exif' ) ) {
- $this->markTestSkipped( "This test needs the exif extension." );
- }
- if ( !extension_loaded( 'xml' ) ) {
- $this->markTestSkipped( "This test needs the xml extension." );
- }
+ $this->checkPHPExtension( 'exif' );
+ $this->checkPHPExtension( 'xml' );
$this->setMwGlobals( 'wgShowEXIF', true );
protected function setUp() {
parent::setUp();
- if ( !extension_loaded( 'exif' ) ) {
- $this->markTestSkipped( "This test needs the exif extension." );
- }
+ $this->checkPHPExtension( 'exif' );
$this->setMwGlobals( 'wgShowEXIF', true );
protected function setUp() {
parent::setUp();
- if ( !extension_loaded( 'exif' ) ) {
- $this->markTestSkipped( "This test needs the exif extension." );
- }
+ $this->checkPHPExtension( 'exif' );
$this->handler = new BitmapHandler();
$filePath = __DIR__ . '/../../data/media';
protected function setUp() {
parent::setUp();
- if ( !extension_loaded( 'exif' ) ) {
- $this->markTestSkipped( "This test needs the exif extension." );
- }
+ $this->checkPHPExtension( 'exif' );
$this->mediaPath = __DIR__ . '/../../data/media/';
protected function setUp() {
parent::setUp();
- if ( !extension_loaded( 'exif' ) ) {
- $this->markTestSkipped( "This test needs the exif extension." );
- }
+ $this->checkPHPExtension( 'exif' );
$filePath = __DIR__ . '/../../data/media';
$this->backend = new FSFileBackend( array(
'name' => 'localtesting',
protected function setUp() {
parent::setUp();
- if ( !extension_loaded( 'exif' ) ) {
- $this->markTestSkipped( "This test needs the exif extension." );
- }
+ $this->checkPHPExtension( 'exif' );
$this->filePath = __DIR__ . '/../../data/media/';
protected function setUp() {
parent::setUp();
- if ( !extension_loaded( 'exif' ) ) {
- $this->markTestSkipped( "This test needs the exif extension." );
- }
+ $this->checkPHPExtension( 'exif' );
$this->setMwGlobals( 'wgShowEXIF', true );
protected function setUp() {
parent::setUp();
- if ( !extension_loaded( 'xml' ) ) {
- $this->markTestSkipped( 'Requires libxml to do XMP parsing' );
- }
+ $this->checkPHPExtension( 'exif' ); # Requires libxml to do XMP parsing
}
/**