From 807d793ab907984c9f347df9d672aadb5db78b38 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Wed, 14 Aug 2019 17:04:50 +0200 Subject: [PATCH] More clean up of oracle/mssql Bug: T230418 Change-Id: I1ff01548e55f01f9419668e31d5aa7dd03d23258 --- includes/db/CloneDatabase.php | 4 +- includes/installer/DatabaseInstaller.php | 3 +- includes/installer/Installer.php | 3 +- includes/installer/WebInstallerDBConnect.php | 6 +-- includes/installer/i18n/en.json | 22 ---------- includes/installer/i18n/qqq.json | 24 +--------- tests/parser/ParserTestRunner.php | 30 ++----------- .../phpunit/MediaWikiIntegrationTestCase.php | 44 +++---------------- .../phpunit/includes/db/LoadBalancerTest.php | 4 +- .../suites/ParserTestTopLevelSuite.php | 3 +- 10 files changed, 18 insertions(+), 125 deletions(-) diff --git a/includes/db/CloneDatabase.php b/includes/db/CloneDatabase.php index cdf0f797df..df5f1151b3 100644 --- a/includes/db/CloneDatabase.php +++ b/includes/db/CloneDatabase.php @@ -93,9 +93,7 @@ class CloneDatabase { // Postgres: Temp tables are automatically deleted upon end of session // Same Temp table name hides existing table for current session - if ( $this->dropCurrentTables - && !in_array( $this->db->getType(), [ 'oracle' ] ) - ) { + if ( $this->dropCurrentTables ) { if ( $oldTableName === $newTableName ) { // Last ditch check to avoid data loss throw new LogicException( "Not dropping new table, as '$newTableName'" diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index ba5da6de50..8b94d977a6 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -447,8 +447,7 @@ abstract class DatabaseInstaller { * @return string */ public function getReadableName() { - // Messages: config-type-mysql, config-type-postgres, config-type-sqlite, - // config-type-oracle + // Messages: config-type-mysql, config-type-postgres, config-type-sqlite return wfMessage( 'config-type-' . $this->getName() )->text(); } diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 5dc3aeca92..de154561c4 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -759,8 +759,7 @@ abstract class Installer { $allNames = []; - // Messages: config-type-mysql, config-type-postgres, config-type-oracle, - // config-type-sqlite + // Messages: config-type-mysql, config-type-postgres, config-type-sqlite foreach ( self::getDBTypes() as $name ) { $allNames[] = wfMessage( "config-type-$name" )->text(); } diff --git a/includes/installer/WebInstallerDBConnect.php b/includes/installer/WebInstallerDBConnect.php index 7546bdf9d2..3bacb76e99 100644 --- a/includes/installer/WebInstallerDBConnect.php +++ b/includes/installer/WebInstallerDBConnect.php @@ -48,8 +48,7 @@ class WebInstallerDBConnect extends WebInstallerPage { $settings = ''; $defaultType = $this->getVar( 'wgDBtype' ); - // Messages: config-dbsupport-mysql, config-dbsupport-postgres, config-dbsupport-oracle, - // config-dbsupport-sqlite, config-dbsupport-mssql + // Messages: config-dbsupport-mysql, config-dbsupport-postgres, config-dbsupport-sqlite $dbSupport = ''; foreach ( Installer::getDBTypes() as $type ) { $dbSupport .= wfMessage( "config-dbsupport-$type" )->plain() . "\n"; @@ -78,8 +77,7 @@ class WebInstallerDBConnect extends WebInstallerPage { ) . "\n"; - // Messages: config-header-mysql, config-header-postgres, config-header-oracle, - // config-header-sqlite + // Messages: config-header-mysql, config-header-postgres, config-header-sqlite $settings .= Html::openElement( 'div', [ diff --git a/includes/installer/i18n/en.json b/includes/installer/i18n/en.json index a9da56dc43..758221f2bb 100644 --- a/includes/installer/i18n/en.json +++ b/includes/installer/i18n/en.json @@ -83,13 +83,9 @@ "config-db-type": "Database type:", "config-db-host": "Database host:", "config-db-host-help": "If your database server is on a different server, enter the host name or IP address here.\n\nIf you are using shared web hosting, your hosting provider should give you the correct host name in their documentation.\n\nIf you are using MySQL, using \"localhost\" may not work for the server name. If it does not, try \"127.0.0.1\" for the local IP address.\n\nIf you are using PostgreSQL, leave this field blank to connect via a Unix socket.", - "config-db-host-oracle": "Database TNS:", - "config-db-host-oracle-help": "Enter a valid [http://download.oracle.com/docs/cd/B28359_01/network.111/b28317/tnsnames.htm Local Connect Name]; a tnsnames.ora file must be visible to this installation.
If you are using client libraries 10g or newer you can also use the [http://download.oracle.com/docs/cd/E11882_01/network.112/e10836/naming.htm Easy Connect] naming method.", "config-db-wiki-settings": "Identify this wiki", "config-db-name": "Database name (no hyphens):", "config-db-name-help": "Choose a name that identifies your wiki.\nIt should not contain spaces.\n\nIf you are using shared web hosting, your hosting provider will either give you a specific database name to use or let you create databases via a control panel.", - "config-db-name-oracle": "Database schema:", - "config-db-account-oracle-warn": "There are three supported scenarios for installing Oracle as database backend:\n\nIf you wish to create database account as part of the installation process, please supply an account with SYSDBA role as database account for installation and specify the desired credentials for the web-access account, otherwise you can either create the web-access account manually and supply only that account (if it has required permissions to create the schema objects) or supply two different accounts, one with create privileges and a restricted one for web access.\n\nScript for creating an account with required privileges can be found in \"maintenance/oracle/\" directory of this installation. Keep in mind that using a restricted account will disable all maintenance capabilities with the default account.", "config-db-install-account": "User account for installation", "config-db-username": "Database username:", "config-db-password": "Database password:", @@ -108,37 +104,24 @@ "config-pg-test-error": "Cannot connect to database $1: $2", "config-sqlite-dir": "SQLite data directory:", "config-sqlite-dir-help": "SQLite stores all data in a single file.\n\nThe directory you provide must be writable by the webserver during installation.\n\nIt should not be accessible via the web; this is why we're not putting it where your PHP files are.\n\nThe installer will write a .htaccess file along with it, but if that fails someone can gain access to your raw database.\nThat includes raw user data (email addresses, hashed passwords) as well as deleted revisions and other restricted data on the wiki.\n\nConsider putting the database somewhere else altogether, for example in /var/lib/mediawiki/yourwiki.", - "config-oracle-def-ts": "Default tablespace:", - "config-oracle-temp-ts": "Temporary tablespace:", "config-type-mysql": "MariaDB, MySQL, or compatible", "config-type-postgres": "PostgreSQL", "config-type-sqlite": "SQLite", - "config-type-oracle": "Oracle", - "config-type-mssql": "Microsoft SQL Server", "config-support-info": "MediaWiki supports the following database systems:\n\n$1\n\nIf you do not see the database system you are trying to use listed below, then follow the instructions linked above to enable support.", "config-dbsupport-mysql": "* [{{int:version-db-mariadb-url}} MariaDB] is the primary target for MediaWiki and is best supported. MediaWiki also works with [{{int:version-db-mysql-url}} MySQL] and [{{int:version-db-percona-url}} Percona Server], which are MariaDB compatible. ([https://www.php.net/manual/en/mysqli.installation.php How to compile PHP with MySQL support])", "config-dbsupport-postgres": "* [{{int:version-db-postgres-url}} PostgreSQL] is a popular open source database system as an alternative to MySQL. ([https://www.php.net/manual/en/pgsql.installation.php How to compile PHP with PostgreSQL support])", "config-dbsupport-sqlite": "* [{{int:version-db-sqlite-url}} SQLite] is a lightweight database system that is very well supported. ([https://www.php.net/manual/en/pdo.installation.php How to compile PHP with SQLite support], uses PDO)", - "config-dbsupport-oracle": "* [{{int:version-db-oracle-url}} Oracle] is a commercial enterprise database. ([https://www.php.net/manual/en/oci8.installation.php How to compile PHP with OCI8 support])", - "config-dbsupport-mssql": "* [{{int:version-db-mssql-url}} Microsoft SQL Server] is a commercial enterprise database for Windows. ([https://www.php.net/manual/en/sqlsrv.installation.php How to compile PHP with SQLSRV support])", "config-header-mysql": "MariaDB/MySQL settings", "config-header-postgres": "PostgreSQL settings", "config-header-sqlite": "SQLite settings", - "config-header-oracle": "Oracle settings", - "config-header-mssql": "Microsoft SQL Server settings", "config-invalid-db-type": "Invalid database type.", "config-missing-db-name": "You must enter a value for \"{{int:config-db-name}}\".", "config-missing-db-host": "You must enter a value for \"{{int:config-db-host}}\".", - "config-missing-db-server-oracle": "You must enter a value for \"{{int:config-db-host-oracle}}\".", - "config-invalid-db-server-oracle": "Invalid database TNS \"$1\".\nUse either \"TNS Name\" or an \"Easy Connect\" string ([http://docs.oracle.com/cd/E11882_01/network.112/e10836/naming.htm Oracle Naming Methods]).", "config-invalid-db-name": "Invalid database name \"$1\".\nUse only ASCII letters (a-z, A-Z), numbers (0-9), underscores (_) and hyphens (-).", "config-invalid-db-prefix": "Invalid database prefix \"$1\".\nUse only ASCII letters (a-z, A-Z), numbers (0-9), underscores (_) and hyphens (-).", "config-connection-error": "$1.\n\nCheck the host, username and password and try again. If using \"localhost\" as the database host, try using \"127.0.0.1\" instead (or vice versa).", "config-invalid-schema": "Invalid schema for MediaWiki \"$1\".\nUse only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).", - "config-db-sys-create-oracle": "Installer only supports using a SYSDBA account for creating a new account.", - "config-db-sys-user-exists-oracle": "User account \"$1\" already exists. SYSDBA can only be used for creating of a new account!", "config-postgres-old": "PostgreSQL $1 or later is required. You have $2.", - "config-mssql-old": "Microsoft SQL Server $1 or later is required. You have $2.", "config-sqlite-name-help": "Choose a name that identifies your wiki.\nDo not use spaces or hyphens.\nThis will be used for the SQLite data filename.", "config-sqlite-parent-unwritable-group": "Cannot create the data directory $1, because the parent directory $2 is not writable by the webserver.\n\nThe installer has determined the user your webserver is running as.\nMake the $3 directory writable by it to continue.\nOn a Unix/Linux system do:\n\n
cd $2\nmkdir $3\nchgrp $4 $3\nchmod g+w $3
", "config-sqlite-parent-unwritable-nogroup": "Cannot create the data directory $1, because the parent directory $2 is not writable by the webserver.\n\nThe installer could not determine the user your webserver is running as.\nMake the $3 directory globally writable by it (and others!) to continue.\nOn a Unix/Linux system do:\n\n
cd $2\nmkdir $3\nchmod a+w $3
", @@ -163,11 +146,6 @@ "config-mysql-engine": "Storage engine:", "config-mysql-innodb": "InnoDB (recommended)", "config-mysql-engine-help": "InnoDB is almost always the best option, since it has good concurrency support.\n\nMyISAM may be faster in single-user or read-only installations.\nMyISAM databases tend to get corrupted more often than InnoDB databases.", - "config-mssql-auth": "Authentication type:", - "config-mssql-install-auth": "Select the authentication type that will be used to connect to the database during the installation process.\nIf you select \"{{int:config-mssql-windowsauth}}\", the credentials of whatever user the webserver is running as will be used.", - "config-mssql-web-auth": "Select the authentication type that the web server will use to connect to the database server, during ordinary operation of the wiki.\nIf you select \"{{int:config-mssql-windowsauth}}\", the credentials of whatever user the webserver is running as will be used.", - "config-mssql-sqlauth": "SQL Server Authentication", - "config-mssql-windowsauth": "Windows Authentication", "config-site-name": "Name of wiki:", "config-site-name-help": "This will appear in the title bar of the browser and in various other places.", "config-site-name-blank": "Enter a site name.", diff --git a/includes/installer/i18n/qqq.json b/includes/installer/i18n/qqq.json index 039cd263af..42211b499f 100644 --- a/includes/installer/i18n/qqq.json +++ b/includes/installer/i18n/qqq.json @@ -106,13 +106,9 @@ "config-db-type": "Field label in the MediaWiki installer followed by possible database types.", "config-db-host": "Used as label.\n\nAlso used in {{msg-mw|Config-missing-db-host}}.", "config-db-host-help": "{{doc-singularthey}}", - "config-db-host-oracle": "TNS = [[w:Transparent Network Substrate]].\n\nUsed as label.\n\nAlso used in {{msg-mw|Config-missing-db-server-oracle}}.", - "config-db-host-oracle-help": "See also:\n* {{msg-mw|Config-invalid-db-server-oracle}}", "config-db-wiki-settings": "This is more acurate: \"Enter identifying or distinguishing data for this wiki\" since a MySQL database can host tables of several wikis.", "config-db-name": "Used as label.\n\nAlso used in {{msg-mw|Config-missing-db-name}}.\n{{Identical|Database name}}", "config-db-name-help": "Help box text in the MediaWiki installer.", - "config-db-name-oracle": "Field label in the MediaWiki installer where an Oracle database schema can be specified.", - "config-db-account-oracle-warn": "A \"[[:wikipedia:Front and back ends|backend]]\" is a system or component that ordinary users don't interact with directly and don't need to know about, and that is responsible for a distinct task or service - for example, a storage back-end is a generic system for storing data which other applications can use. Possible alternatives for back-end are \"system\" or \"service\", or (depending on context and language) even leave it untranslated.", "config-db-install-account": "Legend in the MediaWiki installer for the section where database username and password have to be provided.", "config-db-username": "Used as label.", "config-db-password": "Field label in the MediaWiki installer where database password has to be provided.", @@ -131,37 +127,24 @@ "config-pg-test-error": "Parameters:\n* $1 - database name\n* $2 - error message", "config-sqlite-dir": "Field label for a folder location.", "config-sqlite-dir-help": "{{doc-important|Do not translate .htaccess and /var/lib/mediawiki/yourwiki.}}\nUsed in help box.", - "config-oracle-def-ts": "Field label for an Oracle default tablespace.", - "config-oracle-temp-ts": "Field label for an Oracle temporary tablespace.", "config-type-mysql": "\"Or compatible\" refers to several database systems that are compatible with MySQL, as explained in {{msg-mw|config-dbsupport-mysql}}, and thus also work with this choice of database type.", "config-type-postgres": "{{optional}}", "config-type-sqlite": "{{optional}}", - "config-type-oracle": "{{optional}}", - "config-type-mssql": "{{optional}}", - "config-support-info": "Parameters:\n* $1 - a list of DBMSs that MediaWiki supports, composed with config-dbsupport-* messages.\nSee also:\n* {{msg-mw|Config-dbsupport-mysql}}\n* {{msg-mw|Config-dbsupport-postgres}}\n* {{msg-mw|Config-dbsupport-oracle}}\n* {{msg-mw|Config-dbsupport-sqlite}}\n* {{msg-mw|Config-dbsupport-mssql}}", + "config-support-info": "Parameters:\n* $1 - a list of DBMSs that MediaWiki supports, composed with config-dbsupport-* messages.\nSee also:\n* {{msg-mw|Config-dbsupport-mysql}}\n* {{msg-mw|Config-dbsupport-postgres}}\n* {{msg-mw|Config-dbsupport-sqlite}}", "config-dbsupport-mysql": "Used in:\n* {{msg-mw|config-support-info}}\n{{Related|Config-dbsupport}}", "config-dbsupport-postgres": "Used in:\n* {{msg-mw|config-support-info}}\n{{Related|Config-dbsupport}}", "config-dbsupport-sqlite": "Used in:\n* {{msg-mw|config-support-info}}\n{{Related|Config-dbsupport}}", - "config-dbsupport-oracle": "Used in:\n* {{msg-mw|Config-support-info}}.\n{{Related|Config-dbsupport}}", - "config-dbsupport-mssql": "Used in:\n* {{msg-mw|Config-support-info}}\n{{Related|Config-dbsupport}}", "config-header-mysql": "Header for MySQL database settings in the MediaWiki installer.", "config-header-postgres": "Header for PostgreSQL database settings in the MediaWiki installer.", "config-header-sqlite": "Header for SQLite database settings in the MediaWiki installer.", - "config-header-oracle": "Header for Oracle database settings in the MediaWiki installer.", - "config-header-mssql": "Used as a section heading on the installer form, inside of a fieldset", "config-invalid-db-type": "Error message in MediaWiki installer when an invalid database type has been provided.", "config-missing-db-name": "Refers to {{msg-mw|Config-db-name}}.\n{{Related|Config-missing}}", "config-missing-db-host": "Refers to {{msg-mw|Config-db-host}}.\n{{Related|Config-missing}}", - "config-missing-db-server-oracle": "Refers to {{msg-mw|Config-db-host-oracle}}.\n{{Related|Config-missing}}", - "config-invalid-db-server-oracle": "Used as error message. Parameters:\n* $1 - database server name\nSee also:\n* {{msg-mw|Config-db-host-oracle-help}}", "config-invalid-db-name": "Used as error message. Parameters:\n* $1 - database name\nSee also:\n* {{msg-mw|Config-invalid-db-prefix}}", "config-invalid-db-prefix": "Used as error message. Parameters:\n* $1 - database prefix\nSee also:\n* {{msg-mw|Config-invalid-db-name}}", "config-connection-error": "$1 is the external error from the database, such as \"DB connection error: Access denied for user 'dba'@'localhost' (using password: YES) (localhost).\"\n\nIf you're translating this message to a right-to-left language, consider writing
$1.
. (When the bidi features for HTML5 will be implemented in the browsers, it will probably be a good idea to write it as
$1.
.)", "config-invalid-schema": "*$1 - schema name", - "config-db-sys-create-oracle": "Error message in the MediaWiki installer when Oracle is used as database and an incorrect user account type has been provided.", - "config-db-sys-user-exists-oracle": "Used as error message. Parameters:\n* $1 - database username", "config-postgres-old": "Used as error message. Used as warning. Parameters:\n* $1 - minimum version\n* $2 - the version of PostgreSQL that has been installed\n{{Related|Config-old}}", - "config-mssql-old": "Used as an error message. Parameters:\n* $1 - minimum version\n* $2 - the version of Microsoft SQL Server that has been installed\n{{Related|Config-old}}", "config-sqlite-name-help": "Help text for the form field for the SQLite data file name.", "config-sqlite-parent-unwritable-group": "Used as SQLite error message. Parameters:\n* $1 - data directory\n* $2 - \"dirname\" part of $1\n* $3 - \"basename\" part of $1\n* $4 - web server's primary group name\nSee also:\n* {{msg-mw|Config-sqlite-parent-unwritable-nogroup}}", "config-sqlite-parent-unwritable-nogroup": "Used as SQLite error message. Parameters:\n* $1 - data directory\n* $2 - \"dirname\" part of $1\n* $3 - \"basename\" part of $1\nSee also:\n* {{msg-mw|Config-sqlite-parent-unwritable-group}}", @@ -186,11 +169,6 @@ "config-mysql-engine": "Field label for MySQL storage engine in the MediaWiki installer.", "config-mysql-innodb": "Option for the MySQL storage engine in the MediaWiki installer.", "config-mysql-engine-help": "Help text in MediaWiki installer with advice for picking a MySQL storage engine.", - "config-mssql-auth": "Radio button group label.\n\nFollowed by the following radio button labels:\n* {{msg-mw|Config-mssql-sqlauth}}\n* {{msg-mw|Config-mssql-windowsauth}}", - "config-mssql-install-auth": "Used as the help text for the \"Authentication type\" radio button when typing in database settings for installation.\n\nRefers to {{msg-mw|Config-mssql-windowsauth}}.\n\nSee also:\n* {{msg-mw|Config-mssql-web-auth}}", - "config-mssql-web-auth": "Used as the help text for the \"Authentication type\" radio button when typing in database settings for normal wiki usage.\n\nRefers to {{msg-mw|Config-mssql-windowsauth}}.\n\nSee also:\n* {{msg-mw|Config-mssql-install-auth}}", - "config-mssql-sqlauth": "Radio button.\n\n\"SQL Server\" refers to \"Microsoft SQL Server\".\n\nSee also:\n* {{msg-mw|Config-mssql-windowsauth}}", - "config-mssql-windowsauth": "Radio button. The official term is \"Integrated Windows Authentication\" but Microsoft itself uses \"Windows Authentication\" elsewhere in Microsoft SQL Server as a synonym.\n\nAlso used in:\n* {{msg-mw|Config-mssql-install-auth}}\n* {{msg-mw|Config-mssql-web-auth}}\n\nSee also:\n* {{msg-mw|Config-mssql-sqlauth}}", "config-site-name": "Field label for the form field where a wiki name has to be entered.", "config-site-name-help": "Help text for the form field where a wiki name has to be entered.", "config-site-name-blank": "Error text in the MediaWiki installer when the site name is left empty.", diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index e3c20a2cee..29453082ef 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -1265,7 +1265,7 @@ class ParserTestRunner { $tables[] = 'revision_actor_temp'; } - if ( in_array( $this->db->getType(), [ 'mysql', 'sqlite', 'oracle' ] ) ) { + if ( in_array( $this->db->getType(), [ 'mysql', 'sqlite' ] ) ) { array_push( $tables, 'searchindex' ); } @@ -1305,11 +1305,7 @@ class ParserTestRunner { $this->db = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_MASTER ); $dbType = $this->db->getType(); - if ( $dbType == 'oracle' ) { - $suspiciousPrefixes = [ 'pt_', MediaWikiTestCase::ORA_DB_PREFIX ]; - } else { - $suspiciousPrefixes = [ 'parsertest_', MediaWikiTestCase::DB_PREFIX ]; - } + $suspiciousPrefixes = [ 'parsertest_', MediaWikiTestCase::DB_PREFIX ]; if ( in_array( $wgDBprefix, $suspiciousPrefixes ) ) { throw new MWException( "\$wgDBprefix=$wgDBprefix suggests DB setup is already done" ); } @@ -1324,23 +1320,13 @@ class ParserTestRunner { } $temporary = $this->useTemporaryTables || $dbType == 'postgres'; - $prefix = $dbType != 'oracle' ? 'parsertest_' : 'pt_'; + $prefix = 'parsertest_'; $this->dbClone = new CloneDatabase( $this->db, $this->listTables(), $prefix ); $this->dbClone->useTemporaryTables( $temporary ); $this->dbClone->cloneTableStructure(); CloneDatabase::changePrefix( $prefix ); - if ( $dbType == 'oracle' ) { - $this->db->query( 'BEGIN FILL_WIKI_INFO; END;' ); - # Insert 0 user to prevent FK violations - - # Anonymous user - $this->db->insert( 'user', [ - 'user_id' => 0, - 'user_name' => 'Anonymous' ] ); - } - $teardown[] = function () { $this->teardownDatabase(); }; @@ -1542,15 +1528,7 @@ class ParserTestRunner { $tables = $this->listTables(); foreach ( $tables as $table ) { - if ( $this->db->getType() == 'oracle' ) { - $this->db->query( "DROP TABLE pt_$table DROP CONSTRAINTS" ); - } else { - $this->db->query( "DROP TABLE `parsertest_$table`" ); - } - } - - if ( $this->db->getType() == 'oracle' ) { - $this->db->query( 'BEGIN FILL_WIKI_INFO; END;' ); + $this->db->query( "DROP TABLE `parsertest_$table`" ); } } diff --git a/tests/phpunit/MediaWikiIntegrationTestCase.php b/tests/phpunit/MediaWikiIntegrationTestCase.php index 07d135de8d..7aa161484e 100644 --- a/tests/phpunit/MediaWikiIntegrationTestCase.php +++ b/tests/phpunit/MediaWikiIntegrationTestCase.php @@ -136,10 +136,9 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { private $overriddenServices = []; /** - * Table name prefixes. Oracle likes it shorter. + * Table name prefix. */ const DB_PREFIX = 'unittest_'; - const ORA_DB_PREFIX = 'ut_'; /** * @var array @@ -149,7 +148,6 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { 'mysql', 'sqlite', 'postgres', - 'oracle' ]; public function __construct( $name = null, array $data = [], $dataName = '' ) { @@ -1318,7 +1316,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { * @since 1.32 */ public static function getTestPrefixFor( IDatabase $db ) { - return $db->getType() == 'oracle' ? self::ORA_DB_PREFIX : self::DB_PREFIX; + return self::DB_PREFIX; } /** @@ -1411,32 +1409,6 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { * @since 1.32 */ protected function addCoreDBData() { - if ( $this->db->getType() == 'oracle' ) { - # Insert 0 user to prevent FK violations - # Anonymous user - if ( !$this->db->selectField( 'user', '1', [ 'user_id' => 0 ] ) ) { - $this->db->insert( 'user', [ - 'user_id' => 0, - 'user_name' => 'Anonymous' ], __METHOD__, [ 'IGNORE' ] ); - } - - # Insert 0 page to prevent FK violations - # Blank page - if ( !$this->db->selectField( 'page', '1', [ 'page_id' => 0 ] ) ) { - $this->db->insert( 'page', [ - 'page_id' => 0, - 'page_namespace' => 0, - 'page_title' => ' ', - 'page_restrictions' => null, - 'page_is_redirect' => 0, - 'page_is_new' => 0, - 'page_random' => 0, - 'page_touched' => $this->db->timestamp(), - 'page_latest' => 0, - 'page_len' => 0 ], __METHOD__, [ 'IGNORE' ] ); - } - } - SiteStatsInit::doPlaceholderInit(); User::resetIdByNameCache(); @@ -1520,7 +1492,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { $prefix = self::getTestPrefixFor( $db ); } - if ( ( $db->getType() == 'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) { + if ( !self::$useTemporaryTables && self::$reuseDB ) { $db->tablePrefix( $prefix ); return false; } @@ -1609,12 +1581,6 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { return; } - // Assuming this isn't needed for External Store database, and not sure if the procedure - // would be available there. - if ( $db->getType() == 'oracle' ) { - $db->query( 'BEGIN FILL_WIKI_INFO; END;', __METHOD__ ); - } - Hooks::run( 'UnitTestsAfterDatabaseSetup', [ $db, $prefix ] ); } @@ -1928,7 +1894,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { $tablesUsed = array_unique( array_merge( $tablesUsed, $pageTables ) ); } - // Postgres, Oracle, and MSSQL all use mwuser/pagecontent + // Postgres uses mwuser/pagecontent // instead of user/text. But Postgres does not remap the // table name in tableExists(), so we mark the real table // names as being used. @@ -1971,7 +1937,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { return; } - $truncate = in_array( $db->getType(), [ 'oracle', 'mysql' ] ); + $truncate = in_array( $db->getType(), [ 'mysql' ] ); if ( $truncate ) { $db->query( 'TRUNCATE TABLE ' . $db->tableName( $tableName ), __METHOD__ ); diff --git a/tests/phpunit/includes/db/LoadBalancerTest.php b/tests/phpunit/includes/db/LoadBalancerTest.php index bf5326a440..588fe67e9f 100644 --- a/tests/phpunit/includes/db/LoadBalancerTest.php +++ b/tests/phpunit/includes/db/LoadBalancerTest.php @@ -341,9 +341,9 @@ class LoadBalancerTest extends MediaWikiTestCase { private function assertWriteAllowed( Database $db ) { $table = $db->tableName( 'some_table' ); // Trigger a transaction so that rollback() will remove all the tables. - // Don't do this for MySQL/Oracle as they auto-commit transactions for DDL + // Don't do this for MySQL as they auto-commit transactions for DDL // statements such as CREATE TABLE. - $useAtomicSection = in_array( $db->getType(), [ 'sqlite', 'postgres', 'mssql' ], true ); + $useAtomicSection = in_array( $db->getType(), [ 'sqlite', 'postgres' ], true ); try { $db->dropTable( 'some_table' ); // clear for sanity $this->assertNotEquals( $db::STATUS_TRX_ERROR, $db->trxStatus() ); diff --git a/tests/phpunit/suites/ParserTestTopLevelSuite.php b/tests/phpunit/suites/ParserTestTopLevelSuite.php index f318df1dd7..0e8b77552d 100644 --- a/tests/phpunit/suites/ParserTestTopLevelSuite.php +++ b/tests/phpunit/suites/ParserTestTopLevelSuite.php @@ -141,8 +141,7 @@ class ParserTestTopLevelSuite extends PHPUnit_Framework_TestSuite { $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); $db = $lb->getConnection( DB_MASTER ); $type = $db->getType(); - $prefix = $type === 'oracle' ? - MediaWikiTestCase::ORA_DB_PREFIX : MediaWikiTestCase::DB_PREFIX; + $prefix = MediaWikiTestCase::DB_PREFIX; $this->oldTablePrefix = $db->tablePrefix(); MediaWikiTestCase::setupTestDB( $db, $prefix ); CloneDatabase::changePrefix( $prefix ); -- 2.20.1