]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove OC_DB::getConnection
authorMorris Jobke <hey@morrisjobke.de>
Thu, 7 Jan 2016 09:26:00 +0000 (10:26 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 7 Jan 2016 13:54:55 +0000 (14:54 +0100)
20 files changed:
core/command/db/converttype.php
core/command/db/generatechangescript.php
lib/private/db.php
lib/private/files/cache/storage.php
lib/private/repair.php
lib/private/repair/innodb.php
lib/private/repair/searchlucenetables.php
lib/private/server.php
lib/private/share/share.php
lib/private/tags.php
tests/lib/app.php
tests/lib/db/mdb2schemamanager.php
tests/lib/db/migrator.php
tests/lib/db/mysqlmigration.php
tests/lib/db/sqlitemigration.php
tests/lib/dbschema.php
tests/lib/repair/repaircollation.php
tests/lib/repair/repairinnodb.php
tests/lib/repair/repairsqliteautoincrement.php
tests/lib/tags.php

index dd91d86b8d75123af1dd0110f205951270e9f901..77e614a5853d40a55f57e0e80cd7eefbb8b91e4f 100644 (file)
@@ -166,7 +166,7 @@ class ConvertType extends Command {
                $this->validateInput($input, $output);
                $this->readPassword($input, $output);
 
-               $fromDB = \OC_DB::getConnection();
+               $fromDB = \OC::$server->getDatabaseConnection();
                $toDB = $this->getToDBConnection($input, $output);
 
                if ($input->getOption('clear-schema')) {
index 956921206f9cdba38a7c1f1d425f75ab0f84dbd4..c94a6a9b0e4d6068158d562423fd6965bf7ae856 100644 (file)
@@ -45,7 +45,7 @@ class GenerateChangeScript extends Command {
 
                $file = $input->getArgument('schema-xml');
 
-               $schemaManager = new \OC\DB\MDB2SchemaManager(\OC_DB::getConnection());
+               $schemaManager = new \OC\DB\MDB2SchemaManager(\OC::$server->getDatabaseConnection());
 
                try {
                        $result = $schemaManager->updateDbFromStructure($file, true);
index 14d9ba0a4938bfa20b56db55b158c9557422ec83..d47b7d4f31a342082e774c44738c8ccd18f89fd4 100644 (file)
  */
 class OC_DB {
 
-       /**
-        * @return \OCP\IDBConnection
-        */
-       static public function getConnection() {
-               return \OC::$server->getDatabaseConnection();
-       }
-
        /**
         * get MDB2 schema manager
         *
index e5235d1ca92d49f275b9aec21c334af69f01a24d..4998c622e84d03d0eca5605dd3dc5400d86c0850 100644 (file)
@@ -58,10 +58,10 @@ class Storage {
                if ($row = self::getStorageById($this->storageId)) {
                        $this->numericId = $row['numeric_id'];
                } else {
-                       $connection = \OC_DB::getConnection();
+                       $connection = \OC::$server->getDatabaseConnection();
                        $available = $isAvailable ? 1 : 0;
                        if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId, 'available' => $available])) {
-                               $this->numericId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*storages');
+                               $this->numericId = $connection->lastInsertId('*PREFIX*storages');
                        } else {
                                if ($row = self::getStorageById($this->storageId)) {
                                        $this->numericId = $row['numeric_id'];
index d870b472c4f1ad50b21c7dae3618d97219fd63ef..269fe4c5f097f0e9a6e09b64deed2b69947e5c9b 100644 (file)
@@ -136,10 +136,11 @@ class Repair extends BasicEmitter {
         * @return array of RepairStep instances
         */
        public static function getBeforeUpgradeRepairSteps() {
+               $connection = \OC::$server->getDatabaseConnection();
                $steps = [
                        new InnoDB(),
-                       new Collation(\OC::$server->getConfig(), \OC_DB::getConnection()),
-                       new SqliteAutoincrement(\OC_DB::getConnection()),
+                       new Collation(\OC::$server->getConfig(), $connection),
+                       new SqliteAutoincrement($connection),
                        new SearchLuceneTables(),
                ];
 
index ab94c79468dd606e2eedac15fc42c7a33d956e28..4bbfdcea20a48733424f6aa763b8194463edb705 100644 (file)
@@ -37,7 +37,7 @@ class InnoDB extends BasicEmitter implements \OC\RepairStep {
         * Fix mime types
         */
        public function run() {
-               $connection = \OC_DB::getConnection();
+               $connection = \OC::$server->getDatabaseConnection();
                if (!$connection->getDatabasePlatform() instanceof MySqlPlatform) {
                        $this->emit('\OC\Repair', 'info', array('Not a mysql database -> nothing to do'));
                        return;
index 5ae8a300246018ee613ed26873536ec4d9d3c849..52d41083c450575e40920636c04c13ae8d832f49 100644 (file)
@@ -52,10 +52,10 @@ class SearchLuceneTables extends BasicEmitter implements \OC\RepairStep {
         * search_lucene will then reindex the fileids without a status when the next indexing job is executed
         */
        public function run() {
-               if (\OC_DB::tableExists('lucene_status')) {
+               $connection = \OC::$server->getDatabaseConnection();
+               if ($connection->tableExists('lucene_status')) {
                        $this->emit('\OC\Repair', 'info', array('removing duplicate entries from lucene_status'));
 
-                       $connection = \OC_DB::getConnection();
                        $query = $connection->prepare('
                                DELETE FROM `*PREFIX*lucene_status`
                                WHERE `fileid` IN (
index 7efe78b7c37899c2d54e05561a30ce1d7e71e043..a21ff58f3554c4026ead86f656ec5b68f28869eb 100644 (file)
@@ -242,8 +242,8 @@ class Server extends ServerContainer implements IServerContainer {
                $this->registerService('SystemConfig', function ($c) use ($config) {
                        return new \OC\SystemConfig($config);
                });
-               $this->registerService('AppConfig', function ($c) {
-                       return new \OC\AppConfig(\OC_DB::getConnection());
+               $this->registerService('AppConfig', function (Server $c) {
+                       return new \OC\AppConfig($c->getDatabaseConnection());
                });
                $this->registerService('L10NFactory', function ($c) {
                        return new \OC\L10N\Factory();
index 2b251dba1e0daf10ff17f84c12e6602dfaf004c5..db27fa6a8916850ec140d492c88718766ad0252f 100644 (file)
@@ -436,7 +436,7 @@ class Share extends Constants {
 
                                // TODO: inject connection, hopefully one day in the future when this
                                // class isn't static anymore...
-                               $conn = \OC_DB::getConnection();
+                               $conn = \OC::$server->getDatabaseConnection();
                                $result = $conn->executeQuery(
                                        'SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where,
                                        $arguments,
index 09cb7618c024c9fbb0c6d57259bdbc3c29bc38f7..c621aa3cf8ffeb9ef5e78988243780ec64f5650a 100644 (file)
@@ -215,7 +215,7 @@ class Tags implements \OCP\ITags {
                $entries = array();
 
                try {
-                       $conn = \OC_DB::getConnection();
+                       $conn = \OC::$server->getDatabaseConnection();
                        $chunks = array_chunk($objIds, 900, false);
                        foreach ($chunks as $chunk) {
                                $result = $conn->executeQuery(
index 1c38a1c161f3c0d0aba0b4fad6d96c72dd37a6b1..389c9e5d2cf40c27ceffea2f7b5437ebc82241ec 100644 (file)
@@ -461,7 +461,7 @@ class Test_App extends \Test\TestCase {
                $appConfig = $this->getMock(
                        '\OC\AppConfig',
                        array('getValues'),
-                       array(\OC_DB::getConnection()),
+                       array(\OC::$server->getDatabaseConnection()),
                        '',
                        false
                );
@@ -488,8 +488,8 @@ class Test_App extends \Test\TestCase {
         * Restore the original app config service.
         */
        private function restoreAppConfig() {
-               \OC::$server->registerService('AppConfig', function ($c) {
-                       return new \OC\AppConfig(\OC_DB::getConnection());
+               \OC::$server->registerService('AppConfig', function (\OC\Server $c) {
+                       return new \OC\AppConfig($c->getDatabaseConnection());
                });
                \OC::$server->registerService('AppManager', function (\OC\Server $c) {
                        return new \OC\App\AppManager($c->getUserSession(), $c->getAppConfig(), $c->getGroupManager(), $c->getMemCacheFactory());
index 470e385b858b50aa21ee3350b7ac67d54216abfb..fd412bdec2da27de836521fe4b9f983405f43d57 100644 (file)
@@ -32,7 +32,7 @@ class MDB2SchemaManager extends \Test\TestCase {
 
        public function testAutoIncrement() {
 
-               $connection = \OC_DB::getConnection();
+               $connection = \OC::$server->getDatabaseConnection();
                if ($connection->getDatabasePlatform() instanceof OraclePlatform) {
                        $this->markTestSkipped('Adding auto increment columns in Oracle is not supported.');
                }
index a50c5f1b864e4ac3763cf8879a08cbf5bb3ca56d..84a98c1e3387c7fed97fc9c1c9d9d58b88e60f0c 100644 (file)
@@ -45,7 +45,7 @@ class Migrator extends \Test\TestCase {
                parent::setUp();
 
                $this->config = \OC::$server->getConfig();
-               $this->connection = \OC_DB::getConnection();
+               $this->connection = \OC::$server->getDatabaseConnection();
                if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
                        $this->markTestSkipped('DB migration tests are not supported on OCI');
                }
index 50b9d91d4eece64bf3dfe55cc95523659c819fbc..51e8801dc3b1079c11c89f03e23a80776a7f9042 100644 (file)
@@ -22,7 +22,7 @@ class TestMySqlMigration extends \Test\TestCase {
        protected function setUp() {
                parent::setUp();
 
-               $this->connection = \OC_DB::getConnection();
+               $this->connection = \OC::$server->getDatabaseConnection();
                if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
                        $this->markTestSkipped("Test only relevant on MySql");
                }
index 3674d452bae27738438f41d5c8c03a64790fd28d..f23f4d4ee86c51e6d7fee6977b260f6880cf347a 100644 (file)
@@ -22,7 +22,7 @@ class TestSqliteMigration extends \Test\TestCase {
        protected function setUp() {
                parent::setUp();
 
-               $this->connection = \OC_DB::getConnection();
+               $this->connection = \OC::$server->getDatabaseConnection();
                if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
                        $this->markTestSkipped("Test only relevant on Sqlite");
                }
index 46d7559acc2c2e637d13c878648524289972dccd..d96f81957707675e30cf1d98ebe99ecc51a0d22d 100644 (file)
@@ -51,7 +51,7 @@ class Test_DBSchema extends \Test\TestCase {
         * @medium
         */
        public function testSchema() {
-               $platform = \OC_DB::getConnection()->getDatabasePlatform();
+               $platform = \OC::$server->getDatabaseConnection()->getDatabasePlatform();
                $this->doTestSchemaCreating();
                $this->doTestSchemaChanging();
                $this->doTestSchemaDumping();
@@ -94,7 +94,7 @@ class Test_DBSchema extends \Test\TestCase {
         * @param string $table
         */
        public function assertTableNotExist($table) {
-               $platform = \OC_DB::getConnection()->getDatabasePlatform();
+               $platform = \OC::$server->getDatabaseConnection()->getDatabasePlatform();
                if ($platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
                        // sqlite removes the tables after closing the DB
                        $this->assertTrue(true);
index f9d921e88a48f2019aa2c53bec0a1d9268807d1b..8d609aeed386adca0a9eaf43ceeb219e4fd1f3ca 100644 (file)
@@ -48,7 +48,7 @@ class TestRepairCollation extends \Test\TestCase {
        protected function setUp() {
                parent::setUp();
 
-               $this->connection = \OC_DB::getConnection();
+               $this->connection = \OC::$server->getDatabaseConnection();
                $this->config = \OC::$server->getConfig();
                if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
                        $this->markTestSkipped("Test only relevant on MySql");
index e7d2b83c224766978dcf45877ab559dd1364c75e..5c73b9313676c037c7de7c701bcfaba34e5cae00 100644 (file)
@@ -28,7 +28,7 @@ class RepairInnoDB extends \Test\TestCase {
        protected function setUp() {
                parent::setUp();
 
-               $this->connection = \OC_DB::getConnection();
+               $this->connection = \OC::$server->getDatabaseConnection();
                if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
                        $this->markTestSkipped("Test only relevant on MySql");
                }
index e3bb110191bcd0b1df8f01773c1c3acd5c3bbe71..6f0c2cb8d28508e1b41aa30b298d05b84025ea61 100644 (file)
@@ -38,7 +38,7 @@ class RepairSqliteAutoincrement extends \Test\TestCase {
        protected function setUp() {
                parent::setUp();
 
-               $this->connection = \OC_DB::getConnection();
+               $this->connection = \OC::$server->getDatabaseConnection();
                $this->config = \OC::$server->getConfig();
                if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
                        $this->markTestSkipped("Test only relevant on Sqlite");
index 537c898da131207850f5d221f5ee759f2df1e151..91472d5ceb84e42b0e828b7b2be8e4a7903847e1 100644 (file)
@@ -60,7 +60,7 @@ class Test_Tags extends \Test\TestCase {
        }
 
        protected function tearDown() {
-               $conn = \OC_DB::getConnection();
+               $conn = \OC::$server->getDatabaseConnection();
                $conn->executeQuery('DELETE FROM `*PREFIX*vcategory_to_object`');
                $conn->executeQuery('DELETE FROM `*PREFIX*vcategory`');
 
@@ -199,7 +199,7 @@ class Test_Tags extends \Test\TestCase {
                $tagId = $tagData[0]['id'];
                $tagType = $tagData[0]['type'];
 
-               $conn = \OC_DB::getConnection();
+               $conn = \OC::$server->getDatabaseConnection();
                $statement = $conn->prepare(
                                'INSERT INTO `*PREFIX*vcategory_to_object` ' .
                                '(`objid`, `categoryid`, `type`) VALUES ' .