Passed
Push — master ( 70aa85...772303 )
by Morris
25:14 queued 14:09
created
lib/private/Files/Cache/Cache.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -172,21 +172,21 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader) {
174 174
 		//fix types
175
-		$data['fileid'] = (int)$data['fileid'];
176
-		$data['parent'] = (int)$data['parent'];
175
+		$data['fileid'] = (int) $data['fileid'];
176
+		$data['parent'] = (int) $data['parent'];
177 177
 		$data['size'] = 0 + $data['size'];
178
-		$data['mtime'] = (int)$data['mtime'];
179
-		$data['storage_mtime'] = (int)$data['storage_mtime'];
180
-		$data['encryptedVersion'] = (int)$data['encrypted'];
181
-		$data['encrypted'] = (bool)$data['encrypted'];
178
+		$data['mtime'] = (int) $data['mtime'];
179
+		$data['storage_mtime'] = (int) $data['storage_mtime'];
180
+		$data['encryptedVersion'] = (int) $data['encrypted'];
181
+		$data['encrypted'] = (bool) $data['encrypted'];
182 182
 		$data['storage_id'] = $data['storage'];
183
-		$data['storage'] = (int)$data['storage'];
183
+		$data['storage'] = (int) $data['storage'];
184 184
 		$data['mimetype'] = $mimetypeLoader->getMimetypeById($data['mimetype']);
185 185
 		$data['mimepart'] = $mimetypeLoader->getMimetypeById($data['mimepart']);
186 186
 		if ($data['storage_mtime'] == 0) {
187 187
 			$data['storage_mtime'] = $data['mtime'];
188 188
 		}
189
-		$data['permissions'] = (int)$data['permissions'];
189
+		$data['permissions'] = (int) $data['permissions'];
190 190
 		return new CacheEntry($data);
191 191
 	}
192 192
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 					FROM `*PREFIX*filecache` WHERE `parent` = ? ORDER BY `name` ASC';
215 215
 			$result = $this->connection->executeQuery($sql, [$fileId]);
216 216
 			$files = $result->fetchAll();
217
-			return array_map(function (array $data) {
217
+			return array_map(function(array $data) {
218 218
 				return self::cacheEntryFromData($data, $this->mimetypeLoader);
219 219
 			}, $files);
220 220
 		}
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 		$queryParts[] = '`storage`';
276 276
 		$params[] = $this->getNumericStorageId();
277 277
 
278
-		$queryParts = array_map(function ($item) {
278
+		$queryParts = array_map(function($item) {
279 279
 			return trim($item, "`");
280 280
 		}, $queryParts);
281 281
 		$values = array_combine($queryParts, $params);
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 			}
290 290
 
291 291
 			if ($builder->execute()) {
292
-				$fileId = (int)$this->connection->lastInsertId('*PREFIX*filecache');
292
+				$fileId = (int) $this->connection->lastInsertId('*PREFIX*filecache');
293 293
 				$this->eventDispatcher->dispatch(CacheInsertEvent::class, new CacheInsertEvent($this->storage, $file, $fileId));
294 294
 				return $fileId;
295 295
 			}
@@ -332,10 +332,10 @@  discard block
 block discarded – undo
332 332
 
333 333
 		// don't update if the data we try to set is the same as the one in the record
334 334
 		// some databases (Postgres) don't like superfluous updates
335
-		$sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? ' .
336
-			'WHERE (' .
337
-			implode(' <> ? OR ', $queryParts) . ' <> ? OR ' .
338
-			implode(' IS NULL OR ', $queryParts) . ' IS NULL' .
335
+		$sql = 'UPDATE `*PREFIX*filecache` SET '.implode(' = ?, ', $queryParts).'=? '.
336
+			'WHERE ('.
337
+			implode(' <> ? OR ', $queryParts).' <> ? OR '.
338
+			implode(' IS NULL OR ', $queryParts).' IS NULL'.
339 339
 			') AND `fileid` = ? ';
340 340
 		$this->connection->executeQuery($sql, $params);
341 341
 
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 					}
392 392
 				}
393 393
 				$params[] = $value;
394
-				$queryParts[] = '`' . $name . '`';
394
+				$queryParts[] = '`'.$name.'`';
395 395
 			}
396 396
 		}
397 397
 		return array($queryParts, $params);
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 			return -1;
434 434
 		} else {
435 435
 			$parent = $this->getParentPath($file);
436
-			return (int)$this->getId($parent);
436
+			return (int) $this->getId($parent);
437 437
 		}
438 438
 	}
439 439
 
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 	 */
480 480
 	private function getSubFolders($entry) {
481 481
 		$children = $this->getFolderContentsById($entry['fileid']);
482
-		return array_filter($children, function ($child) {
482
+		return array_filter($children, function($child) {
483 483
 			return $child['mimetype'] === 'httpd/unix-directory';
484 484
 		});
485 485
 	}
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
 			list($targetStorageId, $targetPath) = $this->getMoveInfo($targetPath);
544 544
 
545 545
 			if (is_null($sourceStorageId) || $sourceStorageId === false) {
546
-				throw new \Exception('Invalid source storage id: ' . $sourceStorageId);
546
+				throw new \Exception('Invalid source storage id: '.$sourceStorageId);
547 547
 			}
548 548
 			if (is_null($targetStorageId) || $targetStorageId === false) {
549
-				throw new \Exception('Invalid target storage id: ' . $targetStorageId);
549
+				throw new \Exception('Invalid target storage id: '.$targetStorageId);
550 550
 			}
551 551
 
552 552
 			$this->connection->beginTransaction();
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 					->set('path_hash', $fun->md5($newPathFunction))
566 566
 					->set('path', $newPathFunction)
567 567
 					->where($query->expr()->eq('storage', $query->createNamedParameter($sourceStorageId, IQueryBuilder::PARAM_INT)))
568
-					->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath) . '/%')));
568
+					->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath).'/%')));
569 569
 
570 570
 				try {
571 571
 					$query->execute();
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 		$sql = 'SELECT `size` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?';
615 615
 		$result = $this->connection->executeQuery($sql, array($this->getNumericStorageId(), $pathHash));
616 616
 		if ($row = $result->fetch()) {
617
-			if ((int)$row['size'] === -1) {
617
+			if ((int) $row['size'] === -1) {
618 618
 				return self::SHALLOW;
619 619
 			} else {
620 620
 				return self::COMPLETE;
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 	private function searchResultToCacheEntries(Statement $result) {
664 664
 		$files = $result->fetchAll();
665 665
 
666
-		return array_map(function (array $data) {
666
+		return array_map(function(array $data) {
667 667
 			return self::cacheEntryFromData($data, $this->mimetypeLoader);
668 668
 		}, $files);
669 669
 	}
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 			$where = '`mimepart` = ?';
683 683
 		}
684 684
 		$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `storage_mtime`, `mtime`, `encrypted`, `etag`, `permissions`, `checksum`
685
-				FROM `*PREFIX*filecache` WHERE ' . $where . ' AND `storage` = ?';
685
+				FROM `*PREFIX*filecache` WHERE ' . $where.' AND `storage` = ?';
686 686
 		$mimetype = $this->mimetypeLoader->getId($mimetype);
687 687
 		$result = $this->connection->executeQuery($sql, array($mimetype, $this->getNumericStorageId()));
688 688
 
@@ -733,20 +733,20 @@  discard block
 block discarded – undo
733 733
 	 * @return ICacheEntry[] file data
734 734
 	 */
735 735
 	public function searchByTag($tag, $userId) {
736
-		$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, ' .
737
-			'`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, ' .
738
-			'`encrypted`, `etag`, `permissions`, `checksum` ' .
739
-			'FROM `*PREFIX*filecache` `file`, ' .
740
-			'`*PREFIX*vcategory_to_object` `tagmap`, ' .
741
-			'`*PREFIX*vcategory` `tag` ' .
736
+		$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, '.
737
+			'`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, '.
738
+			'`encrypted`, `etag`, `permissions`, `checksum` '.
739
+			'FROM `*PREFIX*filecache` `file`, '.
740
+			'`*PREFIX*vcategory_to_object` `tagmap`, '.
741
+			'`*PREFIX*vcategory` `tag` '.
742 742
 			// JOIN filecache to vcategory_to_object
743
-			'WHERE `file`.`fileid` = `tagmap`.`objid` ' .
743
+			'WHERE `file`.`fileid` = `tagmap`.`objid` '.
744 744
 			// JOIN vcategory_to_object to vcategory
745
-			'AND `tagmap`.`type` = `tag`.`type` ' .
746
-			'AND `tagmap`.`categoryid` = `tag`.`id` ' .
745
+			'AND `tagmap`.`type` = `tag`.`type` '.
746
+			'AND `tagmap`.`categoryid` = `tag`.`id` '.
747 747
 			// conditions
748
-			'AND `file`.`storage` = ? ' .
749
-			'AND `tag`.`type` = \'files\' ' .
748
+			'AND `file`.`storage` = ? '.
749
+			'AND `tag`.`type` = \'files\' '.
750 750
 			'AND `tag`.`uid` = ? ';
751 751
 		if (is_int($tag)) {
752 752
 			$sql .= 'AND `tag`.`id` = ? ';
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 
765 765
 		$files = $result->fetchAll();
766 766
 
767
-		return array_map(function (array $data) {
767
+		return array_map(function(array $data) {
768 768
 			return self::cacheEntryFromData($data, $this->mimetypeLoader);
769 769
 		}, $files);
770 770
 	}
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 			$sql = 'SELECT count(*)
805 805
 					FROM `*PREFIX*filecache` WHERE `parent` = ? AND size = -1';
806 806
 			$result = $this->connection->executeQuery($sql, [$fileId]);
807
-			return (int)$result->fetchColumn();
807
+			return (int) $result->fetchColumn();
808 808
 		}
809 809
 		return -1;
810 810
 	}
@@ -823,8 +823,8 @@  discard block
 block discarded – undo
823 823
 		}
824 824
 		if (isset($entry['mimetype']) && $entry['mimetype'] === 'httpd/unix-directory') {
825 825
 			$id = $entry['fileid'];
826
-			$sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 ' .
827
-				'FROM `*PREFIX*filecache` ' .
826
+			$sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 '.
827
+				'FROM `*PREFIX*filecache` '.
828 828
 				'WHERE `parent` = ? AND `storage` = ?';
829 829
 			$result = $this->connection->executeQuery($sql, array($id, $this->getNumericStorageId()));
830 830
 			if ($row = $result->fetch()) {
Please login to merge, or discard this patch.