From: Max Semenik Date: Thu, 23 Sep 2010 19:36:06 +0000 (+0000) Subject: Special:Version now displays whether a SQLite database supports full-text search X-Git-Tag: 1.31.0-rc.0~34817 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=c357bc7c8abc00d1c8371ca70d3c3165106c88fd;p=lhc%2Fweb%2Fwiklou.git Special:Version now displays whether a SQLite database supports full-text search --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 132ede9267..886810505f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 diff --git a/includes/db/Database.php b/includes/db/Database.php index 40063e8e60..d20e04b0c5 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -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 diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php index e18a8e060d..95c3db6d5f 100644 --- a/includes/db/DatabaseSqlite.php +++ b/includes/db/DatabaseSqlite.php @@ -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. diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 541de159f0..3164e48977 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -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 ) ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 02ea64e4db..09dfde5eeb 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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', + ); diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index fc2ab8f9e8..f60bc3417e 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -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', ); diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 63ef92c696..84b76c4820 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -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', );