Browse Source

Use the public interface and our method instead of the doctrine thing

tags/v8.2beta1
Joas Schilling 9 years ago
parent
commit
de348180ae

+ 7
- 7
apps/encryption/lib/migration.php View File

@@ -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'))

+ 12
- 12
apps/encryption/tests/lib/MigrationTest.php View File

@@ -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();

+ 2
- 2
apps/files_trashbin/command/cleanup.php View File

@@ -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);

+ 4
- 4
apps/files_trashbin/tests/command/cleanuptest.php View File

@@ -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));
}

+ 5
- 5
lib/private/repair.php View File

@@ -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()),
);
}


+ 8
- 8
lib/private/share/share.php View File

@@ -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')

+ 5
- 5
lib/repair/cleantags.php View File

@@ -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')

+ 4
- 4
lib/repair/dropoldtables.php View File

@@ -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;
}


+ 3
- 4
lib/repair/filletags.php View File

@@ -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('')))

+ 7
- 7
tests/lib/repair/cleantags.php View File

@@ -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();

+ 14
- 14
tests/lib/share/share.php View File

@@ -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()

Loading…
Cancel
Save