diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-07-07 22:08:21 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-07-21 15:25:47 +0200 |
commit | f77e5f411dda91a7c4fc70c090825a036b7b1135 (patch) | |
tree | 6cc6cc88d7f3bb3ff137e2da5130e933ca1ab840 | |
parent | 516f7e8299c309ed909259c90c23cb0ce6a8e4f7 (diff) | |
download | nextcloud-server-f77e5f411dda91a7c4fc70c090825a036b7b1135.tar.gz nextcloud-server-f77e5f411dda91a7c4fc70c090825a036b7b1135.zip |
Fix existing usages by removing the quotes
-rw-r--r-- | apps/encryption/lib/migration.php | 14 | ||||
-rw-r--r-- | apps/encryption/tests/lib/MigrationTest.php | 74 | ||||
-rw-r--r-- | apps/files_trashbin/command/cleanup.php | 4 | ||||
-rw-r--r-- | apps/files_trashbin/tests/command/cleanuptest.php | 22 | ||||
-rw-r--r-- | lib/private/share/share.php | 12 | ||||
-rw-r--r-- | lib/repair/cleantags.php | 16 | ||||
-rw-r--r-- | lib/repair/filletags.php | 8 | ||||
-rw-r--r-- | tests/lib/repair/cleantags.php | 44 | ||||
-rw-r--r-- | tests/lib/share/share.php | 18 |
9 files changed, 109 insertions, 103 deletions
diff --git a/apps/encryption/lib/migration.php b/apps/encryption/lib/migration.php index a4da05d7f06..789f5f77757 100644 --- a/apps/encryption/lib/migration.php +++ b/apps/encryption/lib/migration.php @@ -67,9 +67,9 @@ class Migration { */ private function updateFileCache() { $query = $this->connection->getQueryBuilder(); - $query->update('`*PREFIX*filecache`') - ->set('`size`', '`unencrypted_size`') - ->where($query->expr()->eq('`encrypted`', ':encrypted')) + $query->update('*PREFIX*filecache') + ->set('size', 'unencrypted_size') + ->where($query->expr()->eq('encrypted', $query->createParameter('encrypted'))) ->setParameter('encrypted', 1); $query->execute(); } @@ -151,8 +151,8 @@ class Migration { $oldAppValues = $this->connection->getQueryBuilder(); $oldAppValues->select('*') - ->from('`*PREFIX*appconfig`') - ->where($oldAppValues->expr()->eq('`appid`', ':appid')) + ->from('*PREFIX*appconfig') + ->where($oldAppValues->expr()->eq('appid', $oldAppValues->createParameter('appid'))) ->setParameter('appid', 'files_encryption'); $appSettings = $oldAppValues->execute(); @@ -166,8 +166,8 @@ class Migration { $oldPreferences = $this->connection->getQueryBuilder(); $oldPreferences->select('*') - ->from('`*PREFIX*preferences`') - ->where($oldPreferences->expr()->eq('`appid`', ':appid')) + ->from('*PREFIX*preferences') + ->where($oldPreferences->expr()->eq('appid', $oldPreferences->createParameter('appid'))) ->setParameter('appid', 'files_encryption'); $preferenceSettings = $oldPreferences->execute(); diff --git a/apps/encryption/tests/lib/MigrationTest.php b/apps/encryption/tests/lib/MigrationTest.php index c0d8f081342..a05418c5f26 100644 --- a/apps/encryption/tests/lib/MigrationTest.php +++ b/apps/encryption/tests/lib/MigrationTest.php @@ -291,13 +291,13 @@ class MigrationTest extends \Test\TestCase { /** @var \OCP\IDBConnection $connection */ $connection = \OC::$server->getDatabaseConnection(); $query = $connection->getQueryBuilder(); - $query->delete('`*PREFIX*appconfig`') - ->where($query->expr()->eq('`appid`', ':appid')) + $query->delete('*PREFIX*appconfig') + ->where($query->expr()->eq('appid', $query->createParameter('appid'))) ->setParameter('appid', 'encryption'); $query->execute(); $query = $connection->getQueryBuilder(); - $query->delete('`*PREFIX*preferences`') - ->where($query->expr()->eq('`appid`', ':appid')) + $query->delete('*PREFIX*preferences') + ->where($query->expr()->eq('appid', $query->createParameter('appid'))) ->setParameter('appid', 'encryption'); $query->execute(); } @@ -308,10 +308,10 @@ class MigrationTest extends \Test\TestCase { $m = new Migration(\OC::$server->getConfig(), new \OC\Files\View(), \OC::$server->getDatabaseConnection(), $this->logger); $m->updateDB(); - $this->verifyDB('`*PREFIX*appconfig`', 'files_encryption', 0); - $this->verifyDB('`*PREFIX*preferences`', 'files_encryption', 0); - $this->verifyDB('`*PREFIX*appconfig`', 'encryption', 3); - $this->verifyDB('`*PREFIX*preferences`', 'encryption', 1); + $this->verifyDB('*PREFIX*appconfig', 'files_encryption', 0); + $this->verifyDB('*PREFIX*preferences', 'files_encryption', 0); + $this->verifyDB('*PREFIX*appconfig', 'encryption', 3); + $this->verifyDB('*PREFIX*preferences', 'encryption', 1); } @@ -327,20 +327,20 @@ class MigrationTest extends \Test\TestCase { $m = new Migration(\OC::$server->getConfig(), new \OC\Files\View(), \OC::$server->getDatabaseConnection(), $this->logger); $m->updateDB(); - $this->verifyDB('`*PREFIX*appconfig`', 'files_encryption', 0); - $this->verifyDB('`*PREFIX*preferences`', 'files_encryption', 0); - $this->verifyDB('`*PREFIX*appconfig`', 'encryption', 3); - $this->verifyDB('`*PREFIX*preferences`', 'encryption', 1); + $this->verifyDB('*PREFIX*appconfig', 'files_encryption', 0); + $this->verifyDB('*PREFIX*preferences', 'files_encryption', 0); + $this->verifyDB('*PREFIX*appconfig', 'encryption', 3); + $this->verifyDB('*PREFIX*preferences', 'encryption', 1); // check if the existing values where overwritten correctly /** @var \OC\DB\Connection $connection */ $connection = \OC::$server->getDatabaseConnection(); - $query = $connection->createQueryBuilder(); - $query->select('`configvalue`') - ->from('`*PREFIX*appconfig`') + $query = $connection->getQueryBuilder(); + $query->select('configvalue') + ->from('*PREFIX*appconfig') ->where($query->expr()->andX( - $query->expr()->eq('`appid`', ':appid'), - $query->expr()->eq('`configkey`', ':configkey') + $query->expr()->eq('appid', $query->createParameter('appid')), + $query->expr()->eq('configkey', $query->createParameter('configkey')) )) ->setParameter('appid', 'encryption') ->setParameter('configkey', 'publicShareKeyId'); @@ -349,13 +349,13 @@ class MigrationTest extends \Test\TestCase { $this->assertTrue(isset($value['configvalue'])); $this->assertSame('share_id', $value['configvalue']); - $query = $connection->createQueryBuilder(); - $query->select('`configvalue`') - ->from('`*PREFIX*preferences`') + $query = $connection->getQueryBuilder(); + $query->select('configvalue') + ->from('*PREFIX*preferences') ->where($query->expr()->andX( - $query->expr()->eq('`appid`', ':appid'), - $query->expr()->eq('`configkey`', ':configkey'), - $query->expr()->eq('`userid`', ':userid') + $query->expr()->eq('appid', $query->createParameter('appid')), + $query->expr()->eq('configkey', $query->createParameter('configkey')), + $query->expr()->eq('userid', $query->createParameter('userid')) )) ->setParameter('appid', 'encryption') ->setParameter('configkey', 'recoverKeyEnabled') @@ -371,9 +371,9 @@ class MigrationTest extends \Test\TestCase { /** @var \OCP\IDBConnection $connection */ $connection = \OC::$server->getDatabaseConnection(); $query = $connection->getQueryBuilder(); - $query->select('`appid`') + $query->select('appid') ->from($table) - ->where($query->expr()->eq('`appid`', ':appid')) + ->where($query->expr()->eq('appid', $query->createParameter('appid'))) ->setParameter('appid', $appid); $result = $query->execute(); $values = $result->fetchAll(); @@ -396,7 +396,7 @@ class MigrationTest extends \Test\TestCase { $connection = \OC::$server->getDatabaseConnection(); $query = $connection->getQueryBuilder(); $query->select('*') - ->from('`*PREFIX*filecache`'); + ->from('*PREFIX*filecache'); $result = $query->execute(); $entries = $result->fetchAll(); foreach($entries as $entry) { @@ -414,22 +414,22 @@ class MigrationTest extends \Test\TestCase { /** @var \OCP\IDBConnection $connection */ $connection = \OC::$server->getDatabaseConnection(); $query = $connection->getQueryBuilder(); - $query->delete('`*PREFIX*filecache`'); + $query->delete('*PREFIX*filecache'); $query->execute(); $query = $connection->getQueryBuilder(); - $result = $query->select('`fileid`') - ->from('`*PREFIX*filecache`') + $result = $query->select('fileid') + ->from('*PREFIX*filecache') ->setMaxResults(1)->execute()->fetchAll(); $this->assertEmpty($result); $query = $connection->getQueryBuilder(); - $query->insert('`*PREFIX*filecache`') + $query->insert('*PREFIX*filecache') ->values( array( - '`storage`' => ':storage', - '`path_hash`' => ':path_hash', - '`encrypted`' => ':encrypted', - '`size`' => ':size', - '`unencrypted_size`' => ':unencrypted_size' + 'storage' => $query->createParameter('storage'), + 'path_hash' => $query->createParameter('path_hash'), + 'encrypted' => $query->createParameter('encrypted'), + 'size' => $query->createParameter('size'), + 'unencrypted_size' => $query->createParameter('unencrypted_size'), ) ); for ($i = 1; $i < 20; $i++) { @@ -443,8 +443,8 @@ class MigrationTest extends \Test\TestCase { ); } $query = $connection->getQueryBuilder(); - $result = $query->select('`fileid`') - ->from('`*PREFIX*filecache`') + $result = $query->select('fileid') + ->from('*PREFIX*filecache') ->execute()->fetchAll(); $this->assertSame(19, count($result)); } diff --git a/apps/files_trashbin/command/cleanup.php b/apps/files_trashbin/command/cleanup.php index de17020ea5c..0cc94912339 100644 --- a/apps/files_trashbin/command/cleanup.php +++ b/apps/files_trashbin/command/cleanup.php @@ -108,8 +108,8 @@ class CleanUp extends Command { if ($this->rootFolder->nodeExists('/' . $uid . '/files_trashbin')) { $this->rootFolder->get('/' . $uid . '/files_trashbin')->delete(); $query = $this->dbConnection->getQueryBuilder(); - $query->delete('`*PREFIX*files_trash`') - ->where($query->expr()->eq('`user`', ':uid')) + $query->delete('*PREFIX*files_trash') + ->where($query->expr()->eq('user', $query->createParameter('uid'))) ->setParameter('uid', $uid); $query->execute(); } diff --git a/apps/files_trashbin/tests/command/cleanuptest.php b/apps/files_trashbin/tests/command/cleanuptest.php index ecbaab98bf2..a7400e901fa 100644 --- a/apps/files_trashbin/tests/command/cleanuptest.php +++ b/apps/files_trashbin/tests/command/cleanuptest.php @@ -43,7 +43,7 @@ class CleanUpTest extends TestCase { protected $dbConnection; /** @var string */ - protected $trashTable = '`*PREFIX*files_trash`'; + protected $trashTable = '*PREFIX*files_trash'; /** @var string */ protected $user0 = 'user0'; @@ -69,14 +69,17 @@ class CleanUpTest extends TestCase { for ($i = 0; $i < 10; $i++) { $query->insert($this->trashTable) ->values(array( - '`id`' => $query->expr()->literal('file'.$i), - '`timestamp`' => $query->expr()->literal($i), - '`location`' => $query->expr()->literal('.'), - '`user`' => $query->expr()->literal('user'.$i%2) + 'id' => $query->expr()->literal('file'.$i), + 'timestamp' => $query->expr()->literal($i), + 'location' => $query->expr()->literal('.'), + 'user' => $query->expr()->literal('user'.$i%2) ))->execute(); } $getAllQuery = $this->dbConnection->getQueryBuilder(); - $result = $getAllQuery->select('`id`')->from($this->trashTable)->execute()->fetchAll(); + $result = $getAllQuery->select('id') + ->from($this->trashTable) + ->execute() + ->fetchAll(); $this->assertSame(10, count($result)); } @@ -107,7 +110,7 @@ class CleanUpTest extends TestCase { // if the delete operation was execute only files from user1 // should be left. $query = $this->dbConnection->getQueryBuilder(); - $result = $query->select('`user`') + $result = $query->select('user') ->from($this->trashTable) ->execute()->fetchAll(); $this->assertSame(5, count($result)); @@ -118,7 +121,10 @@ class CleanUpTest extends TestCase { // if no delete operation was execute we should still have all 10 // database entries $getAllQuery = $this->dbConnection->getQueryBuilder(); - $result = $getAllQuery->select('`id`')->from($this->trashTable)->execute()->fetchAll(); + $result = $getAllQuery->select('id') + ->from($this->trashTable) + ->execute() + ->fetchAll(); $this->assertSame(10, count($result)); } diff --git a/lib/private/share/share.php b/lib/private/share/share.php index e3364e0de0b..41b60ecc638 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -1203,9 +1203,9 @@ class Share extends Constants { private static function getShareOwner(IDBConnection $connection, $shareId) { $qb = $connection->getQueryBuilder(); - $qb->select('`uid_owner`') - ->from('`*PREFIX*share`') - ->where('`id` = :shareId') + $qb->select('uid_owner') + ->from('*PREFIX*share') + ->where($qb->expr()->eq('id', $qb->createParameter('shareId'))) ->setParameter(':shareId', $shareId); $result = $qb->execute(); $result = $result->fetch(); @@ -1253,9 +1253,9 @@ class Share extends Constants { } $qb = $connection->getQueryBuilder(); - $qb->update('`*PREFIX*share`') - ->set('`share_with`', ':pass') - ->where('`id` = :shareId') + $qb->update('*PREFIX*share') + ->set('share_with', $qb->createParameter('pass')) + ->where($qb->expr()->eq('id', $qb->createParameter('shareId'))) ->setParameter(':pass', is_null($password) ? null : \OC::$server->getHasher()->hash($password)) ->setParameter(':shareId', $shareId); diff --git a/lib/repair/cleantags.php b/lib/repair/cleantags.php index ddd1a483016..2bda1047081 100644 --- a/lib/repair/cleantags.php +++ b/lib/repair/cleantags.php @@ -110,14 +110,14 @@ class CleanTags extends BasicEmitter implements RepairStep { protected function deleteOrphanEntries($repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) { $qb = $this->connection->getQueryBuilder(); - $qb->select('d.`' . $deleteId . '`') - ->from('`' . $deleteTable . '`', 'd') - ->leftJoin('d', '`' . $sourceTable . '`', 's', 'd.`' . $deleteId . '` = s.`' . $sourceId . '`') + $qb->select('d.' . $deleteId) + ->from($deleteTable, 'd') + ->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, ' s.' . $sourceId)) ->where( - 'd.`type` = ' . $qb->expr()->literal('files') + $qb->expr()->eq('d.type', $qb->expr()->literal('files')) ) ->andWhere( - $qb->expr()->isNull('s.`' . $sourceNullColumn . '`') + $qb->expr()->isNull('s.' . $sourceNullColumn) ); $result = $qb->execute(); @@ -129,11 +129,11 @@ class CleanTags extends BasicEmitter implements RepairStep { if (!empty($orphanItems)) { $orphanItemsBatch = array_chunk($orphanItems, 200); foreach ($orphanItemsBatch as $items) { - $qb->delete('`' . $deleteTable . '`') + $qb->delete($deleteTable) ->where( - '`type` = ' . $qb->expr()->literal('files') + $qb->expr()->eq('type', $qb->expr()->literal('files')) ) - ->andWhere($qb->expr()->in('`' . $deleteId . '`', ':ids')); + ->andWhere($qb->expr()->in($deleteId, $qb->createParameter('ids'))); $qb->setParameter('ids', $items, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY); $qb->execute(); } diff --git a/lib/repair/filletags.php b/lib/repair/filletags.php index a46c951efaf..f1bb2c896c4 100644 --- a/lib/repair/filletags.php +++ b/lib/repair/filletags.php @@ -42,10 +42,10 @@ class FillETags extends BasicEmitter implements \OC\RepairStep { public function run() { $qb = $this->connection->getQueryBuilder(); - $qb->update('`*PREFIX*filecache`') - ->set('`etag`', $qb->expr()->literal('xxx')) - ->where($qb->expr()->eq('`etag`', $qb->expr()->literal(''))) - ->orWhere($qb->expr()->isNull('`etag`')); + $qb->update('*PREFIX*filecache') + ->set('etag', $qb->expr()->literal('xxx')) + ->where($qb->expr()->eq('etag', $qb->expr()->literal(''))) + ->orWhere($qb->expr()->isNull('etag')); $result = $qb->execute(); $this->emit('\OC\Repair', 'info', array("ETags have been fixed for $result files/folders.")); diff --git a/tests/lib/repair/cleantags.php b/tests/lib/repair/cleantags.php index fc9b21d4636..2f6d0879642 100644 --- a/tests/lib/repair/cleantags.php +++ b/tests/lib/repair/cleantags.php @@ -40,13 +40,13 @@ class CleanTags extends \Test\TestCase { protected function cleanUpTables() { $qb = $this->connection->getQueryBuilder(); - $qb->delete('`*PREFIX*vcategory`') + $qb->delete('*PREFIX*vcategory') ->execute(); - $qb->delete('`*PREFIX*vcategory_to_object`') + $qb->delete('*PREFIX*vcategory_to_object') ->execute(); - $qb->delete('`*PREFIX*filecache`') + $qb->delete('*PREFIX*filecache') ->execute(); } @@ -84,8 +84,8 @@ class CleanTags extends \Test\TestCase { */ protected function assertEntryCount($tableName, $expected, $message = '') { $qb = $this->connection->getQueryBuilder(); - $result = $qb->select('COUNT(*)') - ->from('`' . $tableName . '`') + $result = $qb->select($qb->createFunction('COUNT(*)')) + ->from($tableName) ->execute(); $this->assertEquals($expected, $result->fetchColumn(), $message); @@ -100,15 +100,15 @@ class CleanTags extends \Test\TestCase { */ protected function addTagCategory($category, $type) { $qb = $this->connection->getQueryBuilder(); - $qb->insert('`*PREFIX*vcategory`') + $qb->insert('*PREFIX*vcategory') ->values([ - '`uid`' => $qb->createNamedParameter('TestRepairCleanTags'), - '`category`' => $qb->createNamedParameter($category), - '`type`' => $qb->createNamedParameter($type), + 'uid' => $qb->createNamedParameter('TestRepairCleanTags'), + 'category' => $qb->createNamedParameter($category), + 'type' => $qb->createNamedParameter($type), ]) ->execute(); - return (int) $this->getLastInsertID('`*PREFIX*vcategory`', '`id`'); + return (int) $this->getLastInsertID('*PREFIX*vcategory', 'id'); } /** @@ -119,11 +119,11 @@ class CleanTags extends \Test\TestCase { */ protected function addTagEntry($objectId, $category, $type) { $qb = $this->connection->getQueryBuilder(); - $qb->insert('`*PREFIX*vcategory_to_object`') + $qb->insert('*PREFIX*vcategory_to_object') ->values([ - '`objid`' => $qb->createNamedParameter($objectId, \PDO::PARAM_INT), - '`categoryid`' => $qb->createNamedParameter($category, \PDO::PARAM_INT), - '`type`' => $qb->createNamedParameter($type), + 'objid' => $qb->createNamedParameter($objectId, \PDO::PARAM_INT), + 'categoryid' => $qb->createNamedParameter($category, \PDO::PARAM_INT), + 'type' => $qb->createNamedParameter($type), ]) ->execute(); } @@ -141,21 +141,21 @@ class CleanTags extends \Test\TestCase { // We create a new file entry and delete it after the test again $fileName = $this->getUniqueID('TestRepairCleanTags', 12); - $qb->insert('`*PREFIX*filecache`') + $qb->insert('*PREFIX*filecache') ->values([ - '`path`' => $qb->createNamedParameter($fileName), - '`path_hash`' => $qb->createNamedParameter(md5($fileName)), + 'path' => $qb->createNamedParameter($fileName), + 'path_hash' => $qb->createNamedParameter(md5($fileName)), ]) ->execute(); $fileName = $this->getUniqueID('TestRepairCleanTags', 12); - $qb->insert('`*PREFIX*filecache`') + $qb->insert('*PREFIX*filecache') ->values([ - '`path`' => $qb->createNamedParameter($fileName), - '`path_hash`' => $qb->createNamedParameter(md5($fileName)), + 'path' => $qb->createNamedParameter($fileName), + 'path_hash' => $qb->createNamedParameter(md5($fileName)), ]) ->execute(); - $this->createdFile = (int) $this->getLastInsertID('`*PREFIX*filecache`', '`fileid`'); + $this->createdFile = (int) $this->getLastInsertID('*PREFIX*filecache', 'fileid'); return $this->createdFile; } @@ -175,7 +175,7 @@ class CleanTags extends \Test\TestCase { // FIXME https://github.com/owncloud/core/issues/13303 // FIXME ALSO FIX https://github.com/owncloud/core/commit/2dd85ec984c12d3be401518f22c90d2327bec07a $qb = $this->connection->getQueryBuilder(); - $result = $qb->select("MAX($idName)") + $result = $qb->select($qb->createFunction('MAX(`' . $idName . '`)')) ->from($tableName) ->execute(); diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 816070afd8b..52511810efa 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -1287,12 +1287,12 @@ class Test_Share extends \Test\TestCase { // Find the share ID in the db $qb = $connection->getQueryBuilder(); - $qb->select('`id`') - ->from('`*PREFIX*share`') - ->where('`item_type` = :type') - ->andWhere('`item_source` = :source') - ->andWhere('`uid_owner` = :owner') - ->andWhere('`share_type` = :share_type') + $qb->select('id') + ->from('*PREFIX*share') + ->where($qb->expr()->eq('item_type', $qb->createParameter('type'))) + ->andWhere($qb->expr()->eq('item_source', $qb->createParameter('source'))) + ->andWhere($qb->expr()->eq('uid_owner', $qb->createParameter('owner'))) + ->andWhere($qb->expr()->eq('share_type', $qb->createParameter('share_type'))) ->setParameter('type', 'test') ->setParameter('source', 'test.txt') ->setParameter('owner', $this->user1) @@ -1308,9 +1308,9 @@ class Test_Share extends \Test\TestCase { // Fetch the hash from the database $qb = $connection->getQueryBuilder(); - $qb->select('`share_with`') - ->from('`*PREFIX*share`') - ->where('`id` = :id') + $qb->select('share_with') + ->from('*PREFIX*share') + ->where($qb->expr()->eq('id', $qb->createParameter('id'))) ->setParameter('id', $id); $hash = $qb->execute()->fetch()['share_with']; |