From 16b811c80356cdd5344bd61845cb2af86ce83454 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Wed, 4 Jan 2012 10:41:39 +0000 Subject: [PATCH] Made installer not install on SQLite less than 3.3.7, would prevent stuff like bug 25746. Also, threw MSSQL out of release notes - it can't be installed through the usual means. --- RELEASE-NOTES-1.19 | 4 +-- includes/installer/DatabaseInstaller.php | 9 +++++++ includes/installer/Installer.i18n.php | 1 + includes/installer/Installer.php | 31 +++++++++++++++++------- includes/installer/SqliteInstaller.php | 19 +++++++++++++++ 5 files changed, 53 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 8edb4ae95e..b80b52e0d2 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -295,13 +295,13 @@ MediaWiki 1.19 requires PHP 5.2.3. PHP 4 is no longer supported. MySQL is the recommended DBMS. PostgreSQL or SQLite can also be used, but support for them is somewhat less mature. There is experimental support for IBM -DB2 and Microsoft SQL Server. +DB2 and Oracle. The supported versions are: * MySQL 5.0.2 or later * PostgreSQL 8.3 or later -* SQLite 3 +* SQLite 3.3.7 or later * Oracle 9.0.1 or later == Upgrading == diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index fca866190f..b086478bd3 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -54,6 +54,15 @@ abstract class DatabaseInstaller { */ public abstract function isCompiled(); + /** + * Checks for installation prerequisites other than those checked by isCompiled() + * @since 1.19 + * @return Status + */ + public function checkPrerequisites() { + return Status::newGood(); + } + /** * Get HTML for a web form that configures this database. Configuration * at this time should be the minimum needed to connect and test diff --git a/includes/installer/Installer.i18n.php b/includes/installer/Installer.i18n.php index ad0b546f11..67f92e9484 100644 --- a/includes/installer/Installer.i18n.php +++ b/includes/installer/Installer.i18n.php @@ -103,6 +103,7 @@ The following database types are supported: $1. If you are on shared hosting, ask your hosting provider to install a suitable database driver. If you compiled PHP yourself, reconfigure it with a database client enabled, for example using ./configure --with-mysql. If you installed PHP from a Debian or Ubuntu package, then you also need install the php5-mysql module.', + 'config-outdated-sqlite' => "'''Warning''': you have SQLite $1, which is lower than minimum required version $2. SQLite will be unavailable.", 'config-no-fts3' => "'''Warning''': SQLite is compiled without the [//sqlite.org/fts3.html FTS3 module], search features will be unavailable on this backend.", 'config-register-globals' => "'''Warning: PHP's [http://php.net/register_globals register_globals] option is enabled.''' '''Disable it if you can.''' diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 1c2cbfff45..0b7979dce4 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -634,19 +634,32 @@ abstract class Installer { $allNames[] = wfMsg( "config-type-$name" ); } - if ( !$this->getVar( '_CompiledDBs' ) ) { + // cache initially available databases to make sure that everything will be displayed correctly + // after a refresh on env checks page + $databases = $this->getVar( '_CompiledDBs-preFilter' ); + if ( !$databases ) { + $databases = $this->getVar( '_CompiledDBs' ); + $this->setVar( '_CompiledDBs-preFilter', $databases ); + } + + $databases = array_flip ( $databases ); + foreach ( array_keys( $databases ) as $db ) { + $installer = $this->getDBInstaller( $db ); + $status = $installer->checkPrerequisites(); + if ( !$status->isGood() ) { + $this->showStatusMessage( $status ); + } + if ( !$status->isOK() ) { + unset( $databases[$db] ); + } + } + $databases = array_flip( $databases ); + if ( !$databases ) { $this->showError( 'config-no-db', $wgLang->commaList( $allNames ) ); // @todo FIXME: This only works for the web installer! return false; } - - // Check for FTS3 full-text search module - $sqlite = $this->getDBInstaller( 'sqlite' ); - if ( $sqlite->isCompiled() ) { - if( DatabaseSqlite::getFulltextSearchModule() != 'FTS3' ) { - $this->showMessage( 'config-no-fts3' ); - } - } + $this->setVar( '_CompiledDBs', $databases ); } /** diff --git a/includes/installer/SqliteInstaller.php b/includes/installer/SqliteInstaller.php index 67dd1ba7b8..658a3b1646 100644 --- a/includes/installer/SqliteInstaller.php +++ b/includes/installer/SqliteInstaller.php @@ -13,6 +13,7 @@ * @since 1.17 */ class SqliteInstaller extends DatabaseInstaller { + const MINIMUM_VERSION = '3.3.7'; /** * @var DatabaseSqlite @@ -32,6 +33,24 @@ class SqliteInstaller extends DatabaseInstaller { return self::checkExtension( 'pdo_sqlite' ); } + /** + * + * @return Status: + */ + public function checkPrerequisites() { + $result = Status::newGood(); + // Bail out if SQLite is too old + $db = new DatabaseSqliteStandalone( ':memory:' ); + if ( version_compare( $db->getServerVersion(), self::MINIMUM_VERSION, '<' ) ) { + $result->fatal( 'config-outdated-sqlite', $db->getServerVersion(), self::MINIMUM_VERSION ); + } + // Check for FTS3 full-text search module + if( DatabaseSqlite::getFulltextSearchModule() != 'FTS3' ) { + $result->warning( 'config-no-fts3' ); + } + return $result; + } + public function getGlobalDefaults() { if ( isset( $_SERVER['DOCUMENT_ROOT'] ) ) { $path = str_replace( -- 2.20.1