Merge "Don't pass $this by reference to SkinVectorStyleModules hook."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 23 Jan 2014 23:44:28 +0000 (23:44 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 23 Jan 2014 23:44:28 +0000 (23:44 +0000)
18 files changed:
includes/AutoLoader.php
includes/search/SearchDatabase.php [new file with mode: 0644]
includes/search/SearchEngine.php
includes/search/SearchMssql.php
includes/search/SearchMySQL.php
includes/search/SearchOracle.php
includes/search/SearchPostgres.php
includes/search/SearchSqlite.php
tests/phpunit/includes/CollationTest.php
tests/phpunit/includes/DiffHistoryBlobTest.php
tests/phpunit/includes/media/BitmapMetadataHandlerTest.php
tests/phpunit/includes/media/ExifBitmapTest.php
tests/phpunit/includes/media/ExifRotationTest.php
tests/phpunit/includes/media/ExifTest.php
tests/phpunit/includes/media/FormatMetadataTest.php
tests/phpunit/includes/media/JpegTest.php
tests/phpunit/includes/media/TiffTest.php
tests/phpunit/includes/media/XMPTest.php

index 6d65a82..07c89ed 100644 (file)
@@ -880,6 +880,7 @@ $wgAutoloadLocalClasses = array(
        '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',
diff --git a/includes/search/SearchDatabase.php b/includes/search/SearchDatabase.php
new file mode 100644 (file)
index 0000000..e3aafe8
--- /dev/null
@@ -0,0 +1,46 @@
+<?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 );
+               }
+       }
+}
index e3a10ab..33fcd8c 100644 (file)
@@ -41,19 +41,6 @@ class SearchEngine {
        /// 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.
index cbc1a7a..15b5f1c 100644 (file)
  * 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.
         *
index b2bc1c2..aec6a01 100644 (file)
  * 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
index a847965..cea17d2 100644 (file)
@@ -28,7 +28,7 @@
  * Search engine hook base class for Oracle (ConText).
  * @ingroup Search
  */
-class SearchOracle extends SearchEngine {
+class SearchOracle extends SearchDatabase {
 
        private $reservedWords = array(
                'ABOUT' => 1,
@@ -59,14 +59,6 @@ class SearchOracle extends SearchEngine {
                '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.
         *
index 7f19ed1..c9f5466 100644 (file)
  * 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
index 554181f..ebff68e 100644 (file)
  * 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
index c6a7169..213e610 100644 (file)
@@ -10,9 +10,7 @@
 class CollationTest extends MediaWikiLangTestCase {
        protected function setUp() {
                parent::setUp();
-               if ( !extension_loaded( 'intl' ) ) {
-                       $this->markTestSkipped( 'These tests require intl extension' );
-               }
+               $this->checkPHPExtension( 'intl' );
        }
 
        /**
index 0b04c6e..e28a92c 100644 (file)
@@ -5,19 +5,12 @@ class DiffHistoryBlobTest extends MediaWikiTestCase {
        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;
                }
        }
index a0e63a8..8402522 100644 (file)
@@ -19,12 +19,8 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
         * @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 );
 
index a2e0eb6..fb3e40e 100644 (file)
@@ -9,9 +9,7 @@ class ExifBitmapTest extends MediaWikiTestCase {
 
        protected function setUp() {
                parent::setUp();
-               if ( !extension_loaded( 'exif' ) ) {
-                       $this->markTestSkipped( "This test needs the exif extension." );
-               }
+               $this->checkPHPExtension( 'exif' );
 
                $this->setMwGlobals( 'wgShowEXIF', true );
 
index 118dc85..3cfbf1a 100644 (file)
@@ -10,9 +10,7 @@ class ExifRotationTest extends MediaWikiTestCase {
 
        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';
index 667c078..735663c 100644 (file)
@@ -10,9 +10,7 @@ class ExifTest extends MediaWikiTestCase {
 
        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/';
 
index 44d8f00..605dfa8 100644 (file)
@@ -10,9 +10,7 @@ class FormatMetadataTest extends MediaWikiTestCase {
        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',
index a5bf1dc..1b28de1 100644 (file)
@@ -8,9 +8,7 @@ class JpegTest extends MediaWikiTestCase {
 
        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/';
 
index 8d74b98..ca97698 100644 (file)
@@ -8,9 +8,7 @@ class TiffTest extends MediaWikiTestCase {
 
        protected function setUp() {
                parent::setUp();
-               if ( !extension_loaded( 'exif' ) ) {
-                       $this->markTestSkipped( "This test needs the exif extension." );
-               }
+               $this->checkPHPExtension( 'exif' );
 
                $this->setMwGlobals( 'wgShowEXIF', true );
 
index 9ec5796..61ba189 100644 (file)
@@ -7,9 +7,7 @@ class XMPTest extends MediaWikiTestCase {
 
        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
        }
 
        /**