From 1eb86c85c6073190f69d8c57e6e74609926606d3 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 28 Aug 2024 10:41:47 +0200 Subject: [PATCH] chore: Apply php:cs recommendations Signed-off-by: Louis Chemineau --- apps/files/lib/BackgroundJob/ScanFiles.php | 4 +- .../lib/DeleteOrphanedSharesJob.php | 2 +- lib/composer/composer/InstalledVersions.php | 4 +- lib/composer/composer/LICENSE | 2 - lib/composer/composer/installed.json | 69 ++++++++++++++++++- lib/composer/composer/installed.php | 15 +++- lib/private/DB/ArrayResult.php | 4 +- .../Partitioned/JoinCondition.php | 8 +-- .../Partitioned/PartitionedQueryBuilder.php | 4 +- .../Sharded/AutoIncrementHandler.php | 20 +++--- .../Sharded/CrossShardMoveHelper.php | 8 +-- .../QueryBuilder/Sharded/ShardDefinition.php | 2 +- .../QueryBuilder/Sharded/ShardQueryRunner.php | 4 +- .../Sharded/ShardedQueryBuilder.php | 10 +-- lib/private/Files/Cache/Cache.php | 18 ++--- .../Partitioned/JoinConditionTest.php | 2 +- .../Sharded/SharedQueryBuilderTest.php | 4 +- tests/lib/Files/Cache/CacheTest.php | 14 ++-- .../lib/Preview/BackgroundCleanupJobTest.php | 4 +- tests/preseed-config.php | 12 ++-- 20 files changed, 140 insertions(+), 70 deletions(-) diff --git a/apps/files/lib/BackgroundJob/ScanFiles.php b/apps/files/lib/BackgroundJob/ScanFiles.php index 42beb70aaf5d6..b7e6e8db10ecb 100644 --- a/apps/files/lib/BackgroundJob/ScanFiles.php +++ b/apps/files/lib/BackgroundJob/ScanFiles.php @@ -70,7 +70,7 @@ protected function runScanner(string $user): void { * @return string|false */ private function getUserToScan() { - if ($this->connection->getShardDefinition("filecache")) { + if ($this->connection->getShardDefinition('filecache')) { // for sharded filecache, the "LIMIT" from the normal query doesn't work // first we try it with a "LEFT JOIN" on mounts, this is fast, but might return a storage that isn't mounted. @@ -82,7 +82,7 @@ private function getUserToScan() { ->where($query->expr()->lt('f.size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))) ->andWhere($query->expr()->gt('f.parent', $query->createNamedParameter(-1, IQueryBuilder::PARAM_INT))) ->setMaxResults(10) - ->groupBy("f.storage") + ->groupBy('f.storage') ->runAcrossAllShards(); $result = $query->executeQuery(); diff --git a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php index 7b55ac59da102..2315ff5c12070 100644 --- a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php +++ b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php @@ -120,7 +120,7 @@ private function shardingCleanup(): void { $this->atomic(function () use ($deletedFiles, $deleteQb) { $deleteQb->setParameter('ids', $deletedFiles, IQueryBuilder::PARAM_INT_ARRAY); $deleted = $deleteQb->executeStatement(); - $this->logger->debug("{deleted} orphaned share(s) deleted", [ + $this->logger->debug('{deleted} orphaned share(s) deleted', [ 'app' => 'DeleteOrphanedSharesJob', 'deleted' => $deleted, ]); diff --git a/lib/composer/composer/InstalledVersions.php b/lib/composer/composer/InstalledVersions.php index 51e734a774b3e..39e55eab59a5e 100644 --- a/lib/composer/composer/InstalledVersions.php +++ b/lib/composer/composer/InstalledVersions.php @@ -266,7 +266,7 @@ public static function getRawData() if (null === self::$installed) { // only require the installed.php file if this file is loaded from its dumped location, // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { + if (substr(__DIR__, -8, 1) !== 'C' && is_file(__DIR__ . '/installed.php')) { self::$installed = include __DIR__ . '/installed.php'; } else { self::$installed = array(); @@ -341,7 +341,7 @@ private static function getInstalled() if (null === self::$installed) { // only require the installed.php file if this file is loaded from its dumped location, // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { + if (substr(__DIR__, -8, 1) !== 'C' && is_file(__DIR__ . '/installed.php')) { /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ $required = require __DIR__ . '/installed.php'; self::$installed = $required; diff --git a/lib/composer/composer/LICENSE b/lib/composer/composer/LICENSE index f27399a042d95..62ecfd8d0046b 100644 --- a/lib/composer/composer/LICENSE +++ b/lib/composer/composer/LICENSE @@ -1,4 +1,3 @@ - Copyright (c) Nils Adermann, Jordi Boggiano Permission is hereby granted, free of charge, to any person obtaining a copy @@ -18,4 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/lib/composer/composer/installed.json b/lib/composer/composer/installed.json index f20a6c47c6d4f..13ea12dca2a27 100644 --- a/lib/composer/composer/installed.json +++ b/lib/composer/composer/installed.json @@ -1,5 +1,68 @@ { - "packages": [], - "dev": false, - "dev-package-names": [] + "packages": [ + { + "name": "bamarni/composer-bin-plugin", + "version": "1.8.2", + "version_normalized": "1.8.2.0", + "source": { + "type": "git", + "url": "https://github.com/bamarni/composer-bin-plugin.git", + "reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880", + "reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "ext-json": "*", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.5", + "symfony/console": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0", + "symfony/finder": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0", + "symfony/process": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0" + }, + "time": "2022-10-31T08:38:03+00:00", + "type": "composer-plugin", + "extra": { + "class": "Bamarni\\Composer\\Bin\\BamarniBinPlugin" + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Bamarni\\Composer\\Bin\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "No conflicts for your bin dependencies", + "keywords": [ + "composer", + "conflict", + "dependency", + "executable", + "isolation", + "tool" + ], + "support": { + "issues": "https://github.com/bamarni/composer-bin-plugin/issues", + "source": "https://github.com/bamarni/composer-bin-plugin/tree/1.8.2" + }, + "install-path": "../bamarni/composer-bin-plugin" + } + ], + "dev": true, + "dev-package-names": [ + "bamarni/composer-bin-plugin" + ] } diff --git a/lib/composer/composer/installed.php b/lib/composer/composer/installed.php index 5fe8d8f7f491f..51b06396ba223 100644 --- a/lib/composer/composer/installed.php +++ b/lib/composer/composer/installed.php @@ -3,21 +3,30 @@ 'name' => '__root__', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'b99276fdfbac6b1ff243807b8b5b8161f0f67a24', + 'reference' => '9d0248545d85d6a680f2c9507f1bcfe13e889535', 'type' => 'library', 'install_path' => __DIR__ . '/../../../', 'aliases' => array(), - 'dev' => false, + 'dev' => true, ), 'versions' => array( '__root__' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => 'b99276fdfbac6b1ff243807b8b5b8161f0f67a24', + 'reference' => '9d0248545d85d6a680f2c9507f1bcfe13e889535', 'type' => 'library', 'install_path' => __DIR__ . '/../../../', 'aliases' => array(), 'dev_requirement' => false, ), + 'bamarni/composer-bin-plugin' => array( + 'pretty_version' => '1.8.2', + 'version' => '1.8.2.0', + 'reference' => '92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880', + 'type' => 'composer-plugin', + 'install_path' => __DIR__ . '/../bamarni/composer-bin-plugin', + 'aliases' => array(), + 'dev_requirement' => true, + ), ), ); diff --git a/lib/private/DB/ArrayResult.php b/lib/private/DB/ArrayResult.php index 5d094533a3f39..b567ad23d577f 100644 --- a/lib/private/DB/ArrayResult.php +++ b/lib/private/DB/ArrayResult.php @@ -37,7 +37,7 @@ public function fetch(int $fetchMode = PDO::FETCH_ASSOC) { PDO::FETCH_ASSOC => $row, PDO::FETCH_NUM => array_values($row), PDO::FETCH_COLUMN => current($row), - default => throw new \InvalidArgumentException("Fetch mode not supported for array result"), + default => throw new \InvalidArgumentException('Fetch mode not supported for array result'), }; } @@ -51,7 +51,7 @@ public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array { PDO::FETCH_COLUMN => array_map(function ($row) { return current($row); }, $this->rows), - default => throw new \InvalidArgumentException("Fetch mode not supported for array result"), + default => throw new \InvalidArgumentException('Fetch mode not supported for array result'), }; } diff --git a/lib/private/DB/QueryBuilder/Partitioned/JoinCondition.php b/lib/private/DB/QueryBuilder/Partitioned/JoinCondition.php index ff4e1da70b966..a08858d1d6bd6 100644 --- a/lib/private/DB/QueryBuilder/Partitioned/JoinCondition.php +++ b/lib/private/DB/QueryBuilder/Partitioned/JoinCondition.php @@ -37,8 +37,8 @@ public function __construct( * @return JoinCondition */ public static function merge(array $conditions): JoinCondition { - $fromColumn = ""; - $toColumn = ""; + $fromColumn = ''; + $toColumn = ''; $fromAlias = null; $toAlias = null; $fromConditions = []; @@ -99,9 +99,9 @@ private static function parseSubCondition($condition, string $join, string $alia $isSubCondition = self::isExtraCondition($condition); if ($isSubCondition) { if (self::mentionsAlias($condition, $fromAlias)) { - return new JoinCondition("", null, "", null, [$condition], []); + return new JoinCondition('', null, '', null, [$condition], []); } else { - return new JoinCondition("", null, "", null, [], [$condition]); + return new JoinCondition('', null, '', null, [], [$condition]); } } diff --git a/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php b/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php index 8fcde0d24ae29..175b7c1a42eb7 100644 --- a/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php +++ b/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php @@ -391,10 +391,10 @@ public function executeQuery(?IDBConnection $connection = null): IResult { }, false); if ($hasNonLeftJoins) { if (is_int($this->limit)) { - throw new InvalidPartitionedQueryException("Limit is not allowed in partitioned queries"); + throw new InvalidPartitionedQueryException('Limit is not allowed in partitioned queries'); } if (is_int($this->offset)) { - throw new InvalidPartitionedQueryException("Offset is not allowed in partitioned queries"); + throw new InvalidPartitionedQueryException('Offset is not allowed in partitioned queries'); } } } diff --git a/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php b/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php index 553644def4e1b..d40934669d741 100644 --- a/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php +++ b/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php @@ -29,13 +29,13 @@ public function __construct( private ShardConnectionManager $shardConnectionManager, ) { if (PHP_INT_SIZE < 8) { - throw new \Exception("sharding is only supported with 64bit php"); + throw new \Exception('sharding is only supported with 64bit php'); } } private function getCache(): IMemcache { if(is_null($this->cache)) { - $cache = $this->cacheFactory->createDistributed("shared_autoincrement"); + $cache = $this->cacheFactory->createDistributed('shared_autoincrement'); if ($cache instanceof IMemcache) { $this->cache = $cache; } else { @@ -61,7 +61,7 @@ public function getNextPrimaryKey(ShardDefinition $shardDefinition, int $shard): $next = $this->getNextInner($shardDefinition); if ($next !== null) { if ($next > ShardDefinition::MAX_PRIMARY_KEY) { - throw new \Exception("Max primary key of " . ShardDefinition::MAX_PRIMARY_KEY . " exceeded"); + throw new \Exception('Max primary key of ' . ShardDefinition::MAX_PRIMARY_KEY . ' exceeded'); } // we encode the shard the primary key was originally inserted into to allow guessing the shard by primary key later on return ($next << 8) | $shard; @@ -69,7 +69,7 @@ public function getNextPrimaryKey(ShardDefinition $shardDefinition, int $shard): $retries++; } } - throw new \Exception("Failed to get next primary key"); + throw new \Exception('Failed to get next primary key'); } /** @@ -88,7 +88,7 @@ private function getNextInner(ShardDefinition $shardDefinition): ?int { // if that is not the case we find the highest used id in the database increment it, and save it in the cache // prevent inc from returning `1` if the key doesn't exist by setting it to a non-numeric value - $cache->add($shardDefinition->table, "empty-placeholder", self::TTL); + $cache->add($shardDefinition->table, 'empty-placeholder', self::TTL); $next = $cache->inc($shardDefinition->table); if ($cache instanceof IMemcacheTTL) { @@ -101,7 +101,7 @@ private function getNextInner(ShardDefinition $shardDefinition): ?int { return $next; } elseif (is_int($next)) { // we hit the edge case, so invalidate the cached value - if (!$cache->cas($shardDefinition->table, $next, "empty-placeholder")) { + if (!$cache->cas($shardDefinition->table, $next, 'empty-placeholder')) { // someone else is changing the value concurrently, give up and retry return null; } @@ -110,7 +110,7 @@ private function getNextInner(ShardDefinition $shardDefinition): ?int { // discard the encoded initial shard $current = $this->getMaxFromDb($shardDefinition) >> 8; $next = max($current, self::MIN_VALID_KEY) + 1; - if ($cache->cas($shardDefinition->table, "empty-placeholder", $next)) { + if ($cache->cas($shardDefinition->table, 'empty-placeholder', $next)) { return $next; } @@ -120,11 +120,11 @@ private function getNextInner(ShardDefinition $shardDefinition): ?int { return $next; } elseif(is_int($next)) { // key got cleared, invalidate and retry - $cache->cas($shardDefinition->table, $next, "empty-placeholder"); + $cache->cas($shardDefinition->table, $next, 'empty-placeholder'); return null; } else { // cleanup any non-numeric value other than the placeholder if that got stored somehow - $cache->ncad($shardDefinition->table, "empty-placeholder"); + $cache->ncad($shardDefinition->table, 'empty-placeholder'); // retry return null; } @@ -140,7 +140,7 @@ private function getMaxFromDb(ShardDefinition $shardDefinition): int { $query = $connection->getQueryBuilder(); $query->select($shardDefinition->primaryKey) ->from($shardDefinition->table) - ->orderBy($shardDefinition->primaryKey, "DESC") + ->orderBy($shardDefinition->primaryKey, 'DESC') ->setMaxResults(1); $result = $query->executeQuery()->fetchOne(); if ($result) { diff --git a/lib/private/DB/QueryBuilder/Sharded/CrossShardMoveHelper.php b/lib/private/DB/QueryBuilder/Sharded/CrossShardMoveHelper.php index ffc95e4e54c05..45f24e326858c 100644 --- a/lib/private/DB/QueryBuilder/Sharded/CrossShardMoveHelper.php +++ b/lib/private/DB/QueryBuilder/Sharded/CrossShardMoveHelper.php @@ -83,13 +83,13 @@ public function loadItems(IDBConnection $connection, string $table, string $prim $query = $connection->getQueryBuilder(); $query->select('*') ->from($table) - ->where($query->expr()->in($primaryColumn, $query->createParameter("keys"))); + ->where($query->expr()->in($primaryColumn, $query->createParameter('keys'))); $chunks = array_chunk($primaryKeys, 1000); $results = []; foreach ($chunks as $chunk) { - $query->setParameter("keys", $chunk, IQueryBuilder::PARAM_INT_ARRAY); + $query->setParameter('keys', $chunk, IQueryBuilder::PARAM_INT_ARRAY); $results = array_merge($results, $query->execute()->fetchAll()); } @@ -151,11 +151,11 @@ public function updateItems(IDBConnection $connection, string $table, string $sh public function deleteItems(IDBConnection $connection, string $table, string $primaryColumn, array $primaryKeys): void { $query = $connection->getQueryBuilder(); $query->delete($table) - ->where($query->expr()->in($primaryColumn, $query->createParameter("keys"))); + ->where($query->expr()->in($primaryColumn, $query->createParameter('keys'))); $chunks = array_chunk($primaryKeys, 1000); foreach ($chunks as $chunk) { - $query->setParameter("keys", $chunk, IQueryBuilder::PARAM_INT_ARRAY); + $query->setParameter('keys', $chunk, IQueryBuilder::PARAM_INT_ARRAY); $query->executeStatement(); } } diff --git a/lib/private/DB/QueryBuilder/Sharded/ShardDefinition.php b/lib/private/DB/QueryBuilder/Sharded/ShardDefinition.php index 5661ca079e1c1..ebccbb639a624 100644 --- a/lib/private/DB/QueryBuilder/Sharded/ShardDefinition.php +++ b/lib/private/DB/QueryBuilder/Sharded/ShardDefinition.php @@ -41,7 +41,7 @@ public function __construct( public array $shards = [], ) { if (count($this->shards) >= self::MAX_SHARDS) { - throw new \Exception("Only allowed maximum of " . self::MAX_SHARDS . " shards allowed"); + throw new \Exception('Only allowed maximum of ' . self::MAX_SHARDS . ' shards allowed'); } } diff --git a/lib/private/DB/QueryBuilder/Sharded/ShardQueryRunner.php b/lib/private/DB/QueryBuilder/Sharded/ShardQueryRunner.php index 22b86a018b3dc..51cd055e801fa 100644 --- a/lib/private/DB/QueryBuilder/Sharded/ShardQueryRunner.php +++ b/lib/private/DB/QueryBuilder/Sharded/ShardQueryRunner.php @@ -135,7 +135,7 @@ public function executeQuery( if ($cmp === 0) { continue; } - if ($sort['order'] === "DESC") { + if ($sort['order'] === 'DESC') { $cmp = -$cmp; } return $cmp; @@ -166,7 +166,7 @@ public function executeQuery( */ public function executeStatement(IQueryBuilder $query, bool $allShards, array $shardKeys, array $primaryKeys): int { if ($query->getType() === \Doctrine\DBAL\Query\QueryBuilder::INSERT) { - throw new \Exception("insert queries need special handling"); + throw new \Exception('insert queries need special handling'); } $shards = $this->getShards($allShards, $shardKeys); diff --git a/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php b/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php index 650e414096e65..e7bc70ce440c3 100644 --- a/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php +++ b/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php @@ -36,7 +36,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { private ?int $updateShardKey = null; private ?int $limit = null; private ?int $offset = null; - /** @var array{column: string, order: string}[] */ + /** @var array{column: string, order: string}[] */ private array $sortList = []; private string $mainTable = ''; @@ -276,13 +276,13 @@ public function setFirstResult($firstResult) { } public function addOrderBy($sort, $order = null) { - $this->registerOrder((string) $sort, (string)$order ?? "ASC"); + $this->registerOrder((string)$sort, (string)$order ?? 'ASC'); return parent::orderBy($sort, $order); } public function orderBy($sort, $order = null) { $this->sortList = []; - $this->registerOrder((string) $sort, (string)$order ?? "ASC"); + $this->registerOrder((string)$sort, (string)$order ?? 'ASC'); return parent::orderBy($sort, $order); } @@ -329,7 +329,7 @@ public function validate(): void { } if ($this->shardDefinition && !$this->allShards) { if (empty($this->getShardKeys()) && empty($this->getPrimaryKeys())) { - throw new InvalidShardedQueryException("No shard key or primary key set for query"); + throw new InvalidShardedQueryException('No shard key or primary key set for query'); } } if ($this->shardDefinition && $this->updateShardKey) { @@ -347,7 +347,7 @@ public function validate(): void { }, $oldShardKeys))); $newShard = $this->shardDefinition->getShardForKey((int)$newShardKey); if ($oldShards === [$newShard]) { - throw new InvalidShardedQueryException("Update statement would move rows to a different shard"); + throw new InvalidShardedQueryException('Update statement would move rows to a different shard'); } } } diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 8cb203ab2bcd4..a8d9067050dc0 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -1220,9 +1220,9 @@ private function moveFromStorageSharded(ShardDefinition $shardDefinition, ICache $sourceConnection = $helper->getConnection($shardDefinition, $sourceCache->getNumericStorageId()); $targetConnection = $helper->getConnection($shardDefinition, $this->getNumericStorageId()); - $cacheItems = $helper->loadItems($sourceConnection, "filecache", "fileid", $fileIds); - $extendedItems = $helper->loadItems($sourceConnection, "filecache_extended", "fileid", $fileIds); - $metadataItems = $helper->loadItems($sourceConnection, "files_metadata", "file_id", $fileIds); + $cacheItems = $helper->loadItems($sourceConnection, 'filecache', 'fileid', $fileIds); + $extendedItems = $helper->loadItems($sourceConnection, 'filecache_extended', 'fileid', $fileIds); + $metadataItems = $helper->loadItems($sourceConnection, 'files_metadata', 'file_id', $fileIds); // when moving from an encrypted storage to a non-encrypted storage remove the `encrypted` mark $removeEncryptedFlag = ($sourceCache instanceof Cache && $sourceCache->hasEncryptionWrapper()) && !$this->hasEncryptionWrapper(); @@ -1246,9 +1246,9 @@ private function moveFromStorageSharded(ShardDefinition $shardDefinition, ICache $targetConnection->beginTransaction(); try { - $helper->saveItems($targetConnection, "filecache", $cacheItems); - $helper->saveItems($targetConnection, "filecache_extended", $extendedItems); - $helper->saveItems($targetConnection, "files_metadata", $metadataItems); + $helper->saveItems($targetConnection, 'filecache', $cacheItems); + $helper->saveItems($targetConnection, 'filecache_extended', $extendedItems); + $helper->saveItems($targetConnection, 'files_metadata', $metadataItems); } catch (\Exception $e) { $targetConnection->rollback(); throw $e; @@ -1257,9 +1257,9 @@ private function moveFromStorageSharded(ShardDefinition $shardDefinition, ICache $sourceConnection->beginTransaction(); try { - $helper->deleteItems($sourceConnection, "filecache", "fileid", $fileIds); - $helper->deleteItems($sourceConnection, "filecache_extended", "fileid", $fileIds); - $helper->deleteItems($sourceConnection, "files_metadata", "file_id", $fileIds); + $helper->deleteItems($sourceConnection, 'filecache', 'fileid', $fileIds); + $helper->deleteItems($sourceConnection, 'filecache_extended', 'fileid', $fileIds); + $helper->deleteItems($sourceConnection, 'files_metadata', 'file_id', $fileIds); } catch (\Exception $e) { $targetConnection->rollback(); $sourceConnection->rollBack(); diff --git a/tests/lib/DB/QueryBuilder/Partitioned/JoinConditionTest.php b/tests/lib/DB/QueryBuilder/Partitioned/JoinConditionTest.php index 56a8e5783aa2b..a8ebf11c2c2f4 100644 --- a/tests/lib/DB/QueryBuilder/Partitioned/JoinConditionTest.php +++ b/tests/lib/DB/QueryBuilder/Partitioned/JoinConditionTest.php @@ -47,7 +47,7 @@ private function getBuilder(string $platform): IQueryBuilder { public function testParseCondition(string $platform): void { $query = $this->getBuilder($platform); $param1 = $query->createNamedParameter('files'); - $param2 = $query->createNamedParameter("test"); + $param2 = $query->createNamedParameter('test'); $condition = $query->expr()->andX( $query->expr()->eq('tagmap.categoryid', 'tag.id'), $query->expr()->eq('tag.type', $param1), diff --git a/tests/lib/DB/QueryBuilder/Sharded/SharedQueryBuilderTest.php b/tests/lib/DB/QueryBuilder/Sharded/SharedQueryBuilderTest.php index 83261729e5e56..7af93bbbe590a 100644 --- a/tests/lib/DB/QueryBuilder/Sharded/SharedQueryBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/Sharded/SharedQueryBuilderTest.php @@ -91,7 +91,7 @@ public function testValidateWithNoKey() { $this->expectException(InvalidShardedQueryException::class); $query->validate(); - $this->fail("exception expected"); + $this->fail('exception expected'); } public function testValidateNonSharedTable() { @@ -114,7 +114,7 @@ public function testGetShardKeyMultipleSingleParam() { $query->expr()->eq('storage', $query->createNamedParameter(10, IQueryBuilder::PARAM_INT)), $query->expr()->andX( $query->expr()->eq('storage', $query->createNamedParameter(11, IQueryBuilder::PARAM_INT)), - $query->expr()->like('path', $query->createNamedParameter("foo/%")) + $query->expr()->like('path', $query->createNamedParameter('foo/%')) ) ) )); diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php index 9f6d708075733..b90b67a6589ef 100644 --- a/tests/lib/Files/Cache/CacheTest.php +++ b/tests/lib/Files/Cache/CacheTest.php @@ -487,17 +487,17 @@ public function testMoveFromCache() { $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar']; $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; - $this->cache2->put("folder", $folderData); - $this->cache2->put("folder/sub", $data); + $this->cache2->put('folder', $folderData); + $this->cache2->put('folder/sub', $data); - $this->cache->moveFromCache($this->cache2, "folder", "targetfolder"); + $this->cache->moveFromCache($this->cache2, 'folder', 'targetfolder'); - $this->assertFalse($this->cache2->inCache("folder")); - $this->assertFalse($this->cache2->inCache("folder/sub")); + $this->assertFalse($this->cache2->inCache('folder')); + $this->assertFalse($this->cache2->inCache('folder/sub')); - $this->assertTrue($this->cache->inCache("targetfolder")); - $this->assertTrue($this->cache->inCache("targetfolder/sub")); + $this->assertTrue($this->cache->inCache('targetfolder')); + $this->assertTrue($this->cache->inCache('targetfolder/sub')); } public function testGetIncomplete() { diff --git a/tests/lib/Preview/BackgroundCleanupJobTest.php b/tests/lib/Preview/BackgroundCleanupJobTest.php index ccd5dba69cf05..82f1979772800 100644 --- a/tests/lib/Preview/BackgroundCleanupJobTest.php +++ b/tests/lib/Preview/BackgroundCleanupJobTest.php @@ -147,7 +147,7 @@ public function testCleanupSystemCron() { public function testCleanupAjax() { if ($this->connection->getShardDefinition('filecache')) { - $this->markTestSkipped("ajax cron is not supported for sharded setups"); + $this->markTestSkipped('ajax cron is not supported for sharded setups'); return; } $files = $this->setup11Previews(); @@ -179,7 +179,7 @@ public function testCleanupAjax() { public function testOldPreviews() { if ($this->connection->getShardDefinition('filecache')) { - $this->markTestSkipped("old previews are not supported for sharded setups"); + $this->markTestSkipped('old previews are not supported for sharded setups'); return; } $appdata = \OC::$server->getAppDataDir('preview'); diff --git a/tests/preseed-config.php b/tests/preseed-config.php index 7c341278027ce..f9c1593946946 100644 --- a/tests/preseed-config.php +++ b/tests/preseed-config.php @@ -81,19 +81,19 @@ if (getenv('SHARDING') == '1') { $CONFIG['dbsharding'] = [ - "filecache" => [ - "shards" => [ + 'filecache' => [ + 'shards' => [ [ - "port" => 5001, + 'port' => 5001, ], [ - "port" => 5002, + 'port' => 5002, ], [ - "port" => 5003, + 'port' => 5003, ], [ - "port" => 5004, + 'port' => 5004, ], ] ]