@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | namespace OC\Files\Storage; |
34 | 34 | |
35 | -class CommonTest extends \OC\Files\Storage\Common{ |
|
35 | +class CommonTest extends \OC\Files\Storage\Common { |
|
36 | 36 | /** |
37 | 37 | * underlying local storage used for missing functions |
38 | 38 | * @var \OC\Files\Storage\Local |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | private $storage; |
41 | 41 | |
42 | 42 | public function __construct($params) { |
43 | - $this->storage=new \OC\Files\Storage\Local($params); |
|
43 | + $this->storage = new \OC\Files\Storage\Local($params); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function getId(){ |
|
46 | + public function getId() { |
|
47 | 47 | return 'test::'.$this->storage->getId(); |
48 | 48 | } |
49 | 49 | public function mkdir($path) { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function free_space($path) { |
80 | 80 | return $this->storage->free_space($path); |
81 | 81 | } |
82 | - public function touch($path, $mtime=null) { |
|
82 | + public function touch($path, $mtime = null) { |
|
83 | 83 | return $this->storage->touch($path, $mtime); |
84 | 84 | } |
85 | 85 | } |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | $this->storageId = self::adjustStorageId($this->storageId); |
70 | 70 | |
71 | 71 | if ($row = self::getStorageById($this->storageId)) { |
72 | - $this->numericId = (int)$row['numeric_id']; |
|
72 | + $this->numericId = (int) $row['numeric_id']; |
|
73 | 73 | } else { |
74 | 74 | $connection = \OC::$server->getDatabaseConnection(); |
75 | 75 | $available = $isAvailable ? 1 : 0; |
76 | 76 | if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId, 'available' => $available])) { |
77 | - $this->numericId = (int)$connection->lastInsertId('*PREFIX*storages'); |
|
77 | + $this->numericId = (int) $connection->lastInsertId('*PREFIX*storages'); |
|
78 | 78 | } else { |
79 | 79 | if ($row = self::getStorageById($this->storageId)) { |
80 | - $this->numericId = (int)$row['numeric_id']; |
|
80 | + $this->numericId = (int) $row['numeric_id']; |
|
81 | 81 | } else { |
82 | 82 | throw new \RuntimeException('Storage could neither be inserted nor be selected from the database'); |
83 | 83 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $storageId = self::adjustStorageId($storageId); |
143 | 143 | |
144 | 144 | if ($row = self::getStorageById($storageId)) { |
145 | - return (int)$row['numeric_id']; |
|
145 | + return (int) $row['numeric_id']; |
|
146 | 146 | } else { |
147 | 147 | return null; |
148 | 148 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | public function getAvailability() { |
155 | 155 | if ($row = self::getStorageById($this->storageId)) { |
156 | 156 | return [ |
157 | - 'available' => ((int)$row['available'] === 1), |
|
157 | + 'available' => ((int) $row['available'] === 1), |
|
158 | 158 | 'last_checked' => $row['last_checked'] |
159 | 159 | ]; |
160 | 160 | } else { |
@@ -58,7 +58,7 @@ |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | public function getId() { |
61 | - return (int)$this->data['fileid']; |
|
61 | + return (int) $this->data['fileid']; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | public function getStorageId() { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param int $sizeDifference number of bytes the file has grown |
61 | 61 | */ |
62 | 62 | public function propagateChange($internalPath, $time, $sizeDifference = 0) { |
63 | - $storageId = (int)$this->storage->getStorageCache()->getNumericId(); |
|
63 | + $storageId = (int) $this->storage->getStorageCache()->getNumericId(); |
|
64 | 64 | |
65 | 65 | $parents = $this->getParents($internalPath); |
66 | 66 | |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | $etag = uniqid(); // since we give all folders the same etag we don't ask the storage for the etag |
76 | 76 | |
77 | 77 | $builder = $this->connection->getQueryBuilder(); |
78 | - $hashParams = array_map(function ($hash) use ($builder) { |
|
78 | + $hashParams = array_map(function($hash) use ($builder) { |
|
79 | 79 | return $builder->expr()->literal($hash); |
80 | 80 | }, $parentHashes); |
81 | 81 | |
82 | 82 | $builder->update('filecache') |
83 | - ->set('mtime', $builder->createFunction('GREATEST(`mtime`, ' . $builder->createNamedParameter((int)$time, IQueryBuilder::PARAM_INT) . ')')) |
|
83 | + ->set('mtime', $builder->createFunction('GREATEST(`mtime`, '.$builder->createNamedParameter((int) $time, IQueryBuilder::PARAM_INT).')')) |
|
84 | 84 | ->set('etag', $builder->createNamedParameter($etag, IQueryBuilder::PARAM_STR)) |
85 | 85 | ->where($builder->expr()->eq('storage', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))) |
86 | 86 | ->andWhere($builder->expr()->in('path_hash', $hashParams)); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // we need to do size separably so we can ignore entries with uncalculated size |
92 | 92 | $builder = $this->connection->getQueryBuilder(); |
93 | 93 | $builder->update('filecache') |
94 | - ->set('size', $builder->createFunction('`size` + ' . $builder->createNamedParameter($sizeDifference))) |
|
94 | + ->set('size', $builder->createFunction('`size` + '.$builder->createNamedParameter($sizeDifference))) |
|
95 | 95 | ->where($builder->expr()->eq('storage', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))) |
96 | 96 | ->andWhere($builder->expr()->in('path_hash', $hashParams)) |
97 | 97 | ->andWhere($builder->expr()->gt('size', $builder->expr()->literal(-1, IQueryBuilder::PARAM_INT))); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $parents = []; |
107 | 107 | foreach ($parts as $part) { |
108 | 108 | $parents[] = $parent; |
109 | - $parent = trim($parent . '/' . $part, '/'); |
|
109 | + $parent = trim($parent.'/'.$part, '/'); |
|
110 | 110 | } |
111 | 111 | return $parents; |
112 | 112 | } |
@@ -150,17 +150,17 @@ discard block |
||
150 | 150 | $this->connection->beginTransaction(); |
151 | 151 | |
152 | 152 | $query = $this->connection->getQueryBuilder(); |
153 | - $storageId = (int)$this->storage->getStorageCache()->getNumericId(); |
|
153 | + $storageId = (int) $this->storage->getStorageCache()->getNumericId(); |
|
154 | 154 | |
155 | 155 | $query->update('filecache') |
156 | - ->set('mtime', $query->createFunction('GREATEST(`mtime`, ' . $query->createParameter('time') . ')')) |
|
156 | + ->set('mtime', $query->createFunction('GREATEST(`mtime`, '.$query->createParameter('time').')')) |
|
157 | 157 | ->set('etag', $query->expr()->literal(uniqid())) |
158 | 158 | ->where($query->expr()->eq('storage', $query->expr()->literal($storageId, IQueryBuilder::PARAM_INT))) |
159 | 159 | ->andWhere($query->expr()->eq('path_hash', $query->createParameter('hash'))); |
160 | 160 | |
161 | 161 | $sizeQuery = $this->connection->getQueryBuilder(); |
162 | 162 | $sizeQuery->update('filecache') |
163 | - ->set('size', $sizeQuery->createFunction('`size` + ' . $sizeQuery->createParameter('size'))) |
|
163 | + ->set('size', $sizeQuery->createFunction('`size` + '.$sizeQuery->createParameter('size'))) |
|
164 | 164 | ->where($query->expr()->eq('storage', $query->expr()->literal($storageId, IQueryBuilder::PARAM_INT))) |
165 | 165 | ->andWhere($query->expr()->eq('path_hash', $query->createParameter('hash'))) |
166 | 166 | ->andWhere($sizeQuery->expr()->gt('size', $sizeQuery->expr()->literal(-1, IQueryBuilder::PARAM_INT))); |
@@ -51,8 +51,8 @@ |
||
51 | 51 | } |
52 | 52 | if ($entry && $entry['mimetype'] === 'httpd/unix-directory') { |
53 | 53 | $id = $entry['fileid']; |
54 | - $sql = 'SELECT SUM(`size`) AS f1 ' . |
|
55 | - 'FROM `*PREFIX*filecache` ' . |
|
54 | + $sql = 'SELECT SUM(`size`) AS f1 '. |
|
55 | + 'FROM `*PREFIX*filecache` '. |
|
56 | 56 | 'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0'; |
57 | 57 | $result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId())); |
58 | 58 | if ($row = $result->fetchRow()) { |
@@ -67,7 +67,7 @@ |
||
67 | 67 | if ($sourceEntry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) { |
68 | 68 | $folderContent = $sourceCache->getFolderContentsById($sourceEntry->getId()); |
69 | 69 | foreach ($folderContent as $subEntry) { |
70 | - $subTargetPath = $targetPath . '/' . $subEntry->getName(); |
|
70 | + $subTargetPath = $targetPath.'/'.$subEntry->getName(); |
|
71 | 71 | $this->copyFromCache($sourceCache, $subEntry, $subTargetPath); |
72 | 72 | } |
73 | 73 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | } |
137 | 137 | $query = $this->connection->prepare('SELECT `lock` from `*PREFIX*file_locks` WHERE `key` = ?'); |
138 | 138 | $query->execute([$path]); |
139 | - $lockValue = (int)$query->fetchColumn(); |
|
139 | + $lockValue = (int) $query->fetchColumn(); |
|
140 | 140 | if ($type === self::LOCK_SHARED) { |
141 | 141 | if ($this->isLocallyLocked($path)) { |
142 | 142 | // if we have a shared lock we kept open locally but it's released we always have at least 1 shared lock in the db |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | // since we keep shared locks we need to manually clean those |
263 | 263 | $lockedPaths = array_keys($this->sharedLocks); |
264 | - $lockedPaths = array_filter($lockedPaths, function ($path) { |
|
264 | + $lockedPaths = array_filter($lockedPaths, function($path) { |
|
265 | 265 | return $this->sharedLocks[$path]; |
266 | 266 | }); |
267 | 267 |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * because the database connection was created with an uninitialized config |
88 | 88 | */ |
89 | 89 | private function fixDIInit() { |
90 | - if($this->connection === null) { |
|
90 | + if ($this->connection === null) { |
|
91 | 91 | $this->connection = \OC::$server->getDatabaseConnection(); |
92 | 92 | } |
93 | 93 | } |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | $prevValue = $this->getUserValue($userId, $appName, $key, null); |
219 | 219 | |
220 | 220 | if ($prevValue !== null) { |
221 | - if ($prevValue === (string)$value) { |
|
221 | + if ($prevValue === (string) $value) { |
|
222 | 222 | return; |
223 | - } else if ($preCondition !== null && $prevValue !== (string)$preCondition) { |
|
223 | + } else if ($preCondition !== null && $prevValue !== (string) $preCondition) { |
|
224 | 224 | throw new PreConditionNotMetException(); |
225 | 225 | } else { |
226 | 226 | $qb = $this->connection->getQueryBuilder(); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | // TODO - FIXME |
306 | 306 | $this->fixDIInit(); |
307 | 307 | |
308 | - $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
308 | + $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
309 | 309 | 'WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?'; |
310 | 310 | $this->connection->executeUpdate($sql, array($userId, $appName, $key)); |
311 | 311 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | // TODO - FIXME |
324 | 324 | $this->fixDIInit(); |
325 | 325 | |
326 | - $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
326 | + $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
327 | 327 | 'WHERE `userid` = ?'; |
328 | 328 | $this->connection->executeUpdate($sql, array($userId)); |
329 | 329 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | // TODO - FIXME |
340 | 340 | $this->fixDIInit(); |
341 | 341 | |
342 | - $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
342 | + $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
343 | 343 | 'WHERE `appid` = ?'; |
344 | 344 | $this->connection->executeUpdate($sql, array($appName)); |
345 | 345 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | return $this->userCache[$userId]; |
363 | 363 | } |
364 | 364 | if ($userId === null || $userId === '') { |
365 | - $this->userCache[$userId]=array(); |
|
365 | + $this->userCache[$userId] = array(); |
|
366 | 366 | return $this->userCache[$userId]; |
367 | 367 | } |
368 | 368 | |
@@ -409,12 +409,12 @@ discard block |
||
409 | 409 | array_unshift($queryParams, $key); |
410 | 410 | array_unshift($queryParams, $appName); |
411 | 411 | |
412 | - $placeholders = (sizeof($chunk) == 50) ? $placeholders50 : implode(',', array_fill(0, sizeof($chunk), '?')); |
|
412 | + $placeholders = (sizeof($chunk) == 50) ? $placeholders50 : implode(',', array_fill(0, sizeof($chunk), '?')); |
|
413 | 413 | |
414 | - $query = 'SELECT `userid`, `configvalue` ' . |
|
415 | - 'FROM `*PREFIX*preferences` ' . |
|
416 | - 'WHERE `appid` = ? AND `configkey` = ? ' . |
|
417 | - 'AND `userid` IN (' . $placeholders . ')'; |
|
414 | + $query = 'SELECT `userid`, `configvalue` '. |
|
415 | + 'FROM `*PREFIX*preferences` '. |
|
416 | + 'WHERE `appid` = ? AND `configkey` = ? '. |
|
417 | + 'AND `userid` IN ('.$placeholders.')'; |
|
418 | 418 | $result = $this->connection->executeQuery($query, $queryParams); |
419 | 419 | |
420 | 420 | while ($row = $result->fetch()) { |
@@ -437,10 +437,10 @@ discard block |
||
437 | 437 | // TODO - FIXME |
438 | 438 | $this->fixDIInit(); |
439 | 439 | |
440 | - $sql = 'SELECT `userid` FROM `*PREFIX*preferences` ' . |
|
440 | + $sql = 'SELECT `userid` FROM `*PREFIX*preferences` '. |
|
441 | 441 | 'WHERE `appid` = ? AND `configkey` = ? '; |
442 | 442 | |
443 | - if($this->getSystemValue('dbtype', 'sqlite') === 'oci') { |
|
443 | + if ($this->getSystemValue('dbtype', 'sqlite') === 'oci') { |
|
444 | 444 | //oracle hack: need to explicitly cast CLOB to CHAR for comparison |
445 | 445 | $sql .= 'AND to_char(`configvalue`) = ?'; |
446 | 446 | } else { |
@@ -51,19 +51,19 @@ |
||
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | // create audio result |
54 | - if($fileData['mimepart'] === 'audio'){ |
|
54 | + if ($fileData['mimepart'] === 'audio') { |
|
55 | 55 | $result = new \OC\Search\Result\Audio($fileData); |
56 | 56 | } |
57 | 57 | // create image result |
58 | - elseif($fileData['mimepart'] === 'image'){ |
|
58 | + elseif ($fileData['mimepart'] === 'image') { |
|
59 | 59 | $result = new \OC\Search\Result\Image($fileData); |
60 | 60 | } |
61 | 61 | // create folder result |
62 | - elseif($fileData['mimetype'] === 'httpd/unix-directory'){ |
|
62 | + elseif ($fileData['mimetype'] === 'httpd/unix-directory') { |
|
63 | 63 | $result = new \OC\Search\Result\Folder($fileData); |
64 | 64 | } |
65 | 65 | // or create file result |
66 | - else{ |
|
66 | + else { |
|
67 | 67 | $result = new \OC\Search\Result\File($fileData); |
68 | 68 | } |
69 | 69 | // add to results |