summaryrefslogtreecommitdiff
path: root/includes/installer
diff options
context:
space:
mode:
Diffstat (limited to 'includes/installer')
-rw-r--r--includes/installer/MssqlInstaller.php736
-rw-r--r--includes/installer/MssqlUpdater.php143
-rw-r--r--includes/installer/OracleInstaller.php344
-rw-r--r--includes/installer/OracleUpdater.php289
4 files changed, 0 insertions, 1512 deletions
diff --git a/includes/installer/MssqlInstaller.php b/includes/installer/MssqlInstaller.php
deleted file mode 100644
index 4d79d966..00000000
--- a/includes/installer/MssqlInstaller.php
+++ /dev/null
@@ -1,736 +0,0 @@
-<?php
-/**
- * Microsoft SQL Server-specific installer.
- *
- * 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 Deployment
- */
-
-/**
- * Class for setting up the MediaWiki database using Microsoft SQL Server.
- *
- * @ingroup Deployment
- * @since 1.23
- */
-class MssqlInstaller extends DatabaseInstaller {
-
- protected $globalNames = array(
- 'wgDBserver',
- 'wgDBname',
- 'wgDBuser',
- 'wgDBpassword',
- 'wgDBmwschema',
- 'wgDBprefix',
- 'wgDBWindowsAuthentication',
- );
-
- protected $internalDefaults = array(
- '_InstallUser' => 'sa',
- '_InstallWindowsAuthentication' => 'sqlauth',
- '_WebWindowsAuthentication' => 'sqlauth',
- );
-
- // SQL Server 2005 RTM
- // @todo Are SQL Express version numbers different?)
- public $minimumVersion = '9.00.1399';
-
- // These are schema-level privs
- // Note: the web user will be created will full permissions if possible, this permission
- // list is only used if we are unable to grant full permissions.
- public $webUserPrivs = array(
- 'DELETE',
- 'INSERT',
- 'SELECT',
- 'UPDATE',
- 'EXECUTE',
- );
-
- /**
- * @return string
- */
- public function getName() {
- return 'mssql';
- }
-
- /**
- * @return bool
- */
- public function isCompiled() {
- return self::checkExtension( 'sqlsrv' );
- }
-
- /**
- * @return string
- */
- public function getConnectForm() {
- if ( $this->getVar( '_InstallWindowsAuthentication' ) == 'windowsauth' ) {
- $displayStyle = 'display: none;';
- } else {
- $displayStyle = 'display: block;';
- }
-
- return $this->getTextBox(
- 'wgDBserver',
- 'config-db-host',
- array(),
- $this->parent->getHelpBox( 'config-db-host-help' )
- ) .
- Html::openElement( 'fieldset' ) .
- Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) .
- $this->getTextBox( 'wgDBname', 'config-db-name', array( 'dir' => 'ltr' ),
- $this->parent->getHelpBox( 'config-db-name-help' ) ) .
- $this->getTextBox( 'wgDBmwschema', 'config-db-schema', array( 'dir' => 'ltr' ),
- $this->parent->getHelpBox( 'config-db-schema-help' ) ) .
- $this->getTextBox( 'wgDBprefix', 'config-db-prefix', array( 'dir' => 'ltr' ),
- $this->parent->getHelpBox( 'config-db-prefix-help' ) ) .
- Html::closeElement( 'fieldset' ) .
- Html::openElement( 'fieldset' ) .
- Html::element( 'legend', array(), wfMessage( 'config-db-install-account' )->text() ) .
- $this->getRadioSet( array(
- 'var' => '_InstallWindowsAuthentication',
- 'label' => 'config-mssql-auth',
- 'itemLabelPrefix' => 'config-mssql-',
- 'values' => array( 'sqlauth', 'windowsauth' ),
- 'itemAttribs' => array(
- 'sqlauth' => array(
- 'class' => 'showHideRadio',
- 'rel' => 'dbCredentialBox',
- ),
- 'windowsauth' => array(
- 'class' => 'hideShowRadio',
- 'rel' => 'dbCredentialBox',
- )
- ),
- 'help' => $this->parent->getHelpBox( 'config-mssql-install-auth' )
- ) ) .
- Html::openElement( 'div', array( 'id' => 'dbCredentialBox', 'style' => $displayStyle ) ) .
- $this->getTextBox(
- '_InstallUser',
- 'config-db-username',
- array( 'dir' => 'ltr' ),
- $this->parent->getHelpBox( 'config-db-install-username' )
- ) .
- $this->getPasswordBox(
- '_InstallPassword',
- 'config-db-password',
- array( 'dir' => 'ltr' ),
- $this->parent->getHelpBox( 'config-db-install-password' )
- ) .
- Html::closeElement( 'div' ) .
- Html::closeElement( 'fieldset' );
- }
-
- public function submitConnectForm() {
- // Get variables from the request.
- $newValues = $this->setVarsFromRequest( array(
- 'wgDBserver',
- 'wgDBname',
- 'wgDBmwschema',
- 'wgDBprefix'
- ) );
-
- // Validate them.
- $status = Status::newGood();
- if ( !strlen( $newValues['wgDBserver'] ) ) {
- $status->fatal( 'config-missing-db-host' );
- }
- if ( !strlen( $newValues['wgDBname'] ) ) {
- $status->fatal( 'config-missing-db-name' );
- } elseif ( !preg_match( '/^[a-z0-9_]+$/i', $newValues['wgDBname'] ) ) {
- $status->fatal( 'config-invalid-db-name', $newValues['wgDBname'] );
- }
- if ( !preg_match( '/^[a-z0-9_]*$/i', $newValues['wgDBmwschema'] ) ) {
- $status->fatal( 'config-invalid-schema', $newValues['wgDBmwschema'] );
- }
- if ( !preg_match( '/^[a-z0-9_]*$/i', $newValues['wgDBprefix'] ) ) {
- $status->fatal( 'config-invalid-db-prefix', $newValues['wgDBprefix'] );
- }
- if ( !$status->isOK() ) {
- return $status;
- }
-
- // Check for blank schema and remap to dbo
- if ( $newValues['wgDBmwschema'] === '' ) {
- $this->setVar( 'wgDBmwschema', 'dbo' );
- }
-
- // User box
- $this->setVarsFromRequest( array(
- '_InstallUser',
- '_InstallPassword',
- '_InstallWindowsAuthentication'
- ) );
-
- // Try to connect
- $status = $this->getConnection();
- if ( !$status->isOK() ) {
- return $status;
- }
- /**
- * @var $conn DatabaseBase
- */
- $conn = $status->value;
-
- // Check version
- $version = $conn->getServerVersion();
- if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
- return Status::newFatal( 'config-mssql-old', $this->minimumVersion, $version );
- }
-
- return $status;
- }
-
- /**
- * @return Status
- */
- public function openConnection() {
- global $wgDBWindowsAuthentication;
- $status = Status::newGood();
- $user = $this->getVar( '_InstallUser' );
- $password = $this->getVar( '_InstallPassword' );
-
- if ( $this->getVar( '_InstallWindowsAuthentication' ) == 'windowsauth' ) {
- // Use Windows authentication for this connection
- $wgDBWindowsAuthentication = true;
- } else {
- $wgDBWindowsAuthentication = false;
- }
-
- try {
- $db = DatabaseBase::factory( 'mssql', array(
- 'host' => $this->getVar( 'wgDBserver' ),
- 'user' => $user,
- 'password' => $password,
- 'dbname' => false,
- 'flags' => 0,
- 'schema' => $this->getVar( 'wgDBmwschema' ),
- 'tablePrefix' => $this->getVar( 'wgDBprefix' ) ) );
- $db->prepareStatements( false );
- $db->scrollableCursor( false );
- $status->value = $db;
- } catch ( DBConnectionError $e ) {
- $status->fatal( 'config-connection-error', $e->getMessage() );
- }
-
- return $status;
- }
-
- public function preUpgrade() {
- global $wgDBuser, $wgDBpassword;
-
- $status = $this->getConnection();
- if ( !$status->isOK() ) {
- $this->parent->showStatusError( $status );
-
- return;
- }
- /**
- * @var $conn DatabaseBase
- */
- $conn = $status->value;
- $conn->selectDB( $this->getVar( 'wgDBname' ) );
-
- # Normal user and password are selected after this step, so for now
- # just copy these two
- $wgDBuser = $this->getVar( '_InstallUser' );
- $wgDBpassword = $this->getVar( '_InstallPassword' );
- }
-
- /**
- * Return true if the install user can create accounts
- *
- * @return bool
- */
- public function canCreateAccounts() {
- $status = $this->getConnection();
- if ( !$status->isOK() ) {
- return false;
- }
- /** @var $conn DatabaseBase */
- $conn = $status->value;
-
- // We need the server-level ALTER ANY LOGIN permission to create new accounts
- $res = $conn->query( "SELECT permission_name FROM sys.fn_my_permissions( NULL, 'SERVER' )" );
- $serverPrivs = array(
- 'ALTER ANY LOGIN' => false,
- 'CONTROL SERVER' => false,
- );
-
- foreach ( $res as $row ) {
- $serverPrivs[$row->permission_name] = true;
- }
-
- if ( !$serverPrivs['ALTER ANY LOGIN'] ) {
- return false;
- }
-
- // Check to ensure we can grant everything needed as well
- // We can't actually tell if we have WITH GRANT OPTION for a given permission, so we assume we do
- // and just check for the permission
- // http://technet.microsoft.com/en-us/library/ms178569.aspx
- // The following array sets up which permissions imply whatever permissions we specify
- $implied = array(
- // schema database server
- 'DELETE' => array( 'DELETE', 'CONTROL SERVER' ),
- 'EXECUTE' => array( 'EXECUTE', 'CONTROL SERVER' ),
- 'INSERT' => array( 'INSERT', 'CONTROL SERVER' ),
- 'SELECT' => array( 'SELECT', 'CONTROL SERVER' ),
- 'UPDATE' => array( 'UPDATE', 'CONTROL SERVER' ),
- );
-
- $grantOptions = array_flip( $this->webUserPrivs );
-
- // Check for schema and db-level permissions, but only if the schema/db exists
- $schemaPrivs = $dbPrivs = array(
- 'DELETE' => false,
- 'EXECUTE' => false,
- 'INSERT' => false,
- 'SELECT' => false,
- 'UPDATE' => false,
- );
-
- $dbPrivs['ALTER ANY USER'] = false;
-
- if ( $this->databaseExists( $this->getVar( 'wgDBname' ) ) ) {
- $conn->selectDB( $this->getVar( 'wgDBname' ) );
- $res = $conn->query( "SELECT permission_name FROM sys.fn_my_permissions( NULL, 'DATABASE' )" );
-
- foreach ( $res as $row ) {
- $dbPrivs[$row->permission_name] = true;
- }
-
- // If the db exists, we need ALTER ANY USER privs on it to make a new user
- if ( !$dbPrivs['ALTER ANY USER'] ) {
- return false;
- }
-
- if ( $this->schemaExists( $this->getVar( 'wgDBmwschema' ) ) ) {
- // wgDBmwschema is validated to only contain alphanumeric + underscore, so this is safe
- $res = $conn->query( "SELECT permission_name FROM sys.fn_my_permissions( "
- . "'{$this->getVar( 'wgDBmwschema' )}', 'SCHEMA' )" );
-
- foreach ( $res as $row ) {
- $schemaPrivs[$row->permission_name] = true;
- }
- }
- }
-
- // Now check all the grants we'll need to be doing to see if we can
- foreach ( $this->webUserPrivs as $permission ) {
- if ( ( isset( $schemaPrivs[$permission] ) && $schemaPrivs[$permission] )
- || ( isset( $dbPrivs[$implied[$permission][0]] )
- && $dbPrivs[$implied[$permission][0]] )
- || ( isset( $serverPrivs[$implied[$permission][1]] )
- && $serverPrivs[$implied[$permission][1]] )
- ) {
- unset( $grantOptions[$permission] );
- }
- }
-
- if ( count( $grantOptions ) ) {
- // Can't grant everything
- return false;
- }
-
- return true;
- }
-
- /**
- * @return string
- */
- public function getSettingsForm() {
- if ( $this->canCreateAccounts() ) {
- $noCreateMsg = false;
- } else {
- $noCreateMsg = 'config-db-web-no-create-privs';
- }
-
- $wrapperStyle = $this->getVar( '_SameAccount' ) ? 'display: none' : '';
- $displayStyle = $this->getVar( '_WebWindowsAuthentication' ) == 'windowsauth'
- ? 'display: none'
- : '';
- $s = Html::openElement( 'fieldset' ) .
- Html::element( 'legend', array(), wfMessage( 'config-db-web-account' )->text() ) .
- $this->getCheckBox(
- '_SameAccount', 'config-db-web-account-same',
- array( 'class' => 'hideShowRadio', 'rel' => 'dbOtherAccount' )
- ) .
- Html::openElement( 'div', array( 'id' => 'dbOtherAccount', 'style' => $wrapperStyle ) ) .
- $this->getRadioSet( array(
- 'var' => '_WebWindowsAuthentication',
- 'label' => 'config-mssql-auth',
- 'itemLabelPrefix' => 'config-mssql-',
- 'values' => array( 'sqlauth', 'windowsauth' ),
- 'itemAttribs' => array(
- 'sqlauth' => array(
- 'class' => 'showHideRadio',
- 'rel' => 'dbCredentialBox',
- ),
- 'windowsauth' => array(
- 'class' => 'hideShowRadio',
- 'rel' => 'dbCredentialBox',
- )
- ),
- 'help' => $this->parent->getHelpBox( 'config-mssql-web-auth' )
- ) ) .
- Html::openElement( 'div', array( 'id' => 'dbCredentialBox', 'style' => $displayStyle ) ) .
- $this->getTextBox( 'wgDBuser', 'config-db-username' ) .
- $this->getPasswordBox( 'wgDBpassword', 'config-db-password' ) .
- Html::closeElement( 'div' );
-
- if ( $noCreateMsg ) {
- $s .= $this->parent->getWarningBox( wfMessage( $noCreateMsg )->plain() );
- } else {
- $s .= $this->getCheckBox( '_CreateDBAccount', 'config-db-web-create' );
- }
-
- $s .= Html::closeElement( 'div' ) . Html::closeElement( 'fieldset' );
-
- return $s;
- }
-
- /**
- * @return Status
- */
- public function submitSettingsForm() {
- $this->setVarsFromRequest( array(
- 'wgDBuser',
- 'wgDBpassword',
- '_SameAccount',
- '_CreateDBAccount',
- '_WebWindowsAuthentication'
- ) );
-
- if ( $this->getVar( '_SameAccount' ) ) {
- $this->setVar( '_WebWindowsAuthentication', $this->getVar( '_InstallWindowsAuthentication' ) );
- $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
- $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) );
- }
-
- if ( $this->getVar( '_WebWindowsAuthentication' ) == 'windowsauth' ) {
- $this->setVar( 'wgDBuser', '' );
- $this->setVar( 'wgDBpassword', '' );
- $this->setVar( 'wgDBWindowsAuthentication', true );
- } else {
- $this->setVar( 'wgDBWindowsAuthentication', false );
- }
-
- if ( $this->getVar( '_CreateDBAccount' )
- && $this->getVar( '_WebWindowsAuthentication' ) == 'sqlauth'
- && strval( $this->getVar( 'wgDBpassword' ) ) == ''
- ) {
- return Status::newFatal( 'config-db-password-empty', $this->getVar( 'wgDBuser' ) );
- }
-
- // Validate the create checkbox
- $canCreate = $this->canCreateAccounts();
- if ( !$canCreate ) {
- $this->setVar( '_CreateDBAccount', false );
- $create = false;
- } else {
- $create = $this->getVar( '_CreateDBAccount' );
- }
-
- if ( !$create ) {
- // Test the web account
- $user = $this->getVar( 'wgDBuser' );
- $password = $this->getVar( 'wgDBpassword' );
-
- if ( $this->getVar( '_WebWindowsAuthentication' ) == 'windowsauth' ) {
- $user = 'windowsauth';
- $password = 'windowsauth';
- }
-
- try {
- DatabaseBase::factory( 'mssql', array(
- 'host' => $this->getVar( 'wgDBserver' ),
- 'user' => $user,
- 'password' => $password,
- 'dbname' => false,
- 'flags' => 0,
- 'tablePrefix' => $this->getVar( 'wgDBprefix' ),
- 'schema' => $this->getVar( 'wgDBmwschema' ),
- ) );
- } catch ( DBConnectionError $e ) {
- return Status::newFatal( 'config-connection-error', $e->getMessage() );
- }
- }
-
- return Status::newGood();
- }
-
- public function preInstall() {
- # Add our user callback to installSteps, right before the tables are created.
- $callback = array(
- 'name' => 'user',
- 'callback' => array( $this, 'setupUser' ),
- );
- $this->parent->addInstallStep( $callback, 'tables' );
- }
-
- /**
- * @return Status
- */
- public function setupDatabase() {
- $status = $this->getConnection();
- if ( !$status->isOK() ) {
- return $status;
- }
- /** @var DatabaseBase $conn */
- $conn = $status->value;
- $dbName = $this->getVar( 'wgDBname' );
- $schemaName = $this->getVar( 'wgDBmwschema' );
- if ( !$this->databaseExists( $dbName ) ) {
- $conn->query(
- "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ),
- __METHOD__
- );
- $conn->selectDB( $dbName );
- if ( !$this->schemaExists( $schemaName ) ) {
- $conn->query(
- "CREATE SCHEMA " . $conn->addIdentifierQuotes( $schemaName ),
- __METHOD__
- );
- }
- if ( !$this->catalogExists( $schemaName ) ) {
- $conn->query(
- "CREATE FULLTEXT CATALOG " . $conn->addIdentifierQuotes( $schemaName ),
- __METHOD__
- );
- }
- }
- $this->setupSchemaVars();
-
- return $status;
- }
-
- /**
- * @return Status
- */
- public function setupUser() {
- $dbUser = $this->getVar( 'wgDBuser' );
- if ( $dbUser == $this->getVar( '_InstallUser' )
- || ( $this->getVar( '_InstallWindowsAuthentication' ) == 'windowsauth'
- && $this->getVar( '_WebWindowsAuthentication' ) == 'windowsauth' ) ) {
- return Status::newGood();
- }
- $status = $this->getConnection();
- if ( !$status->isOK() ) {
- return $status;
- }
-
- $this->setupSchemaVars();
- $dbName = $this->getVar( 'wgDBname' );
- $this->db->selectDB( $dbName );
- $password = $this->getVar( 'wgDBpassword' );
- $schemaName = $this->getVar( 'wgDBmwschema' );
-
- if ( $this->getVar( '_WebWindowsAuthentication' ) == 'windowsauth' ) {
- $dbUser = 'windowsauth';
- $password = 'windowsauth';
- }
-
- if ( $this->getVar( '_CreateDBAccount' ) ) {
- $tryToCreate = true;
- } else {
- $tryToCreate = false;
- }
-
- $escUser = $this->db->addIdentifierQuotes( $dbUser );
- $escDb = $this->db->addIdentifierQuotes( $dbName );
- $escSchema = $this->db->addIdentifierQuotes( $schemaName );
- $grantableNames = array();
- if ( $tryToCreate ) {
- $escPass = $this->db->addQuotes( $password );
-
- if ( !$this->loginExists( $dbUser ) ) {
- try {
- $this->db->begin();
- $this->db->selectDB( 'master' );
- $logintype = $this->getVar( '_WebWindowsAuthentication' ) == 'windowsauth'
- ? 'FROM WINDOWS'
- : "WITH PASSWORD = $escPass";
- $this->db->query( "CREATE LOGIN $escUser $logintype" );
- $this->db->selectDB( $dbName );
- $this->db->query( "CREATE USER $escUser FOR LOGIN $escUser WITH DEFAULT_SCHEMA = $escSchema" );
- $this->db->commit();
- $grantableNames[] = $dbUser;
- } catch ( DBQueryError $dqe ) {
- $this->db->rollback();
- $status->warning( 'config-install-user-create-failed', $dbUser, $dqe->getText() );
- }
- } elseif ( !$this->userExists( $dbUser ) ) {
- try {
- $this->db->begin();
- $this->db->selectDB( $dbName );
- $this->db->query( "CREATE USER $escUser FOR LOGIN $escUser WITH DEFAULT_SCHEMA = $escSchema" );
- $this->db->commit();
- $grantableNames[] = $dbUser;
- } catch ( DBQueryError $dqe ) {
- $this->db->rollback();
- $status->warning( 'config-install-user-create-failed', $dbUser, $dqe->getText() );
- }
- } else {
- $status->warning( 'config-install-user-alreadyexists', $dbUser );
- $grantableNames[] = $dbUser;
- }
- }
-
- // Try to grant to all the users we know exist or we were able to create
- $this->db->selectDB( $dbName );
- foreach ( $grantableNames as $name ) {
- try {
- // First try to grant full permissions
- $fullPrivArr = array(
- 'BACKUP DATABASE', 'BACKUP LOG', 'CREATE FUNCTION', 'CREATE PROCEDURE',
- 'CREATE TABLE', 'CREATE VIEW', 'CREATE FULLTEXT CATALOG', 'SHOWPLAN'
- );
- $fullPrivList = implode( ', ', $fullPrivArr );
- $this->db->begin();
- $this->db->query( "GRANT $fullPrivList ON DATABASE :: $escDb TO $escUser", __METHOD__ );
- $this->db->query( "GRANT CONTROL ON SCHEMA :: $escSchema TO $escUser", __METHOD__ );
- $this->db->commit();
- } catch ( DBQueryError $dqe ) {
- // If that fails, try to grant the limited subset specified in $this->webUserPrivs
- try {
- $privList = implode( ', ', $this->webUserPrivs );
- $this->db->rollback();
- $this->db->begin();
- $this->db->query( "GRANT $privList ON SCHEMA :: $escSchema TO $escUser", __METHOD__ );
- $this->db->commit();
- } catch ( DBQueryError $dqe ) {
- $this->db->rollback();
- $status->fatal( 'config-install-user-grant-failed', $dbUser, $dqe->getText() );
- }
- // Also try to grant SHOWPLAN on the db, but don't fail if we can't
- // (just makes a couple things in mediawiki run slower since
- // we have to run SELECT COUNT(*) instead of getting the query plan)
- try {
- $this->db->query( "GRANT SHOWPLAN ON DATABASE :: $escDb TO $escUser", __METHOD__ );
- } catch ( DBQueryError $dqe ) {
- }
- }
- }
-
- return $status;
- }
-
- public function createTables() {
- $status = parent::createTables();
-
- // Do last-minute stuff like fulltext indexes (since they can't be inside a transaction)
- if ( $status->isOk() ) {
- $searchindex = $this->db->tableName( 'searchindex' );
- $schema = $this->db->addIdentifierQuotes( $this->getVar( 'wgDBmwschema' ) );
- try {
- $this->db->query( "CREATE FULLTEXT INDEX ON $searchindex (si_title, si_text) "
- . "KEY INDEX si_page ON $schema" );
- } catch ( DBQueryError $dqe ) {
- $status->fatal( 'config-install-tables-failed', $dqe->getText() );
- }
- }
-
- return $status;
- }
-
- public function getGlobalDefaults() {
- // The default $wgDBmwschema is null, which breaks Postgres and other DBMSes that require
- // the use of a schema, so we need to set it here
- return array_merge( parent::getGlobalDefaults(), array(
- 'wgDBmwschema' => 'mediawiki',
- ) );
- }
-
- /**
- * Try to see if the login exists
- * @param string $user Username to check
- * @return bool
- */
- private function loginExists( $user ) {
- $res = $this->db->selectField( 'sys.sql_logins', 1, array( 'name' => $user ) );
- return (bool)$res;
- }
-
- /**
- * Try to see if the user account exists
- * We assume we already have the appropriate database selected
- * @param string $user Username to check
- * @return bool
- */
- private function userExists( $user ) {
- $res = $this->db->selectField( 'sys.sysusers', 1, array( 'name' => $user ) );
- return (bool)$res;
- }
-
- /**
- * Try to see if a given database exists
- * @param string $dbName Database name to check
- * @return bool
- */
- private function databaseExists( $dbName ) {
- $res = $this->db->selectField( 'sys.databases', 1, array( 'name' => $dbName ) );
- return (bool)$res;
- }
-
- /**
- * Try to see if a given schema exists
- * We assume we already have the appropriate database selected
- * @param string $schemaName Schema name to check
- * @return bool
- */
- private function schemaExists( $schemaName ) {
- $res = $this->db->selectField( 'sys.schemas', 1, array( 'name' => $schemaName ) );
- return (bool)$res;
- }
-
- /**
- * Try to see if a given fulltext catalog exists
- * We assume we already have the appropriate database selected
- * @param string $catalogName Catalog name to check
- * @return bool
- */
- private function catalogExists( $catalogName ) {
- $res = $this->db->selectField( 'sys.fulltext_catalogs', 1, array( 'name' => $catalogName ) );
- return (bool)$res;
- }
-
- /**
- * Get variables to substitute into tables.sql and the SQL patch files.
- *
- * @return array
- */
- public function getSchemaVars() {
- return array(
- 'wgDBname' => $this->getVar( 'wgDBname' ),
- 'wgDBmwschema' => $this->getVar( 'wgDBmwschema' ),
- 'wgDBuser' => $this->getVar( 'wgDBuser' ),
- 'wgDBpassword' => $this->getVar( 'wgDBpassword' ),
- );
- }
-
- public function getLocalSettings() {
- $schema = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgDBmwschema' ) );
- $prefix = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgDBprefix' ) );
- $windowsauth = $this->getVar( 'wgDBWindowsAuthentication' ) ? 'true' : 'false';
-
- return "# MSSQL specific settings
-\$wgDBWindowsAuthentication = {$windowsauth};
-\$wgDBmwschema = \"{$schema}\";
-\$wgDBprefix = \"{$prefix}\";";
- }
-}
diff --git a/includes/installer/MssqlUpdater.php b/includes/installer/MssqlUpdater.php
deleted file mode 100644
index 164cfab4..00000000
--- a/includes/installer/MssqlUpdater.php
+++ /dev/null
@@ -1,143 +0,0 @@
-<?php
-/**
- * Microsoft SQL Server-specific installer.
- *
- * 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 Deployment
- */
-
-/**
- * Class for setting up the MediaWiki database using Microsoft SQL Server.
- *
- * @ingroup Deployment
- * @since 1.23
- */
-
-class MssqlUpdater extends DatabaseUpdater {
-
- /**
- * @var DatabaseMssql
- */
- protected $db;
-
- protected function getCoreUpdateList() {
- return array(
- // 1.23
- array( 'addField', 'mwuser', 'user_password_expires', 'patch-user_password_expires.sql' ),
-
- // 1.24
- array( 'addField', 'page', 'page_lang', 'patch-page-page_lang.sql' ),
-
- // 1.25
- array( 'dropTable', 'hitcounter' ),
- array( 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ),
- array( 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ),
- // Constraint updates
- array( 'updateConstraints', 'category_types', 'categorylinks', 'cl_type' ),
- array( 'updateConstraints', 'major_mime', 'filearchive', 'fa_major_mime' ),
- array( 'updateConstraints', 'media_type', 'filearchive', 'fa_media_type' ),
- array( 'updateConstraints', 'major_mime', 'oldimage', 'oi_major_mime' ),
- array( 'updateConstraints', 'media_type', 'oldimage', 'oi_media_type' ),
- array( 'updateConstraints', 'major_mime', 'image', 'img_major_mime' ),
- array( 'updateConstraints', 'media_type', 'image', 'img_media_type' ),
- array( 'updateConstraints', 'media_type', 'uploadstash', 'us_media_type' ),
- // END: Constraint updates
-
- array( 'modifyField', 'image', 'img_major_mime',
- 'patch-img_major_mime-chemical.sql' ),
- array( 'modifyField', 'oldimage', 'oi_major_mime',
- 'patch-oi_major_mime-chemical.sql' ),
- array( 'modifyField', 'filearchive', 'fa_major_mime',
- 'patch-fa_major_mime-chemical.sql' ),
- );
- }
-
- /**
- * Drops unnamed and creates named constraints following the pattern
- * <column>_ckc
- *
- * @param string $constraintType
- * @param string $table Name of the table to which the field belongs
- * @param string $field Name of the field to modify
- * @return bool False if patch is skipped.
- */
- protected function updateConstraints( $constraintType, $table, $field ) {
- global $wgDBname, $wgDBmwschema;
-
- if ( !$this->doTable( $table ) ) {
- return true;
- }
-
- $this->output( "...updating constraints on [$table].[$field] ..." );
- $updateKey = "$field-$constraintType-ck";
- if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
- $this->output( "...$table table does not exist, skipping modify field patch.\n" );
- return true;
- } elseif ( !$this->db->fieldExists( $table, $field, __METHOD__ ) ) {
- $this->output( "...$field field does not exist in $table table, " .
- "skipping modify field patch.\n" );
- return true;
- } elseif ( $this->updateRowExists( $updateKey ) ) {
- $this->output( "...$field in table $table already patched.\n" );
- return true;
- }
-
- # After all checks passed, start the update
- $this->insertUpdateRow( $updateKey );
- $path = 'named_constraints.sql';
- $constraintMap = array(
- 'category_types' =>
- "($field in('page', 'subcat', 'file'))",
- 'major_mime' =>
- "($field in('unknown', 'application', 'audio', 'image', 'text', 'video'," .
- " 'message', 'model', 'multipart'))",
- 'media_type' =>
- "($field in('UNKNOWN', 'BITMAP', 'DRAWING', 'AUDIO', 'VIDEO', 'MULTIMEDIA'," .
- "'OFFICE', 'TEXT', 'EXECUTABLE', 'ARCHIVE'))"
- );
- $constraint = $constraintMap[$constraintType];
-
- # and hack-in those variables that should be replaced
- # in our template file right now
- $this->db->setSchemaVars( array(
- 'tableName' => $table,
- 'fieldName' => $field,
- 'checkConstraint' => $constraint,
- 'wgDBname' => $wgDBname,
- 'wgDBmwschema' => $wgDBmwschema,
- ) );
-
- # Full path from file name
- $path = $this->db->patchPath( $path );
-
- # No need for a cursor allowing result-iteration; just apply a patch
- # store old value for re-setting later
- $wasScrollable = $this->db->scrollableCursor( false );
-
- # Apply patch
- $this->db->sourceFile( $path );
-
- # Reset DB instance to have original state
- $this->db->setSchemaVars( false );
- $this->db->scrollableCursor( $wasScrollable );
-
- $this->output( "done.\n" );
-
- return true;
- }
-}
diff --git a/includes/installer/OracleInstaller.php b/includes/installer/OracleInstaller.php
deleted file mode 100644
index 9e692ea4..00000000
--- a/includes/installer/OracleInstaller.php
+++ /dev/null
@@ -1,344 +0,0 @@
-<?php
-/**
- * Oracle-specific installer.
- *
- * 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 Deployment
- */
-
-/**
- * Class for setting up the MediaWiki database using Oracle.
- *
- * @ingroup Deployment
- * @since 1.17
- */
-class OracleInstaller extends DatabaseInstaller {
-
- protected $globalNames = array(
- 'wgDBserver',
- 'wgDBname',
- 'wgDBuser',
- 'wgDBpassword',
- 'wgDBprefix',
- );
-
- protected $internalDefaults = array(
- '_OracleDefTS' => 'USERS',
- '_OracleTempTS' => 'TEMP',
- '_InstallUser' => 'SYSTEM',
- );
-
- public $minimumVersion = '9.0.1'; // 9iR1
-
- protected $connError = null;
-
- public function getName() {
- return 'oracle';
- }
-
- public function isCompiled() {
- return self::checkExtension( 'oci8' );
- }
-
- public function getConnectForm() {
- if ( $this->getVar( 'wgDBserver' ) == 'localhost' ) {
- $this->parent->setVar( 'wgDBserver', '' );
- }
-
- return $this->getTextBox(
- 'wgDBserver',
- 'config-db-host-oracle',
- array(),
- $this->parent->getHelpBox( 'config-db-host-oracle-help' )
- ) .
- Html::openElement( 'fieldset' ) .
- Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) .
- $this->getTextBox( 'wgDBprefix', 'config-db-prefix' ) .
- $this->getTextBox( '_OracleDefTS', 'config-oracle-def-ts' ) .
- $this->getTextBox(
- '_OracleTempTS',
- 'config-oracle-temp-ts',
- array(),
- $this->parent->getHelpBox( 'config-db-oracle-help' )
- ) .
- Html::closeElement( 'fieldset' ) .
- $this->parent->getWarningBox( wfMessage( 'config-db-account-oracle-warn' )->text() ) .
- $this->getInstallUserBox() .
- $this->getWebUserBox();
- }
-
- public function submitInstallUserBox() {
- parent::submitInstallUserBox();
- $this->parent->setVar( '_InstallDBname', $this->getVar( '_InstallUser' ) );
-
- return Status::newGood();
- }
-
- public function submitConnectForm() {
- // Get variables from the request
- $newValues = $this->setVarsFromRequest( array(
- 'wgDBserver',
- 'wgDBprefix',
- 'wgDBuser',
- 'wgDBpassword'
- ) );
- $this->parent->setVar( 'wgDBname', $this->getVar( 'wgDBuser' ) );
-
- // Validate them
- $status = Status::newGood();
- if ( !strlen( $newValues['wgDBserver'] ) ) {
- $status->fatal( 'config-missing-db-server-oracle' );
- } elseif ( !self::checkConnectStringFormat( $newValues['wgDBserver'] ) ) {
- $status->fatal( 'config-invalid-db-server-oracle', $newValues['wgDBserver'] );
- }
- if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBprefix'] ) ) {
- $status->fatal( 'config-invalid-schema', $newValues['wgDBprefix'] );
- }
- if ( !$status->isOK() ) {
- return $status;
- }
-
- // Submit user box
- $status = $this->submitInstallUserBox();
- if ( !$status->isOK() ) {
- return $status;
- }
-
- // Try to connect trough multiple scenarios
- // Scenario 1: Install with a manually created account
- $status = $this->getConnection();
- if ( !$status->isOK() ) {
- if ( $this->connError == 28009 ) {
- // _InstallUser seems to be a SYSDBA
- // Scenario 2: Create user with SYSDBA and install with new user
- $status = $this->submitWebUserBox();
- if ( !$status->isOK() ) {
- return $status;
- }
- $status = $this->openSYSDBAConnection();
- if ( !$status->isOK() ) {
- return $status;
- }
- if ( !$this->getVar( '_CreateDBAccount' ) ) {
- $status->fatal( 'config-db-sys-create-oracle' );
- }
- } else {
- return $status;
- }
- } else {
- // check for web user credentials
- // Scenario 3: Install with a priviliged user but use a restricted user
- $statusIS3 = $this->submitWebUserBox();
- if ( !$statusIS3->isOK() ) {
- return $statusIS3;
- }
- }
-
- /**
- * @var $conn DatabaseBase
- */
- $conn = $status->value;
-
- // Check version
- $version = $conn->getServerVersion();
- if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
- return Status::newFatal( 'config-oracle-old', $this->minimumVersion, $version );
- }
-
- return $status;
- }
-
- public function openConnection() {
- $status = Status::newGood();
- try {
- $db = new DatabaseOracle(
- $this->getVar( 'wgDBserver' ),
- $this->getVar( '_InstallUser' ),
- $this->getVar( '_InstallPassword' ),
- $this->getVar( '_InstallDBname' ),
- 0,
- $this->getVar( 'wgDBprefix' )
- );
- $status->value = $db;
- } catch ( DBConnectionError $e ) {
- $this->connError = $e->db->lastErrno();
- $status->fatal( 'config-connection-error', $e->getMessage() );
- }
-
- return $status;
- }
-
- public function openSYSDBAConnection() {
- $status = Status::newGood();
- try {
- $db = new DatabaseOracle(
- $this->getVar( 'wgDBserver' ),
- $this->getVar( '_InstallUser' ),
- $this->getVar( '_InstallPassword' ),
- $this->getVar( '_InstallDBname' ),
- DBO_SYSDBA,
- $this->getVar( 'wgDBprefix' )
- );
- $status->value = $db;
- } catch ( DBConnectionError $e ) {
- $this->connError = $e->db->lastErrno();
- $status->fatal( 'config-connection-error', $e->getMessage() );
- }
-
- return $status;
- }
-
- public function needsUpgrade() {
- $tempDBname = $this->getVar( 'wgDBname' );
- $this->parent->setVar( 'wgDBname', $this->getVar( 'wgDBuser' ) );
- $retVal = parent::needsUpgrade();
- $this->parent->setVar( 'wgDBname', $tempDBname );
-
- return $retVal;
- }
-
- public function preInstall() {
- # Add our user callback to installSteps, right before the tables are created.
- $callback = array(
- 'name' => 'user',
- 'callback' => array( $this, 'setupUser' )
- );
- $this->parent->addInstallStep( $callback, 'database' );
- }
-
- public function setupDatabase() {
- $status = Status::newGood();
-
- return $status;
- }
-
- public function setupUser() {
- global $IP;
-
- if ( !$this->getVar( '_CreateDBAccount' ) ) {
- return Status::newGood();
- }
-
- // normaly only SYSDBA users can create accounts
- $status = $this->openSYSDBAConnection();
- if ( !$status->isOK() ) {
- if ( $this->connError == 1031 ) {
- // insufficient privileges (looks like a normal user)
- $status = $this->openConnection();
- if ( !$status->isOK() ) {
- return $status;
- }
- } else {
- return $status;
- }
- }
-
- $this->db = $status->value;
- $this->setupSchemaVars();
-
- if ( !$this->db->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
- $this->db->setFlag( DBO_DDLMODE );
- $error = $this->db->sourceFile( "$IP/maintenance/oracle/user.sql" );
- if ( $error !== true || !$this->db->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
- $status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ), $error );
- }
- } elseif ( $this->db->getFlag( DBO_SYSDBA ) ) {
- $status->fatal( 'config-db-sys-user-exists-oracle', $this->getVar( 'wgDBuser' ) );
- }
-
- if ( $status->isOK() ) {
- // user created or already existing, switching back to a normal connection
- // as the new user has all needed privileges to setup the rest of the schema
- // i will be using that user as _InstallUser from this point on
- $this->db->close();
- $this->db = false;
- $this->parent->setVar( '_InstallUser', $this->getVar( 'wgDBuser' ) );
- $this->parent->setVar( '_InstallPassword', $this->getVar( 'wgDBpassword' ) );
- $this->parent->setVar( '_InstallDBname', $this->getVar( 'wgDBuser' ) );
- $status = $this->getConnection();
- }
-
- return $status;
- }
-
- /**
- * Overload: after this action field info table has to be rebuilt
- * @return Status
- */
- public function createTables() {
- $this->setupSchemaVars();
- $this->db->setFlag( DBO_DDLMODE );
- $this->parent->setVar( 'wgDBname', $this->getVar( 'wgDBuser' ) );
- $status = parent::createTables();
- $this->db->clearFlag( DBO_DDLMODE );
-
- $this->db->query( 'BEGIN fill_wiki_info; END;' );
-
- return $status;
- }
-
- public function getSchemaVars() {
- $varNames = array(
- # These variables are used by maintenance/oracle/user.sql
- '_OracleDefTS',
- '_OracleTempTS',
- 'wgDBuser',
- 'wgDBpassword',
-
- # These are used by tables.sql
- 'wgDBprefix',
- );
- $vars = array();
- foreach ( $varNames as $name ) {
- $vars[$name] = $this->getVar( $name );
- }
-
- return $vars;
- }
-
- public function getLocalSettings() {
- $prefix = $this->getVar( 'wgDBprefix' );
-
- return "# Oracle specific settings
-\$wgDBprefix = \"{$prefix}\";
-";
- }
-
- /**
- * Function checks the format of Oracle connect string
- * The actual validity of the string is checked by attempting to connect
- *
- * Regex should be able to validate all connect string formats
- * [//](host|tns_name)[:port][/service_name][:POOLED]
- * http://www.orafaq.com/wiki/EZCONNECT
- *
- * @since 1.22
- *
- * @param string $connect_string
- *
- * @return bool Whether the connection string is valid.
- */
- public static function checkConnectStringFormat( $connect_string ) {
- // @@codingStandardsIgnoreStart Long lines with regular expressions.
- // @todo Very long regular expression. Make more readable?
- $isValid = preg_match( '/^[[:alpha:]][\w\-]*(?:\.[[:alpha:]][\w\-]*){0,2}$/', $connect_string ); // TNS name
- $isValid |= preg_match( '/^(?:\/\/)?[\w\-\.]+(?::[\d]+)?(?:\/(?:[\w\-\.]+(?::(pooled|dedicated|shared))?)?(?:\/[\w\-\.]+)?)?$/', $connect_string ); // EZConnect
- // @@codingStandardsIgnoreEnd
- return (bool)$isValid;
- }
-}
diff --git a/includes/installer/OracleUpdater.php b/includes/installer/OracleUpdater.php
deleted file mode 100644
index 03dbd1ce..00000000
--- a/includes/installer/OracleUpdater.php
+++ /dev/null
@@ -1,289 +0,0 @@
-<?php
-/**
- * Oracle-specific updater.
- *
- * 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 Deployment
- */
-
-/**
- * Class for handling updates to Oracle databases.
- *
- * @ingroup Deployment
- * @since 1.17
- */
-class OracleUpdater extends DatabaseUpdater {
-
- /**
- * Handle to the database subclass
- *
- * @var DatabaseOracle
- */
- protected $db;
-
- protected function getCoreUpdateList() {
- return array(
- array( 'disableContentHandlerUseDB' ),
-
- // 1.17
- array( 'doNamespaceDefaults' ),
- array( 'doFKRenameDeferr' ),
- array( 'doFunctions17' ),
- array( 'doSchemaUpgrade17' ),
- array( 'doInsertPage0' ),
- array( 'doRemoveNotNullEmptyDefaults' ),
- array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ),
-
- // 1.18
- array( 'addIndex', 'user', 'i02', 'patch-user_email_index.sql' ),
- array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ),
- array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
- array( 'doRecentchangesFK2Cascade' ),
-
- // 1.19
- array( 'addIndex', 'logging', 'i05', 'patch-logging_type_action_index.sql' ),
- array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1_field.sql' ),
- array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1_field.sql' ),
- array( 'doRemoveNotNullEmptyDefaults2' ),
- array( 'addIndex', 'page', 'i03', 'patch-page_redirect_namespace_len.sql' ),
- array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-us_chunk_inx_field.sql' ),
- array( 'addField', 'job', 'job_timestamp', 'patch-job_timestamp_field.sql' ),
- array( 'addIndex', 'job', 'i02', 'patch-job_timestamp_index.sql' ),
- array( 'doPageRestrictionsPKUKFix' ),
-
- // 1.20
- array( 'addIndex', 'ipblocks', 'i05', 'patch-ipblocks_i05_index.sql' ),
- array( 'addIndex', 'revision', 'i05', 'patch-revision_i05_index.sql' ),
- array( 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ),
-
- // 1.21
- array( 'addField', 'revision', 'rev_content_format',
- 'patch-revision-rev_content_format.sql' ),
- array( 'addField', 'revision', 'rev_content_model',
- 'patch-revision-rev_content_model.sql' ),
- array( 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ),
- array( 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ),
- array( 'addField', 'archive', 'ar_id', 'patch-archive-ar_id.sql' ),
- array( 'addField', 'externallinks', 'el_id', 'patch-externallinks-el_id.sql' ),
- array( 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ),
- array( 'enableContentHandlerUseDB' ),
- array( 'dropField', 'site_stats', 'ss_admins', 'patch-ss_admins.sql' ),
- array( 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ),
- array( 'addTable', 'sites', 'patch-sites.sql' ),
- array( 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ),
- array( 'addField', 'job', 'job_token', 'patch-job_token.sql' ),
- array( 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ),
- array( 'addField', 'uploadstash', 'us_props', 'patch-uploadstash-us_props.sql' ),
- array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase-255.sql' ),
- array( 'modifyField', 'user_former_groups', 'ufg_group',
- 'patch-ufg_group-length-increase-255.sql' ),
-
- // 1.23
- array( 'addIndex', 'logging', 'i06', 'patch-logging_user_text_type_time_index.sql' ),
- array( 'addIndex', 'logging', 'i07', 'patch-logging_user_text_time_index.sql' ),
- array( 'addField', 'user', 'user_password_expires', 'patch-user_password_expire.sql' ),
- array( 'addField', 'page', 'page_links_updated', 'patch-page_links_updated.sql' ),
- array( 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ),
-
- // 1.24
- array( 'addField', 'page', 'page_lang', 'patch-page-page_lang.sql' ),
-
- // 1.25
- array( 'dropTable', 'hitcounter' ),
- array( 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ),
- array( 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ),
-
- // KEEP THIS AT THE BOTTOM!!
- array( 'doRebuildDuplicateFunction' ),
-
- );
- }
-
- /**
- * MySQL uses datatype defaults for NULL inserted into NOT NULL fields
- * In namespace case that results into insert of 0 which is default namespace
- * Oracle inserts NULL, so namespace fields should have a default value
- */
- protected function doNamespaceDefaults() {
- $meta = $this->db->fieldInfo( 'page', 'page_namespace' );
- if ( $meta->defaultValue() != null ) {
- return;
- }
-
- $this->applyPatch(
- 'patch_namespace_defaults.sql',
- false,
- 'Altering namespace fields with default value'
- );
- }
-
- /**
- * Uniform FK names + deferrable state
- */
- protected function doFKRenameDeferr() {
- $meta = $this->db->query( '
- SELECT COUNT(*) cnt
- FROM user_constraints
- WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\''
- );
- $row = $meta->fetchRow();
- if ( $row && $row['cnt'] > 0 ) {
- return;
- }
-
- $this->applyPatch( 'patch_fk_rename_deferred.sql', false, "Altering foreign keys ... " );
- }
-
- /**
- * Recreate functions to 17 schema layout
- */
- protected function doFunctions17() {
- $this->applyPatch( 'patch_create_17_functions.sql', false, "Recreating functions" );
- }
-
- /**
- * Schema upgrade 16->17
- * there are no incremental patches prior to this
- */
- protected function doSchemaUpgrade17() {
- // check if iwlinks table exists which was added in 1.17
- if ( $this->db->tableExists( 'iwlinks' ) ) {
- return;
- }
- $this->applyPatch( 'patch_16_17_schema_changes.sql', false, "Updating schema to 17" );
- }
-
- /**
- * Insert page (page_id = 0) to prevent FK constraint violation
- */
- protected function doInsertPage0() {
- $this->output( "Inserting page 0 if missing ... " );
- $row = array(
- 'page_id' => 0,
- 'page_namespace' => 0,
- 'page_title' => ' ',
- 'page_is_redirect' => 0,
- 'page_is_new' => 0,
- 'page_random' => 0,
- 'page_touched' => $this->db->timestamp(),
- 'page_latest' => 0,
- 'page_len' => 0
- );
- $this->db->insert( 'page', $row, 'OracleUpdater:doInserPage0', array( 'IGNORE' ) );
- $this->output( "ok\n" );
- }
-
- /**
- * Remove DEFAULT '' NOT NULL constraints from fields as '' is internally
- * converted to NULL in Oracle
- */
- protected function doRemoveNotNullEmptyDefaults() {
- $meta = $this->db->fieldInfo( 'categorylinks', 'cl_sortkey_prefix' );
- if ( $meta->isNullable() ) {
- return;
- }
- $this->applyPatch(
- 'patch_remove_not_null_empty_defs.sql',
- false,
- 'Removing not null empty constraints'
- );
- }
-
- protected function doRemoveNotNullEmptyDefaults2() {
- $meta = $this->db->fieldInfo( 'ipblocks', 'ipb_by_text' );
- if ( $meta->isNullable() ) {
- return;
- }
- $this->applyPatch(
- 'patch_remove_not_null_empty_defs2.sql',
- false,
- 'Removing not null empty constraints'
- );
- }
-
- /**
- * Removed forcing of invalid state on recentchanges_fk2.
- * cascading taken in account in the deleting function
- */
- protected function doRecentchangesFK2Cascade() {
- $meta = $this->db->query( 'SELECT 1 FROM all_constraints WHERE owner = \'' .
- strtoupper( $this->db->getDBname() ) .
- '\' AND constraint_name = \'' .
- $this->db->tablePrefix() .
- 'RECENTCHANGES_FK2\' AND delete_rule = \'CASCADE\''
- );
- $row = $meta->fetchRow();
- if ( $row ) {
- return;
- }
-
- $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false, "Altering RECENTCHANGES_FK2" );
- }
-
- /**
- * Fixed wrong PK, UK definition
- */
- protected function doPageRestrictionsPKUKFix() {
- $this->output( "Altering PAGE_RESTRICTIONS keys ... " );
-
- $meta = $this->db->query( 'SELECT column_name FROM all_cons_columns WHERE owner = \'' .
- strtoupper( $this->db->getDBname() ) .
- '\' AND constraint_name = \'' .
- $this->db->tablePrefix() .
- 'PAGE_RESTRICTIONS_PK\' AND rownum = 1'
- );
- $row = $meta->fetchRow();
- if ( $row['column_name'] == 'PR_ID' ) {
- $this->output( "seems to be up to date.\n" );
-
- return;
- }
-
- $this->applyPatch( 'patch-page_restrictions_pkuk_fix.sql', false );
- $this->output( "ok\n" );
- }
-
- /**
- * rebuilding of the function that duplicates tables for tests
- */
- protected function doRebuildDuplicateFunction() {
- $this->applyPatch( 'patch_rebuild_dupfunc.sql', false, "Rebuilding duplicate function" );
- }
-
- /**
- * Overload: after this action field info table has to be rebuilt
- *
- * @param array $what
- */
- public function doUpdates( $what = array( 'core', 'extensions', 'purge', 'stats' ) ) {
- parent::doUpdates( $what );
-
- $this->db->query( 'BEGIN fill_wiki_info; END;' );
- }
-
- /**
- * Overload: because of the DDL_MODE tablename escaping is a bit dodgy
- */
- public function purgeCache() {
- # We can't guarantee that the user will be able to use TRUNCATE,
- # but we know that DELETE is available to us
- $this->output( "Purging caches..." );
- $this->db->delete( '/*Q*/' . $this->db->tableName( 'objectcache' ), '*', __METHOD__ );
- $this->output( "done.\n" );
- }
-}