summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/encryption/lib/migration.php14
-rw-r--r--apps/encryption/tests/lib/MigrationTest.php24
-rw-r--r--apps/files_trashbin/command/cleanup.php4
-rw-r--r--apps/files_trashbin/tests/command/cleanuptest.php8
-rw-r--r--lib/private/repair.php10
-rw-r--r--lib/private/share/share.php16
-rw-r--r--lib/repair/cleantags.php10
-rw-r--r--lib/repair/dropoldtables.php8
-rw-r--r--lib/repair/filletags.php7
-rw-r--r--tests/lib/repair/cleantags.php14
-rw-r--r--tests/lib/share/share.php28
11 files changed, 71 insertions, 72 deletions
diff --git a/apps/encryption/lib/migration.php b/apps/encryption/lib/migration.php
index e6887e8cc07..a4da05d7f06 100644
--- a/apps/encryption/lib/migration.php
+++ b/apps/encryption/lib/migration.php
@@ -23,9 +23,9 @@
namespace OCA\Encryption;
-use OC\DB\Connection;
use OC\Files\View;
use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\ILogger;
class Migration {
@@ -33,7 +33,7 @@ class Migration {
private $moduleId;
/** @var \OC\Files\View */
private $view;
- /** @var \OC\DB\Connection */
+ /** @var \OCP\IDBConnection */
private $connection;
/** @var IConfig */
private $config;
@@ -44,10 +44,10 @@ class Migration {
/**
* @param IConfig $config
* @param View $view
- * @param Connection $connection
+ * @param IDBConnection $connection
* @param ILogger $logger
*/
- public function __construct(IConfig $config, View $view, Connection $connection, ILogger $logger) {
+ public function __construct(IConfig $config, View $view, IDBConnection $connection, ILogger $logger) {
$this->view = $view;
$this->view->getUpdater()->disable();
$this->connection = $connection;
@@ -66,7 +66,7 @@ class Migration {
* update file cache, copy unencrypted_size to the 'size' column
*/
private function updateFileCache() {
- $query = $this->connection->createQueryBuilder();
+ $query = $this->connection->getQueryBuilder();
$query->update('`*PREFIX*filecache`')
->set('`size`', '`unencrypted_size`')
->where($query->expr()->eq('`encrypted`', ':encrypted'))
@@ -149,7 +149,7 @@ class Migration {
$this->config->deleteAppValue('files_encryption', 'types');
$this->config->deleteAppValue('files_encryption', 'enabled');
- $oldAppValues = $this->connection->createQueryBuilder();
+ $oldAppValues = $this->connection->getQueryBuilder();
$oldAppValues->select('*')
->from('`*PREFIX*appconfig`')
->where($oldAppValues->expr()->eq('`appid`', ':appid'))
@@ -164,7 +164,7 @@ class Migration {
}
}
- $oldPreferences = $this->connection->createQueryBuilder();
+ $oldPreferences = $this->connection->getQueryBuilder();
$oldPreferences->select('*')
->from('`*PREFIX*preferences`')
->where($oldPreferences->expr()->eq('`appid`', ':appid'))
diff --git a/apps/encryption/tests/lib/MigrationTest.php b/apps/encryption/tests/lib/MigrationTest.php
index 6742de574bf..c0d8f081342 100644
--- a/apps/encryption/tests/lib/MigrationTest.php
+++ b/apps/encryption/tests/lib/MigrationTest.php
@@ -288,14 +288,14 @@ class MigrationTest extends \Test\TestCase {
// delete default values set by the encryption app during initialization
- /** @var \OC\DB\Connection $connection */
+ /** @var \OCP\IDBConnection $connection */
$connection = \OC::$server->getDatabaseConnection();
- $query = $connection->createQueryBuilder();
+ $query = $connection->getQueryBuilder();
$query->delete('`*PREFIX*appconfig`')
->where($query->expr()->eq('`appid`', ':appid'))
->setParameter('appid', 'encryption');
$query->execute();
- $query = $connection->createQueryBuilder();
+ $query = $connection->getQueryBuilder();
$query->delete('`*PREFIX*preferences`')
->where($query->expr()->eq('`appid`', ':appid'))
->setParameter('appid', 'encryption');
@@ -368,9 +368,9 @@ class MigrationTest extends \Test\TestCase {
}
public function verifyDB($table, $appid, $expected) {
- /** @var \OC\DB\Connection $connection */
+ /** @var \OCP\IDBConnection $connection */
$connection = \OC::$server->getDatabaseConnection();
- $query = $connection->createQueryBuilder();
+ $query = $connection->getQueryBuilder();
$query->select('`appid`')
->from($table)
->where($query->expr()->eq('`appid`', ':appid'))
@@ -392,9 +392,9 @@ class MigrationTest extends \Test\TestCase {
// check results
- /** @var \OC\DB\Connection $connection */
+ /** @var \OCP\IDBConnection $connection */
$connection = \OC::$server->getDatabaseConnection();
- $query = $connection->createQueryBuilder();
+ $query = $connection->getQueryBuilder();
$query->select('*')
->from('`*PREFIX*filecache`');
$result = $query->execute();
@@ -411,17 +411,17 @@ class MigrationTest extends \Test\TestCase {
}
public function prepareFileCache() {
- /** @var \OC\DB\Connection $connection */
+ /** @var \OCP\IDBConnection $connection */
$connection = \OC::$server->getDatabaseConnection();
- $query = $connection->createQueryBuilder();
+ $query = $connection->getQueryBuilder();
$query->delete('`*PREFIX*filecache`');
$query->execute();
- $query = $connection->createQueryBuilder();
+ $query = $connection->getQueryBuilder();
$result = $query->select('`fileid`')
->from('`*PREFIX*filecache`')
->setMaxResults(1)->execute()->fetchAll();
$this->assertEmpty($result);
- $query = $connection->createQueryBuilder();
+ $query = $connection->getQueryBuilder();
$query->insert('`*PREFIX*filecache`')
->values(
array(
@@ -442,7 +442,7 @@ class MigrationTest extends \Test\TestCase {
$query->execute()
);
}
- $query = $connection->createQueryBuilder();
+ $query = $connection->getQueryBuilder();
$result = $query->select('`fileid`')
->from('`*PREFIX*filecache`')
->execute()->fetchAll();
diff --git a/apps/files_trashbin/command/cleanup.php b/apps/files_trashbin/command/cleanup.php
index 961f72763ea..de17020ea5c 100644
--- a/apps/files_trashbin/command/cleanup.php
+++ b/apps/files_trashbin/command/cleanup.php
@@ -38,7 +38,7 @@ class CleanUp extends Command {
/** @var IRootFolder */
protected $rootFolder;
- /** @var \OC\DB\Connection */
+ /** @var \OCP\IDBConnection */
protected $dbConnection;
/**
@@ -107,7 +107,7 @@ class CleanUp extends Command {
\OC_Util::setupFS($uid);
if ($this->rootFolder->nodeExists('/' . $uid . '/files_trashbin')) {
$this->rootFolder->get('/' . $uid . '/files_trashbin')->delete();
- $query = $this->dbConnection->createQueryBuilder();
+ $query = $this->dbConnection->getQueryBuilder();
$query->delete('`*PREFIX*files_trash`')
->where($query->expr()->eq('`user`', ':uid'))
->setParameter('uid', $uid);
diff --git a/apps/files_trashbin/tests/command/cleanuptest.php b/apps/files_trashbin/tests/command/cleanuptest.php
index 6e2f78093e0..ecbaab98bf2 100644
--- a/apps/files_trashbin/tests/command/cleanuptest.php
+++ b/apps/files_trashbin/tests/command/cleanuptest.php
@@ -64,7 +64,7 @@ class CleanUpTest extends TestCase {
* populate files_trash table with 10 dummy values
*/
public function initTable() {
- $query = $this->dbConnection->createQueryBuilder();
+ $query = $this->dbConnection->getQueryBuilder();
$query->delete($this->trashTable)->execute();
for ($i = 0; $i < 10; $i++) {
$query->insert($this->trashTable)
@@ -75,7 +75,7 @@ class CleanUpTest extends TestCase {
'`user`' => $query->expr()->literal('user'.$i%2)
))->execute();
}
- $getAllQuery = $this->dbConnection->createQueryBuilder();
+ $getAllQuery = $this->dbConnection->getQueryBuilder();
$result = $getAllQuery->select('`id`')->from($this->trashTable)->execute()->fetchAll();
$this->assertSame(10, count($result));
}
@@ -106,7 +106,7 @@ class CleanUpTest extends TestCase {
if ($nodeExists) {
// if the delete operation was execute only files from user1
// should be left.
- $query = $this->dbConnection->createQueryBuilder();
+ $query = $this->dbConnection->getQueryBuilder();
$result = $query->select('`user`')
->from($this->trashTable)
->execute()->fetchAll();
@@ -117,7 +117,7 @@ class CleanUpTest extends TestCase {
} else {
// if no delete operation was execute we should still have all 10
// database entries
- $getAllQuery = $this->dbConnection->createQueryBuilder();
+ $getAllQuery = $this->dbConnection->getQueryBuilder();
$result = $getAllQuery->select('`id`')->from($this->trashTable)->execute()->fetchAll();
$this->assertSame(10, count($result));
}
diff --git a/lib/private/repair.php b/lib/private/repair.php
index 166efd3eb8f..bf385af2c2b 100644
--- a/lib/private/repair.php
+++ b/lib/private/repair.php
@@ -103,14 +103,14 @@ class Repair extends BasicEmitter {
public static function getRepairSteps() {
return array(
new RepairMimeTypes(),
- new RepairLegacyStorages(\OC::$server->getConfig(), \OC_DB::getConnection()),
+ new RepairLegacyStorages(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
new RepairConfig(),
new AssetCache(),
- new FillETags(\OC_DB::getConnection()),
- new CleanTags(\OC_DB::getConnection()),
- new DropOldTables(\OC_DB::getConnection()),
+ new FillETags(\OC::$server->getDatabaseConnection()),
+ new CleanTags(\OC::$server->getDatabaseConnection()),
+ new DropOldTables(\OC::$server->getDatabaseConnection()),
new DropOldJobs(\OC::$server->getJobList()),
- new RemoveGetETagEntries(\OC_DB::getConnection()),
+ new RemoveGetETagEntries(\OC::$server->getDatabaseConnection()),
);
}
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 7fcbb695c68..e3364e0de0b 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -38,7 +38,7 @@
namespace OC\Share;
use OCP\IUserSession;
-use OC\DB\Connection;
+use OCP\IDBConnection;
use OCP\IConfig;
/**
@@ -1195,13 +1195,13 @@ class Share extends Constants {
/**
* Retrieve the owner of a connection
*
- * @param Connection $connection
+ * @param IDBConnection $connection
* @param int $shareId
* @throws \Exception
* @return string uid of share owner
*/
- private static function getShareOwner(Connection $connection, $shareId) {
- $qb = $connection->createQueryBuilder();
+ private static function getShareOwner(IDBConnection $connection, $shareId) {
+ $qb = $connection->getQueryBuilder();
$qb->select('`uid_owner`')
->from('`*PREFIX*share`')
@@ -1221,15 +1221,15 @@ class Share extends Constants {
* Set expiration date for a share
*
* @param IUserSession $userSession
- * @param Connection $connection
+ * @param IDBConnection $connection
* @param IConfig $config
* @param int $shareId
* @param string $password
* @throws \Exception
* @return boolean
*/
- public static function setPassword(IUserSession $userSession,
- Connection $connection,
+ public static function setPassword(IUserSession $userSession,
+ IDBConnection $connection,
IConfig $config,
$shareId, $password) {
$user = $userSession->getUser();
@@ -1252,7 +1252,7 @@ class Share extends Constants {
throw new \Exception('Cannot remove password');
}
- $qb = $connection->createQueryBuilder();
+ $qb = $connection->getQueryBuilder();
$qb->update('`*PREFIX*share`')
->set('`share_with`', ':pass')
->where('`id` = :shareId')
diff --git a/lib/repair/cleantags.php b/lib/repair/cleantags.php
index 7d2002427f8..ddd1a483016 100644
--- a/lib/repair/cleantags.php
+++ b/lib/repair/cleantags.php
@@ -22,9 +22,9 @@
namespace OC\Repair;
-use OC\DB\Connection;
use OC\Hooks\BasicEmitter;
use OC\RepairStep;
+use OCP\IDBConnection;
/**
* Class RepairConfig
@@ -33,13 +33,13 @@ use OC\RepairStep;
*/
class CleanTags extends BasicEmitter implements RepairStep {
- /** @var Connection */
+ /** @var IDBConnection */
protected $connection;
/**
- * @param Connection $connection
+ * @param IDBConnection $connection
*/
- public function __construct(Connection $connection) {
+ public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
@@ -108,7 +108,7 @@ class CleanTags extends BasicEmitter implements RepairStep {
* the entry is deleted in the $deleteTable
*/
protected function deleteOrphanEntries($repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
- $qb = $this->connection->createQueryBuilder();
+ $qb = $this->connection->getQueryBuilder();
$qb->select('d.`' . $deleteId . '`')
->from('`' . $deleteTable . '`', 'd')
diff --git a/lib/repair/dropoldtables.php b/lib/repair/dropoldtables.php
index 9afd9698e04..cfe0df6cb5b 100644
--- a/lib/repair/dropoldtables.php
+++ b/lib/repair/dropoldtables.php
@@ -22,19 +22,19 @@
namespace OC\Repair;
-use OC\DB\Connection;
use OC\Hooks\BasicEmitter;
use OC\RepairStep;
+use OCP\IDBConnection;
class DropOldTables extends BasicEmitter implements RepairStep {
- /** @var Connection */
+ /** @var IDBConnection */
protected $connection;
/**
- * @param Connection $connection
+ * @param IDBConnection $connection
*/
- public function __construct(Connection $connection) {
+ public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
diff --git a/lib/repair/filletags.php b/lib/repair/filletags.php
index 501a18d0b4a..a46c951efaf 100644
--- a/lib/repair/filletags.php
+++ b/lib/repair/filletags.php
@@ -22,16 +22,15 @@
namespace OC\Repair;
-use Doctrine\DBAL\Query\QueryBuilder;
use OC\Hooks\BasicEmitter;
class FillETags extends BasicEmitter implements \OC\RepairStep {
- /** @var \OC\DB\Connection */
+ /** @var \OCP\IDBConnection */
protected $connection;
/**
- * @param \OC\DB\Connection $connection
+ * @param \OCP\IDBConnection $connection
*/
public function __construct($connection) {
$this->connection = $connection;
@@ -42,7 +41,7 @@ class FillETags extends BasicEmitter implements \OC\RepairStep {
}
public function run() {
- $qb = $this->connection->createQueryBuilder();
+ $qb = $this->connection->getQueryBuilder();
$qb->update('`*PREFIX*filecache`')
->set('`etag`', $qb->expr()->literal('xxx'))
->where($qb->expr()->eq('`etag`', $qb->expr()->literal('')))
diff --git a/tests/lib/repair/cleantags.php b/tests/lib/repair/cleantags.php
index b455aa870fb..fc9b21d4636 100644
--- a/tests/lib/repair/cleantags.php
+++ b/tests/lib/repair/cleantags.php
@@ -18,7 +18,7 @@ class CleanTags extends \Test\TestCase {
/** @var \OC\RepairStep */
protected $repair;
- /** @var \Doctrine\DBAL\Connection */
+ /** @var \OCP\IDBConnection */
protected $connection;
/** @var int */
@@ -39,7 +39,7 @@ class CleanTags extends \Test\TestCase {
}
protected function cleanUpTables() {
- $qb = $this->connection->createQueryBuilder();
+ $qb = $this->connection->getQueryBuilder();
$qb->delete('`*PREFIX*vcategory`')
->execute();
@@ -83,7 +83,7 @@ class CleanTags extends \Test\TestCase {
* @param string $message
*/
protected function assertEntryCount($tableName, $expected, $message = '') {
- $qb = $this->connection->createQueryBuilder();
+ $qb = $this->connection->getQueryBuilder();
$result = $qb->select('COUNT(*)')
->from('`' . $tableName . '`')
->execute();
@@ -99,7 +99,7 @@ class CleanTags extends \Test\TestCase {
* @return int
*/
protected function addTagCategory($category, $type) {
- $qb = $this->connection->createQueryBuilder();
+ $qb = $this->connection->getQueryBuilder();
$qb->insert('`*PREFIX*vcategory`')
->values([
'`uid`' => $qb->createNamedParameter('TestRepairCleanTags'),
@@ -118,7 +118,7 @@ class CleanTags extends \Test\TestCase {
* @param string $type
*/
protected function addTagEntry($objectId, $category, $type) {
- $qb = $this->connection->createQueryBuilder();
+ $qb = $this->connection->getQueryBuilder();
$qb->insert('`*PREFIX*vcategory_to_object`')
->values([
'`objid`' => $qb->createNamedParameter($objectId, \PDO::PARAM_INT),
@@ -137,7 +137,7 @@ class CleanTags extends \Test\TestCase {
return $this->createdFile;
}
- $qb = $this->connection->createQueryBuilder();
+ $qb = $this->connection->getQueryBuilder();
// We create a new file entry and delete it after the test again
$fileName = $this->getUniqueID('TestRepairCleanTags', 12);
@@ -174,7 +174,7 @@ class CleanTags extends \Test\TestCase {
// FIXME INSTEAD HELP FIXING DOCTRINE
// FIXME https://github.com/owncloud/core/issues/13303
// FIXME ALSO FIX https://github.com/owncloud/core/commit/2dd85ec984c12d3be401518f22c90d2327bec07a
- $qb = $this->connection->createQueryBuilder();
+ $qb = $this->connection->getQueryBuilder();
$result = $qb->select("MAX($idName)")
->from($tableName)
->execute();
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index e225f2a4002..e57dd43f839 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -1286,7 +1286,7 @@ class Test_Share extends \Test\TestCase {
->getMock();
// Find the share ID in the db
- $qb = $connection->createQueryBuilder();
+ $qb = $connection->getQueryBuilder();
$qb->select('`id`')
->from('`*PREFIX*share`')
->where('`item_type` = :type')
@@ -1307,7 +1307,7 @@ class Test_Share extends \Test\TestCase {
$this->assertTrue($res);
// Fetch the hash from the database
- $qb = $connection->createQueryBuilder();
+ $qb = $connection->getQueryBuilder();
$qb->select('`share_with`')
->from('`*PREFIX*share`')
->where('`id` = :id')
@@ -1335,10 +1335,10 @@ class Test_Share extends \Test\TestCase {
$userSession->method('getUser')->willReturn($user);
- $ex = $this->getMockBuilder('\Doctrine\DBAL\Query\Expression\ExpressionBuilder')
+ $ex = $this->getMockBuilder('\OC\DB\ExpressionBuilder')
->disableOriginalConstructor()
->getMock();
- $qb = $this->getMockBuilder('\Doctrine\DBAL\Query\QueryBuilder')
+ $qb = $this->getMockBuilder('\OC\DB\QueryBuilder')
->disableOriginalConstructor()
->getMock();
$qb->method('update')->will($this->returnSelf());
@@ -1360,7 +1360,7 @@ class Test_Share extends \Test\TestCase {
$connection = $this->getMockBuilder('\OC\DB\Connection')
->disableOriginalConstructor()
->getMock();
- $connection->method('createQueryBuilder')->willReturn($qb);
+ $connection->method('getQueryBuilder')->willReturn($qb);
$config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
@@ -1390,10 +1390,10 @@ class Test_Share extends \Test\TestCase {
$userSession->method('getUser')->willReturn($user);
- $ex = $this->getMockBuilder('\Doctrine\DBAL\Query\Expression\ExpressionBuilder')
+ $ex = $this->getMockBuilder('\OC\DB\ExpressionBuilder')
->disableOriginalConstructor()
->getMock();
- $qb = $this->getMockBuilder('\Doctrine\DBAL\Query\QueryBuilder')
+ $qb = $this->getMockBuilder('\OC\DB\QueryBuilder')
->disableOriginalConstructor()
->getMock();
$qb->method('update')->will($this->returnSelf());
@@ -1415,7 +1415,7 @@ class Test_Share extends \Test\TestCase {
$connection = $this->getMockBuilder('\OC\DB\Connection')
->disableOriginalConstructor()
->getMock();
- $connection->method('createQueryBuilder')->willReturn($qb);
+ $connection->method('getQueryBuilder')->willReturn($qb);
$config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
@@ -1443,10 +1443,10 @@ class Test_Share extends \Test\TestCase {
$userSession->method('getUser')->willReturn($user);
- $ex = $this->getMockBuilder('\Doctrine\DBAL\Query\Expression\ExpressionBuilder')
+ $ex = $this->getMockBuilder('\OC\DB\ExpressionBuilder')
->disableOriginalConstructor()
->getMock();
- $qb = $this->getMockBuilder('\Doctrine\DBAL\Query\QueryBuilder')
+ $qb = $this->getMockBuilder('\OC\DB\QueryBuilder')
->disableOriginalConstructor()
->getMock();
$qb->method('update')->will($this->returnSelf());
@@ -1468,7 +1468,7 @@ class Test_Share extends \Test\TestCase {
$connection = $this->getMockBuilder('\OC\DB\Connection')
->disableOriginalConstructor()
->getMock();
- $connection->method('createQueryBuilder')->willReturn($qb);
+ $connection->method('getQueryBuilder')->willReturn($qb);
$config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
@@ -1496,10 +1496,10 @@ class Test_Share extends \Test\TestCase {
$userSession->method('getUser')->willReturn($user);
- $ex = $this->getMockBuilder('\Doctrine\DBAL\Query\Expression\ExpressionBuilder')
+ $ex = $this->getMockBuilder('\OC\DB\ExpressionBuilder')
->disableOriginalConstructor()
->getMock();
- $qb = $this->getMockBuilder('\Doctrine\DBAL\Query\QueryBuilder')
+ $qb = $this->getMockBuilder('\OC\DB\QueryBuilder')
->disableOriginalConstructor()
->getMock();
$qb->method('update')->will($this->returnSelf());
@@ -1521,7 +1521,7 @@ class Test_Share extends \Test\TestCase {
$connection = $this->getMockBuilder('\OC\DB\Connection')
->disableOriginalConstructor()
->getMock();
- $connection->method('createQueryBuilder')->willReturn($qb);
+ $connection->method('getQueryBuilder')->willReturn($qb);
$config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()