summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-07-29 22:59:31 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-07-29 22:59:31 +0200
commitaff11d7a790d5c67b712eb947c9642c32cbc6fdd (patch)
treea4a91ce47473df6ff46146512065c89a5f598cd0
parentddb32d42d298727918f4e704d7e61eae60afcd3c (diff)
parent8bc4a10dbe6235571ab8399bbcc41d2cfb9b89aa (diff)
downloadnextcloud-server-aff11d7a790d5c67b712eb947c9642c32cbc6fdd.tar.gz
nextcloud-server-aff11d7a790d5c67b712eb947c9642c32cbc6fdd.zip
Merge pull request #17966 from owncloud/remove-mssql
Remove remainings of mssql
-rw-r--r--core/command/db/converttype.php5
-rw-r--r--core/js/setup.js5
-rw-r--r--core/templates/installation.php3
-rw-r--r--lib/private/db.php2
-rw-r--r--lib/private/db/connectionfactory.php6
-rw-r--r--lib/private/db/mdb2schemamanager.php3
-rw-r--r--lib/private/db/mssqlmigrator.php37
-rw-r--r--lib/private/setup.php7
-rw-r--r--lib/private/setup/mssql.php203
-rw-r--r--lib/private/setup/mysql.php2
-rw-r--r--tests/lib/db/mdb2schemamanager.php4
-rw-r--r--tests/lib/db/migrator.php6
-rw-r--r--tests/lib/dbschema.php3
-rw-r--r--tests/lib/setup.php9
14 files changed, 11 insertions, 284 deletions
diff --git a/core/command/db/converttype.php b/core/command/db/converttype.php
index e6c0f5caa35..dd91d86b8d7 100644
--- a/core/command/db/converttype.php
+++ b/core/command/db/converttype.php
@@ -115,11 +115,6 @@ class ConvertType extends Command {
'Converting to SQLite (sqlite3) is currently not supported.'
);
}
- if ($type === 'mssql') {
- throw new \InvalidArgumentException(
- 'Converting to Microsoft SQL Server (mssql) is currently not supported.'
- );
- }
if ($type === $this->config->getSystemValue('dbtype', '')) {
throw new \InvalidArgumentException(sprintf(
'Can not convert from %1$s to %1$s.',
diff --git a/core/js/setup.js b/core/js/setup.js
index cfa11a99c3a..cb299597451 100644
--- a/core/js/setup.js
+++ b/core/js/setup.js
@@ -4,8 +4,7 @@ $(document).ready(function() {
sqlite:!!$('#hasSQLite').val(),
mysql:!!$('#hasMySQL').val(),
postgresql:!!$('#hasPostgreSQL').val(),
- oracle:!!$('#hasOracle').val(),
- mssql:!!$('#hasMSSQL').val()
+ oracle:!!$('#hasOracle').val()
};
$('#selectDbType').buttonset();
@@ -28,7 +27,7 @@ $(document).ready(function() {
$('#dbname').attr('pattern','[0-9a-zA-Z$_-]+');
});
- $('#mysql,#pgsql,#mssql').click(function() {
+ $('#mysql,#pgsql').click(function() {
$('#use_other_db').slideDown(250);
$('#use_oracle_db').slideUp(250);
$('#sqliteInformation').hide();
diff --git a/core/templates/installation.php b/core/templates/installation.php
index b686a1ca68c..8db55e4bdab 100644
--- a/core/templates/installation.php
+++ b/core/templates/installation.php
@@ -8,7 +8,6 @@ script('core', [
<input type='hidden' id='hasSQLite' value='<?php p($_['hasSQLite']) ?>'>
<input type='hidden' id='hasPostgreSQL' value='<?php p($_['hasPostgreSQL']) ?>'>
<input type='hidden' id='hasOracle' value='<?php p($_['hasOracle']) ?>'>
-<input type='hidden' id='hasMSSQL' value='<?php p($_['hasMSSQL']) ?>'>
<form action="index.php" method="post">
<input type="hidden" name="install" value="true">
<?php if(count($_['errors']) > 0): ?>
@@ -79,7 +78,7 @@ script('core', [
<?php if(!$_['dbIsSet'] OR count($_['errors']) > 0): ?>
<fieldset id='databaseBackend'>
- <?php if($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'] or $_['hasMSSQL'])
+ <?php if($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'])
$hasOtherDB = true; else $hasOtherDB =false; //other than SQLite ?>
<legend><?php p($l->t( 'Configure the database' )); ?></legend>
<div id="selectDbType">
diff --git a/lib/private/db.php b/lib/private/db.php
index 1e93eb1892e..a4a7b7d17d4 100644
--- a/lib/private/db.php
+++ b/lib/private/db.php
@@ -121,7 +121,7 @@ class OC_DB {
if (is_string($stmt)) {
// convert to an array with 'sql'
if (stripos($stmt, 'LIMIT') !== false) { //OFFSET requires LIMIT, so we only need to check for LIMIT
- // TODO try to convert LIMIT OFFSET notation to parameters, see fixLimitClauseForMSSQL
+ // TODO try to convert LIMIT OFFSET notation to parameters
$message = 'LIMIT and OFFSET are forbidden for portability reasons,'
. ' pass an array with \'limit\' and \'offset\' instead';
throw new \OC\DatabaseException($message);
diff --git a/lib/private/db/connectionfactory.php b/lib/private/db/connectionfactory.php
index 83a59cddd7f..b6c3396e147 100644
--- a/lib/private/db/connectionfactory.php
+++ b/lib/private/db/connectionfactory.php
@@ -39,12 +39,6 @@ class ConnectionFactory {
* \Doctrine\DBAL\DriverManager::getConnection().
*/
protected $defaultConnectionParams = array(
- 'mssql' => array(
- 'adapter' => '\OC\DB\AdapterSQLSrv',
- 'charset' => 'UTF8',
- 'driver' => 'pdo_sqlsrv',
- 'wrapperClass' => 'OC\DB\Connection',
- ),
'mysql' => array(
'adapter' => '\OC\DB\AdapterMySQL',
'charset' => 'UTF8',
diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php
index 6b9888d361b..aef485ed686 100644
--- a/lib/private/db/mdb2schemamanager.php
+++ b/lib/private/db/mdb2schemamanager.php
@@ -32,7 +32,6 @@ use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
-use Doctrine\DBAL\Platforms\SQLServerPlatform;
class MDB2SchemaManager {
/**
@@ -85,8 +84,6 @@ class MDB2SchemaManager {
return new OracleMigrator($this->conn, $random, $config);
} else if ($platform instanceof MySqlPlatform) {
return new MySQLMigrator($this->conn, $random, $config);
- } else if ($platform instanceof SQLServerPlatform) {
- return new MsSqlMigrator($this->conn, $random, $config);
} else if ($platform instanceof PostgreSqlPlatform) {
return new Migrator($this->conn, $random, $config);
} else {
diff --git a/lib/private/db/mssqlmigrator.php b/lib/private/db/mssqlmigrator.php
deleted file mode 100644
index bedb5bac6c4..00000000000
--- a/lib/private/db/mssqlmigrator.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-/**
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OC\DB;
-
-use Doctrine\DBAL\Schema\Schema;
-
-class MsSqlMigrator extends Migrator {
-
- /**
- * @param \Doctrine\DBAL\Schema\Schema $targetSchema
- */
- public function migrate(Schema $targetSchema) {
- throw new MigrationException('',
- 'Database migration is required to continue operation. This feature is provided within the Enterprise Edition.');
- }
-
-}
diff --git a/lib/private/setup.php b/lib/private/setup.php
index 50bf0dceafc..870480feaa0 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -69,7 +69,6 @@ class Setup {
'mysql' => '\OC\Setup\MySQL',
'pgsql' => '\OC\Setup\PostgreSQL',
'oci' => '\OC\Setup\OCI',
- 'mssql' => '\OC\Setup\MSSQL',
'sqlite' => '\OC\Setup\Sqlite',
'sqlite3' => '\OC\Setup\Sqlite',
);
@@ -120,11 +119,6 @@ class Setup {
'type' => 'function',
'call' => 'oci_connect',
'name' => 'Oracle'
- ),
- 'mssql' => array(
- 'type' => 'function',
- 'call' => 'sqlsrv_connect',
- 'name' => 'MS SQL'
)
);
if ($allowAllDatabases) {
@@ -218,7 +212,6 @@ class Setup {
'hasMySQL' => isset($databases['mysql']),
'hasPostgreSQL' => isset($databases['pgsql']),
'hasOracle' => isset($databases['oci']),
- 'hasMSSQL' => isset($databases['mssql']),
'databases' => $databases,
'directory' => $dataDir,
'htaccessWorking' => $htAccessWorking,
diff --git a/lib/private/setup/mssql.php b/lib/private/setup/mssql.php
deleted file mode 100644
index 0ae02d6cbcc..00000000000
--- a/lib/private/setup/mssql.php
+++ /dev/null
@@ -1,203 +0,0 @@
-<?php
-/**
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Joas Schilling <nickvergessen@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OC\Setup;
-
-class MSSQL extends AbstractDatabase {
- public $dbprettyname = 'MS SQL Server';
-
- public function setupDatabase($username) {
- //check if the database user has admin right
- $masterConnectionInfo = array( "Database" => "master", "UID" => $this->dbuser, "PWD" => $this->dbpassword);
-
- $masterConnection = @sqlsrv_connect($this->dbhost, $masterConnectionInfo);
- if(!$masterConnection) {
- $entry = '';
- if( ($errors = sqlsrv_errors() ) != null) {
- $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
- }
- throw new \OC\DatabaseSetupException($this->trans->t('MS SQL username and/or password not valid: %s', array($entry)),
- $this->trans->t('You need to enter either an existing account or the administrator.'));
- }
-
- \OC_Config::setValues([
- 'dbuser' => $this->dbuser,
- 'dbpassword' => $this->dbpassword,
- ]);
-
- $this->createDBLogin($masterConnection);
-
- $this->createDatabase($masterConnection);
-
- $this->createDBUser($masterConnection);
-
- sqlsrv_close($masterConnection);
-
- $this->createDatabaseStructure();
- }
-
- private function createDBLogin($connection) {
- $query = "SELECT * FROM master.sys.server_principals WHERE name = '".$this->dbuser."';";
- $result = sqlsrv_query($connection, $query);
- if ($result === false) {
- if ( ($errors = sqlsrv_errors() ) != null) {
- $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
- } else {
- $entry = '';
- }
- $entry.='Offending command was: '.$query.'<br />';
- \OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
- } else {
- $row = sqlsrv_fetch_array($result);
-
- if ($row === false) {
- if ( ($errors = sqlsrv_errors() ) != null) {
- $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
- } else {
- $entry = '';
- }
- $entry.='Offending command was: '.$query.'<br />';
- \OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
- } else {
- if ($row == null) {
- $query = "CREATE LOGIN [".$this->dbuser."] WITH PASSWORD = '".$this->dbpassword."';";
- $result = sqlsrv_query($connection, $query);
- if (!$result or $result === false) {
- if ( ($errors = sqlsrv_errors() ) != null) {
- $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
- } else {
- $entry = '';
- }
- $entry.='Offending command was: '.$query.'<br />';
- \OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
- }
- }
- }
- }
- }
-
- private function createDBUser($connection) {
- $query = "SELECT * FROM [".$this->dbname."].sys.database_principals WHERE name = '".$this->dbuser."';";
- $result = sqlsrv_query($connection, $query);
- if ($result === false) {
- if ( ($errors = sqlsrv_errors() ) != null) {
- $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
- } else {
- $entry = '';
- }
- $entry.='Offending command was: '.$query.'<br />';
- \OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
- } else {
- $row = sqlsrv_fetch_array($result);
-
- if ($row === false) {
- if ( ($errors = sqlsrv_errors() ) != null) {
- $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
- } else {
- $entry = '';
- }
- $entry.='Offending command was: '.$query.'<br />';
- \OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
- } else {
- if ($row == null) {
- $query = "USE [".$this->dbname."]; CREATE USER [".$this->dbuser."] FOR LOGIN [".$this->dbuser."];";
- $result = sqlsrv_query($connection, $query);
- if (!$result || $result === false) {
- if ( ($errors = sqlsrv_errors() ) != null) {
- $entry = 'DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
- } else {
- $entry = '';
- }
- $entry.='Offending command was: '.$query.'<br />';
- \OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
- }
- }
-
- $query = "USE [".$this->dbname."]; EXEC sp_addrolemember 'db_owner', '".$this->dbuser."';";
- $result = sqlsrv_query($connection, $query);
- if (!$result || $result === false) {
- if ( ($errors = sqlsrv_errors() ) != null) {
- $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
- } else {
- $entry = '';
- }
- $entry.='Offending command was: '.$query.'<br />';
- \OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
- }
- }
- }
- }
-
- private function createDatabase($connection) {
- $query = "CREATE DATABASE [".$this->dbname."];";
- $result = sqlsrv_query($connection, $query);
- if (!$result || $result === false) {
- if ( ($errors = sqlsrv_errors() ) != null) {
- $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
- } else {
- $entry = '';
- }
- $entry.='Offending command was: '.$query.'<br />';
- \OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
- }
- }
-
- private function createDatabaseStructure() {
- $connectionInfo = array( "Database" => $this->dbname, "UID" => $this->dbuser, "PWD" => $this->dbpassword);
-
- $connection = @sqlsrv_connect($this->dbhost, $connectionInfo);
-
- //fill the database if needed
- $query = "SELECT * FROM INFORMATION_SCHEMA.TABLES"
- ." WHERE TABLE_SCHEMA = '".$this->dbname."'"
- ." AND TABLE_NAME = '".$this->tableprefix."users'";
- $result = sqlsrv_query($connection, $query);
- if ($result === false) {
- if ( ($errors = sqlsrv_errors() ) != null) {
- $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
- } else {
- $entry = '';
- }
- $entry.='Offending command was: '.$query.'<br />';
- \OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
- } else {
- $row = sqlsrv_fetch_array($result);
-
- if ($row === false) {
- if ( ($errors = sqlsrv_errors() ) != null) {
- $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
- } else {
- $entry = '';
- }
- $entry.='Offending command was: '.$query.'<br />';
- \OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
- } else {
- if ($row == null) {
- \OC_DB::createDbFromStructure($this->dbDefinitionFile);
- }
- }
- }
-
- sqlsrv_close($connection);
- }
-}
diff --git a/lib/private/setup/mysql.php b/lib/private/setup/mysql.php
index c01ff724b80..9cf102393b8 100644
--- a/lib/private/setup/mysql.php
+++ b/lib/private/setup/mysql.php
@@ -103,7 +103,7 @@ class MySQL extends AbstractDatabase {
if(!$result) {
$entry = $this->trans->t('DB Error: "%s"', array(mysql_error($connection))) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
- \OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
+ \OCP\Util::writeLog('setup.mysql', $entry, \OCP\Util::WARN);
}
$query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'";
diff --git a/tests/lib/db/mdb2schemamanager.php b/tests/lib/db/mdb2schemamanager.php
index e20f4c421b8..8ce6febf3ac 100644
--- a/tests/lib/db/mdb2schemamanager.php
+++ b/tests/lib/db/mdb2schemamanager.php
@@ -10,7 +10,6 @@
namespace Test\DB;
use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\SQLServerPlatform;
class MDB2SchemaManager extends \Test\TestCase {
@@ -30,9 +29,6 @@ class MDB2SchemaManager extends \Test\TestCase {
if ($connection->getDatabasePlatform() instanceof OraclePlatform) {
$this->markTestSkipped('Adding auto increment columns in Oracle is not supported.');
}
- if ($connection->getDatabasePlatform() instanceof SQLServerPlatform) {
- $this->markTestSkipped('DB migration tests are not supported on MSSQL');
- }
$manager = new \OC\DB\MDB2SchemaManager($connection);
diff --git a/tests/lib/db/migrator.php b/tests/lib/db/migrator.php
index 6bde68c2d20..4d558909743 100644
--- a/tests/lib/db/migrator.php
+++ b/tests/lib/db/migrator.php
@@ -11,9 +11,9 @@ namespace Test\DB;
use \Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\SQLServerPlatform;
use \Doctrine\DBAL\Schema\Schema;
use \Doctrine\DBAL\Schema\SchemaConfig;
+use OCP\IConfig;
class Migrator extends \Test\TestCase {
/**
@@ -31,6 +31,7 @@ class Migrator extends \Test\TestCase {
**/
private $config;
+ /** @var string */
private $tableName;
protected function setUp() {
@@ -41,9 +42,6 @@ class Migrator extends \Test\TestCase {
if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
$this->markTestSkipped('DB migration tests are not supported on OCI');
}
- if ($this->connection->getDatabasePlatform() instanceof SQLServerPlatform) {
- $this->markTestSkipped('DB migration tests are not supported on MSSQL');
- }
$this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
$this->tableName = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_'));
}
diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php
index cfaebec079e..97307664b6a 100644
--- a/tests/lib/dbschema.php
+++ b/tests/lib/dbschema.php
@@ -47,9 +47,6 @@ class Test_DBSchema extends \Test\TestCase {
*/
public function testSchema() {
$platform = \OC_DB::getConnection()->getDatabasePlatform();
- if ($platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform) {
- $this->markTestSkipped("Test not relevant on MSSQL");
- }
$this->doTestSchemaCreating();
$this->doTestSchemaChanging();
$this->doTestSchemaDumping();
diff --git a/tests/lib/setup.php b/tests/lib/setup.php
index 79ca0c0be90..d07eaa40ee0 100644
--- a/tests/lib/setup.php
+++ b/tests/lib/setup.php
@@ -76,19 +76,19 @@ class Test_OC_Setup extends \Test\TestCase {
$this->assertSame(array(), $result);
}
- public function testGetSupportedDatabasesWitAllWorking() {
+ public function testGetSupportedDatabasesWithAllWorking() {
$this->config
->expects($this->once())
->method('getSystemValue')
->will($this->returnValue(
- array('sqlite', 'mysql', 'pgsql', 'oci', 'mssql')
+ array('sqlite', 'mysql', 'pgsql', 'oci')
));
$this->setupClass
->expects($this->once())
->method('class_exists')
->will($this->returnValue(true));
$this->setupClass
- ->expects($this->exactly(4))
+ ->expects($this->exactly(3))
->method('is_callable')
->will($this->returnValue(true));
$result = $this->setupClass->getSupportedDatabases();
@@ -96,8 +96,7 @@ class Test_OC_Setup extends \Test\TestCase {
'sqlite' => 'SQLite',
'mysql' => 'MySQL/MariaDB',
'pgsql' => 'PostgreSQL',
- 'oci' => 'Oracle',
- 'mssql' => 'MS SQL'
+ 'oci' => 'Oracle'
);
$this->assertSame($expectedResult, $result);
}