Special:Version now displays whether a SQLite database supports full-text search
authorMax Semenik <maxsem@users.mediawiki.org>
Thu, 23 Sep 2010 19:36:06 +0000 (19:36 +0000)
committerMax Semenik <maxsem@users.mediawiki.org>
Thu, 23 Sep 2010 19:36:06 +0000 (19:36 +0000)
RELEASE-NOTES
includes/db/Database.php
includes/db/DatabaseSqlite.php
includes/specials/SpecialVersion.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

index 132ede9..8868105 100644 (file)
@@ -160,6 +160,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Added new hook GetIP
 * (bug 16574) Allow administrators to temporarily disable the account creation
   limit for IP addresses: [[MediaWiki:Ratelimit-excluded-ips]]
+* Special:Version now displays whether a SQLite database supports full-text
+  search.
 
 === Bug fixes in 1.17 ===
 * (bug 17560) Half-broken deletion moved image files to deletion archive
index 40063e8..d20e04b 100644 (file)
@@ -177,11 +177,20 @@ interface DatabaseType {
 
        /**
         * A string describing the current software version, like from
-        * mysql_get_server_info().  Will be listed on Special:Version, etc.
+        * mysql_get_server_info().
         *
-        * @return string: Version information from the database
+        * @return string: Version information from the database server.
         */
        public function getServerVersion();
+
+       /**
+        * A string describing the current software version, and possibly
+        * other details in a user-friendly way.  Will be listed on Special:Version, etc.
+        * Use getServerVersion() to get machine-friendly information.
+        *
+        * @return string: Version information from the database server
+        */
+       public function getServerInfo();
 }
 
 /**
@@ -215,6 +224,17 @@ abstract class DatabaseBase implements DatabaseType {
 # ------------------------------------------------------------------------------
        # These optionally set a variable and return the previous state
 
+       /**
+        * A string describing the current software version, and possibly
+        * other details in a user-friendly way.  Will be listed on Special:Version, etc.
+        * Use getServerVersion() to get machine-friendly information.
+        *
+        * @return string: Version information from the database server
+        */
+       public function getServerInfo() {
+               return $this->getServerVersion();
+       }
+
        /**
         * Fail function, takes a Database as a parameter
         * Set to false for default, 1 for ignore errors
index e18a8e0..95c3db6 100644 (file)
@@ -148,14 +148,19 @@ class DatabaseSqlite extends DatabaseBase {
         * @return String
         */
        function getFulltextSearchModule() {
+               static $cachedResult = null;
+               if ( $cachedResult !== null ) {
+                       return $cachedResult;
+               }
+               $cachedResult = false;
                $table = 'dummy_search_test';
                $this->query( "DROP TABLE IF EXISTS $table", __METHOD__ );
 
                if ( $this->query( "CREATE VIRTUAL TABLE $table USING FTS3(dummy_field)", __METHOD__, true ) ) {
                        $this->query( "DROP TABLE IF EXISTS $table", __METHOD__ );
-                       return 'FTS3';
+                       $cachedResult = 'FTS3';
                }
-               return false;
+               return $cachedResult;
        }
 
        /**
@@ -468,6 +473,13 @@ class DatabaseSqlite extends DatabaseBase {
                return $ver;
        }
 
+       /**
+        * @return string User-friendly database information
+        */
+       public function getServerInfo() {
+               return wfMsg( $this->getFulltextSearchModule() ? 'sqlite-has-fts' : 'sqlite-no-fts', $this->getServerVersion() );
+       }
+
        /**
         * Get information about a given field
         * Returns false if the field does not exist.
index 541de15..3164e48 100644 (file)
@@ -121,7 +121,7 @@ class SpecialVersion extends SpecialPage {
                $software = array();
                $software['[http://www.mediawiki.org/ MediaWiki]'] = self::getVersionLinked();
                $software['[http://www.php.net/ PHP]'] = phpversion() . " (" . php_sapi_name() . ")";
-               $software[$dbr->getSoftwareLink()] = $dbr->getServerVersion();
+               $software[$dbr->getSoftwareLink()] = $dbr->getServerInfo();
 
                // Allow a hook to add/remove items.
                wfRunHooks( 'SoftwareInfo', array( &$software ) );
index 02ea64e..09dfde5 100644 (file)
@@ -4344,4 +4344,8 @@ This site is experiencing technical difficulties.',
 'htmlform-reset'               => 'Undo changes',
 'htmlform-selectorother-other' => 'Other',
 
+# SQLite support
+'sqlite-has-fts'               => '$1 with full-text search support',
+'sqlite-no-fts'                => '$1 without full-text search support',
+
 );
index fc2ab8f..f60bc34 100644 (file)
@@ -3753,4 +3753,7 @@ Used on [[Special:Tags]]. Verb. Used as display text on a link to create/edit a
 
 {{Identical|Other}}',
 
+# SQLite
+'sqlite-has-fts'    => 'Shown on Special:Version, $1 is version',
+'sqlite-no-fts'     => 'Shown on Special:Version, $1 is version',
 );
index 63ef92c..84b76c4 100644 (file)
@@ -3217,6 +3217,9 @@ $wgMessageStructure = array(
                'htmlform-reset',
                'htmlform-selectorother-other',
        ),
+       'sqlite' => array(
+               'sqlite-has-fts',
+       ),  'sqlite-no-fts',
 );
 
 /** Comments for each block */
@@ -3428,4 +3431,5 @@ Variants for Chinese language",
        'comparepages'          => 'Special:ComparePages',
        'db-error-messages'     => 'Database error messages',
        'html-forms'            => 'HTML forms',
+       'sqlite'                => 'SQLite databse support',
 );