Passed
Push — master ( 6156a4...5d03b5 )
by Blizzz
14:08 queued 10s
created
lib/public/OCS/IDiscoveryService.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -35,18 +35,18 @@
 block discarded – undo
35 35
  */
36 36
 interface IDiscoveryService {
37 37
 
38
-	/**
39
-	 * Discover OCS end-points
40
-	 *
41
-	 * If no valid discovery data is found the defaults are returned
42
-	 *
43
-	 * @since 12.0.0
44
-	 *
45
-	 * @param string $remote
46
-	 * @param string $service the service you want to discover
47
-	 * @param bool $skipCache We won't check if the data is in the cache. This is useful if a background job is updating the status - Added in 14.0.0
48
-	 * @return array
49
-	 */
50
-	public function discover(string $remote, string $service, bool $skipCache = false): array;
38
+    /**
39
+     * Discover OCS end-points
40
+     *
41
+     * If no valid discovery data is found the defaults are returned
42
+     *
43
+     * @since 12.0.0
44
+     *
45
+     * @param string $remote
46
+     * @param string $service the service you want to discover
47
+     * @param bool $skipCache We won't check if the data is in the cache. This is useful if a background job is updating the status - Added in 14.0.0
48
+     * @return array
49
+     */
50
+    public function discover(string $remote, string $service, bool $skipCache = false): array;
51 51
 
52 52
 }
Please login to merge, or discard this patch.
lib/private/Lock/DBLockingProvider.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 		}
155 155
 		$query = $this->connection->prepare('SELECT `lock` from `*PREFIX*file_locks` WHERE `key` = ?');
156 156
 		$query->execute([$path]);
157
-		$lockValue = (int)$query->fetchColumn();
157
+		$lockValue = (int) $query->fetchColumn();
158 158
 		if ($type === self::LOCK_SHARED) {
159 159
 			if ($this->isLocallyLocked($path)) {
160 160
 				// 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
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 		}
292 292
 		// since we keep shared locks we need to manually clean those
293 293
 		$lockedPaths = array_keys($this->sharedLocks);
294
-		$lockedPaths = array_filter($lockedPaths, function ($path) {
294
+		$lockedPaths = array_filter($lockedPaths, function($path) {
295 295
 			return $this->sharedLocks[$path];
296 296
 		});
297 297
 
Please login to merge, or discard this patch.
Indentation   +249 added lines, -249 removed lines patch added patch discarded remove patch
@@ -41,275 +41,275 @@
 block discarded – undo
41 41
  * Locking provider that stores the locks in the database
42 42
  */
43 43
 class DBLockingProvider extends AbstractLockingProvider {
44
-	/**
45
-	 * @var \OCP\IDBConnection
46
-	 */
47
-	private $connection;
44
+    /**
45
+     * @var \OCP\IDBConnection
46
+     */
47
+    private $connection;
48 48
 
49
-	/**
50
-	 * @var \OCP\ILogger
51
-	 */
52
-	private $logger;
49
+    /**
50
+     * @var \OCP\ILogger
51
+     */
52
+    private $logger;
53 53
 
54
-	/**
55
-	 * @var \OCP\AppFramework\Utility\ITimeFactory
56
-	 */
57
-	private $timeFactory;
54
+    /**
55
+     * @var \OCP\AppFramework\Utility\ITimeFactory
56
+     */
57
+    private $timeFactory;
58 58
 
59
-	private $sharedLocks = [];
59
+    private $sharedLocks = [];
60 60
 
61
-	/**
62
-	 * @var bool
63
-	 */
64
-	private $cacheSharedLocks;
61
+    /**
62
+     * @var bool
63
+     */
64
+    private $cacheSharedLocks;
65 65
 
66
-	/**
67
-	 * Check if we have an open shared lock for a path
68
-	 *
69
-	 * @param string $path
70
-	 * @return bool
71
-	 */
72
-	protected function isLocallyLocked(string $path): bool {
73
-		return isset($this->sharedLocks[$path]) && $this->sharedLocks[$path];
74
-	}
66
+    /**
67
+     * Check if we have an open shared lock for a path
68
+     *
69
+     * @param string $path
70
+     * @return bool
71
+     */
72
+    protected function isLocallyLocked(string $path): bool {
73
+        return isset($this->sharedLocks[$path]) && $this->sharedLocks[$path];
74
+    }
75 75
 
76
-	/**
77
-	 * Mark a locally acquired lock
78
-	 *
79
-	 * @param string $path
80
-	 * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
81
-	 */
82
-	protected function markAcquire(string $path, int $type) {
83
-		parent::markAcquire($path, $type);
84
-		if ($this->cacheSharedLocks) {
85
-			if ($type === self::LOCK_SHARED) {
86
-				$this->sharedLocks[$path] = true;
87
-			}
88
-		}
89
-	}
76
+    /**
77
+     * Mark a locally acquired lock
78
+     *
79
+     * @param string $path
80
+     * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
81
+     */
82
+    protected function markAcquire(string $path, int $type) {
83
+        parent::markAcquire($path, $type);
84
+        if ($this->cacheSharedLocks) {
85
+            if ($type === self::LOCK_SHARED) {
86
+                $this->sharedLocks[$path] = true;
87
+            }
88
+        }
89
+    }
90 90
 
91
-	/**
92
-	 * Change the type of an existing tracked lock
93
-	 *
94
-	 * @param string $path
95
-	 * @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE
96
-	 */
97
-	protected function markChange(string $path, int $targetType) {
98
-		parent::markChange($path, $targetType);
99
-		if ($this->cacheSharedLocks) {
100
-			if ($targetType === self::LOCK_SHARED) {
101
-				$this->sharedLocks[$path] = true;
102
-			} elseif ($targetType === self::LOCK_EXCLUSIVE) {
103
-				$this->sharedLocks[$path] = false;
104
-			}
105
-		}
106
-	}
91
+    /**
92
+     * Change the type of an existing tracked lock
93
+     *
94
+     * @param string $path
95
+     * @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE
96
+     */
97
+    protected function markChange(string $path, int $targetType) {
98
+        parent::markChange($path, $targetType);
99
+        if ($this->cacheSharedLocks) {
100
+            if ($targetType === self::LOCK_SHARED) {
101
+                $this->sharedLocks[$path] = true;
102
+            } elseif ($targetType === self::LOCK_EXCLUSIVE) {
103
+                $this->sharedLocks[$path] = false;
104
+            }
105
+        }
106
+    }
107 107
 
108
-	/**
109
-	 * @param \OCP\IDBConnection $connection
110
-	 * @param \OCP\ILogger $logger
111
-	 * @param \OCP\AppFramework\Utility\ITimeFactory $timeFactory
112
-	 * @param int $ttl
113
-	 * @param bool $cacheSharedLocks
114
-	 */
115
-	public function __construct(
116
-		IDBConnection $connection,
117
-		ILogger $logger,
118
-		ITimeFactory $timeFactory,
119
-		int $ttl = 3600,
120
-		$cacheSharedLocks = true
121
-	) {
122
-		$this->connection = $connection;
123
-		$this->logger = $logger;
124
-		$this->timeFactory = $timeFactory;
125
-		$this->ttl = $ttl;
126
-		$this->cacheSharedLocks = $cacheSharedLocks;
127
-	}
108
+    /**
109
+     * @param \OCP\IDBConnection $connection
110
+     * @param \OCP\ILogger $logger
111
+     * @param \OCP\AppFramework\Utility\ITimeFactory $timeFactory
112
+     * @param int $ttl
113
+     * @param bool $cacheSharedLocks
114
+     */
115
+    public function __construct(
116
+        IDBConnection $connection,
117
+        ILogger $logger,
118
+        ITimeFactory $timeFactory,
119
+        int $ttl = 3600,
120
+        $cacheSharedLocks = true
121
+    ) {
122
+        $this->connection = $connection;
123
+        $this->logger = $logger;
124
+        $this->timeFactory = $timeFactory;
125
+        $this->ttl = $ttl;
126
+        $this->cacheSharedLocks = $cacheSharedLocks;
127
+    }
128 128
 
129
-	/**
130
-	 * Insert a file locking row if it does not exists.
131
-	 *
132
-	 * @param string $path
133
-	 * @param int $lock
134
-	 * @return int number of inserted rows
135
-	 */
136
-	protected function initLockField(string $path, int $lock = 0): int {
137
-		$expire = $this->getExpireTime();
138
-		return $this->connection->insertIgnoreConflict('file_locks', [
139
-			'key' => $path,
140
-			'lock' => $lock,
141
-			'ttl' => $expire
142
-		]);
143
-	}
129
+    /**
130
+     * Insert a file locking row if it does not exists.
131
+     *
132
+     * @param string $path
133
+     * @param int $lock
134
+     * @return int number of inserted rows
135
+     */
136
+    protected function initLockField(string $path, int $lock = 0): int {
137
+        $expire = $this->getExpireTime();
138
+        return $this->connection->insertIgnoreConflict('file_locks', [
139
+            'key' => $path,
140
+            'lock' => $lock,
141
+            'ttl' => $expire
142
+        ]);
143
+    }
144 144
 
145
-	/**
146
-	 * @return int
147
-	 */
148
-	protected function getExpireTime(): int {
149
-		return $this->timeFactory->getTime() + $this->ttl;
150
-	}
145
+    /**
146
+     * @return int
147
+     */
148
+    protected function getExpireTime(): int {
149
+        return $this->timeFactory->getTime() + $this->ttl;
150
+    }
151 151
 
152
-	/**
153
-	 * @param string $path
154
-	 * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
155
-	 * @return bool
156
-	 */
157
-	public function isLocked(string $path, int $type): bool {
158
-		if ($this->hasAcquiredLock($path, $type)) {
159
-			return true;
160
-		}
161
-		$query = $this->connection->prepare('SELECT `lock` from `*PREFIX*file_locks` WHERE `key` = ?');
162
-		$query->execute([$path]);
163
-		$lockValue = (int)$query->fetchColumn();
164
-		if ($type === self::LOCK_SHARED) {
165
-			if ($this->isLocallyLocked($path)) {
166
-				// 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
167
-				return $lockValue > 1;
168
-			} else {
169
-				return $lockValue > 0;
170
-			}
171
-		} elseif ($type === self::LOCK_EXCLUSIVE) {
172
-			return $lockValue === -1;
173
-		} else {
174
-			return false;
175
-		}
176
-	}
152
+    /**
153
+     * @param string $path
154
+     * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
155
+     * @return bool
156
+     */
157
+    public function isLocked(string $path, int $type): bool {
158
+        if ($this->hasAcquiredLock($path, $type)) {
159
+            return true;
160
+        }
161
+        $query = $this->connection->prepare('SELECT `lock` from `*PREFIX*file_locks` WHERE `key` = ?');
162
+        $query->execute([$path]);
163
+        $lockValue = (int)$query->fetchColumn();
164
+        if ($type === self::LOCK_SHARED) {
165
+            if ($this->isLocallyLocked($path)) {
166
+                // 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
167
+                return $lockValue > 1;
168
+            } else {
169
+                return $lockValue > 0;
170
+            }
171
+        } elseif ($type === self::LOCK_EXCLUSIVE) {
172
+            return $lockValue === -1;
173
+        } else {
174
+            return false;
175
+        }
176
+    }
177 177
 
178
-	/**
179
-	 * @param string $path
180
-	 * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
181
-	 * @throws \OCP\Lock\LockedException
182
-	 */
183
-	public function acquireLock(string $path, int $type, string $readablePath = null) {
184
-		$expire = $this->getExpireTime();
185
-		if ($type === self::LOCK_SHARED) {
186
-			if (!$this->isLocallyLocked($path)) {
187
-				$result = $this->initLockField($path, 1);
188
-				if ($result <= 0) {
189
-					$result = $this->connection->executeUpdate(
190
-						'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` + 1, `ttl` = ? WHERE `key` = ? AND `lock` >= 0',
191
-						[$expire, $path]
192
-					);
193
-				}
194
-			} else {
195
-				$result = 1;
196
-			}
197
-		} else {
198
-			$existing = 0;
199
-			if ($this->hasAcquiredLock($path, ILockingProvider::LOCK_SHARED) === false && $this->isLocallyLocked($path)) {
200
-				$existing = 1;
201
-			}
202
-			$result = $this->initLockField($path, -1);
203
-			if ($result <= 0) {
204
-				$result = $this->connection->executeUpdate(
205
-					'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = ?',
206
-					[$expire, $path, $existing]
207
-				);
208
-			}
209
-		}
210
-		if ($result !== 1) {
211
-			throw new LockedException($path, null, null, $readablePath);
212
-		}
213
-		$this->markAcquire($path, $type);
214
-	}
178
+    /**
179
+     * @param string $path
180
+     * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
181
+     * @throws \OCP\Lock\LockedException
182
+     */
183
+    public function acquireLock(string $path, int $type, string $readablePath = null) {
184
+        $expire = $this->getExpireTime();
185
+        if ($type === self::LOCK_SHARED) {
186
+            if (!$this->isLocallyLocked($path)) {
187
+                $result = $this->initLockField($path, 1);
188
+                if ($result <= 0) {
189
+                    $result = $this->connection->executeUpdate(
190
+                        'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` + 1, `ttl` = ? WHERE `key` = ? AND `lock` >= 0',
191
+                        [$expire, $path]
192
+                    );
193
+                }
194
+            } else {
195
+                $result = 1;
196
+            }
197
+        } else {
198
+            $existing = 0;
199
+            if ($this->hasAcquiredLock($path, ILockingProvider::LOCK_SHARED) === false && $this->isLocallyLocked($path)) {
200
+                $existing = 1;
201
+            }
202
+            $result = $this->initLockField($path, -1);
203
+            if ($result <= 0) {
204
+                $result = $this->connection->executeUpdate(
205
+                    'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = ?',
206
+                    [$expire, $path, $existing]
207
+                );
208
+            }
209
+        }
210
+        if ($result !== 1) {
211
+            throw new LockedException($path, null, null, $readablePath);
212
+        }
213
+        $this->markAcquire($path, $type);
214
+    }
215 215
 
216
-	/**
217
-	 * @param string $path
218
-	 * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
219
-	 */
220
-	public function releaseLock(string $path, int $type) {
221
-		$this->markRelease($path, $type);
216
+    /**
217
+     * @param string $path
218
+     * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
219
+     */
220
+    public function releaseLock(string $path, int $type) {
221
+        $this->markRelease($path, $type);
222 222
 
223
-		// we keep shared locks till the end of the request so we can re-use them
224
-		if ($type === self::LOCK_EXCLUSIVE) {
225
-			$this->connection->executeUpdate(
226
-				'UPDATE `*PREFIX*file_locks` SET `lock` = 0 WHERE `key` = ? AND `lock` = -1',
227
-				[$path]
228
-			);
229
-		} elseif (!$this->cacheSharedLocks) {
230
-			$query = $this->connection->getQueryBuilder();
231
-			$query->update('file_locks')
232
-				->set('lock', $query->func()->subtract('lock', $query->createNamedParameter(1)))
233
-				->where($query->expr()->eq('key', $query->createNamedParameter($path)))
234
-				->andWhere($query->expr()->gt('lock', $query->createNamedParameter(0)));
235
-			$query->execute();
236
-		}
237
-	}
223
+        // we keep shared locks till the end of the request so we can re-use them
224
+        if ($type === self::LOCK_EXCLUSIVE) {
225
+            $this->connection->executeUpdate(
226
+                'UPDATE `*PREFIX*file_locks` SET `lock` = 0 WHERE `key` = ? AND `lock` = -1',
227
+                [$path]
228
+            );
229
+        } elseif (!$this->cacheSharedLocks) {
230
+            $query = $this->connection->getQueryBuilder();
231
+            $query->update('file_locks')
232
+                ->set('lock', $query->func()->subtract('lock', $query->createNamedParameter(1)))
233
+                ->where($query->expr()->eq('key', $query->createNamedParameter($path)))
234
+                ->andWhere($query->expr()->gt('lock', $query->createNamedParameter(0)));
235
+            $query->execute();
236
+        }
237
+    }
238 238
 
239
-	/**
240
-	 * Change the type of an existing lock
241
-	 *
242
-	 * @param string $path
243
-	 * @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE
244
-	 * @throws \OCP\Lock\LockedException
245
-	 */
246
-	public function changeLock(string $path, int $targetType) {
247
-		$expire = $this->getExpireTime();
248
-		if ($targetType === self::LOCK_SHARED) {
249
-			$result = $this->connection->executeUpdate(
250
-				'UPDATE `*PREFIX*file_locks` SET `lock` = 1, `ttl` = ? WHERE `key` = ? AND `lock` = -1',
251
-				[$expire, $path]
252
-			);
253
-		} else {
254
-			// since we only keep one shared lock in the db we need to check if we have more then one shared lock locally manually
255
-			if (isset($this->acquiredLocks['shared'][$path]) && $this->acquiredLocks['shared'][$path] > 1) {
256
-				throw new LockedException($path);
257
-			}
258
-			$result = $this->connection->executeUpdate(
259
-				'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = 1',
260
-				[$expire, $path]
261
-			);
262
-		}
263
-		if ($result !== 1) {
264
-			throw new LockedException($path);
265
-		}
266
-		$this->markChange($path, $targetType);
267
-	}
239
+    /**
240
+     * Change the type of an existing lock
241
+     *
242
+     * @param string $path
243
+     * @param int $targetType self::LOCK_SHARED or self::LOCK_EXCLUSIVE
244
+     * @throws \OCP\Lock\LockedException
245
+     */
246
+    public function changeLock(string $path, int $targetType) {
247
+        $expire = $this->getExpireTime();
248
+        if ($targetType === self::LOCK_SHARED) {
249
+            $result = $this->connection->executeUpdate(
250
+                'UPDATE `*PREFIX*file_locks` SET `lock` = 1, `ttl` = ? WHERE `key` = ? AND `lock` = -1',
251
+                [$expire, $path]
252
+            );
253
+        } else {
254
+            // since we only keep one shared lock in the db we need to check if we have more then one shared lock locally manually
255
+            if (isset($this->acquiredLocks['shared'][$path]) && $this->acquiredLocks['shared'][$path] > 1) {
256
+                throw new LockedException($path);
257
+            }
258
+            $result = $this->connection->executeUpdate(
259
+                'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = 1',
260
+                [$expire, $path]
261
+            );
262
+        }
263
+        if ($result !== 1) {
264
+            throw new LockedException($path);
265
+        }
266
+        $this->markChange($path, $targetType);
267
+    }
268 268
 
269
-	/**
270
-	 * cleanup empty locks
271
-	 */
272
-	public function cleanExpiredLocks() {
273
-		$expire = $this->timeFactory->getTime();
274
-		try {
275
-			$this->connection->executeUpdate(
276
-				'DELETE FROM `*PREFIX*file_locks` WHERE `ttl` < ?',
277
-				[$expire]
278
-			);
279
-		} catch (\Exception $e) {
280
-			// If the table is missing, the clean up was successful
281
-			if ($this->connection->tableExists('file_locks')) {
282
-				throw $e;
283
-			}
284
-		}
285
-	}
269
+    /**
270
+     * cleanup empty locks
271
+     */
272
+    public function cleanExpiredLocks() {
273
+        $expire = $this->timeFactory->getTime();
274
+        try {
275
+            $this->connection->executeUpdate(
276
+                'DELETE FROM `*PREFIX*file_locks` WHERE `ttl` < ?',
277
+                [$expire]
278
+            );
279
+        } catch (\Exception $e) {
280
+            // If the table is missing, the clean up was successful
281
+            if ($this->connection->tableExists('file_locks')) {
282
+                throw $e;
283
+            }
284
+        }
285
+    }
286 286
 
287
-	/**
288
-	 * release all lock acquired by this instance which were marked using the mark* methods
289
-	 */
290
-	public function releaseAll() {
291
-		parent::releaseAll();
287
+    /**
288
+     * release all lock acquired by this instance which were marked using the mark* methods
289
+     */
290
+    public function releaseAll() {
291
+        parent::releaseAll();
292 292
 
293
-		if (!$this->cacheSharedLocks) {
294
-			return;
295
-		}
296
-		// since we keep shared locks we need to manually clean those
297
-		$lockedPaths = array_keys($this->sharedLocks);
298
-		$lockedPaths = array_filter($lockedPaths, function ($path) {
299
-			return $this->sharedLocks[$path];
300
-		});
293
+        if (!$this->cacheSharedLocks) {
294
+            return;
295
+        }
296
+        // since we keep shared locks we need to manually clean those
297
+        $lockedPaths = array_keys($this->sharedLocks);
298
+        $lockedPaths = array_filter($lockedPaths, function ($path) {
299
+            return $this->sharedLocks[$path];
300
+        });
301 301
 
302
-		$chunkedPaths = array_chunk($lockedPaths, 100);
302
+        $chunkedPaths = array_chunk($lockedPaths, 100);
303 303
 
304
-		foreach ($chunkedPaths as $chunk) {
305
-			$builder = $this->connection->getQueryBuilder();
304
+        foreach ($chunkedPaths as $chunk) {
305
+            $builder = $this->connection->getQueryBuilder();
306 306
 
307
-			$query = $builder->update('file_locks')
308
-				->set('lock', $builder->func()->subtract('lock', $builder->expr()->literal(1)))
309
-				->where($builder->expr()->in('key', $builder->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY)))
310
-				->andWhere($builder->expr()->gt('lock', new Literal(0)));
307
+            $query = $builder->update('file_locks')
308
+                ->set('lock', $builder->func()->subtract('lock', $builder->expr()->literal(1)))
309
+                ->where($builder->expr()->in('key', $builder->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY)))
310
+                ->andWhere($builder->expr()->gt('lock', new Literal(0)));
311 311
 
312
-			$query->execute();
313
-		}
314
-	}
312
+            $query->execute();
313
+        }
314
+    }
315 315
 }
Please login to merge, or discard this patch.
core/Migrations/Version14000Date20180129121024.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -30,30 +30,30 @@
 block discarded – undo
30 30
  * Delete the admin|personal sections and settings tables
31 31
  */
32 32
 class Version14000Date20180129121024 extends SimpleMigrationStep {
33
-	public function name(): string {
34
-		return 'Drop obsolete settings tables';
35
-	}
33
+    public function name(): string {
34
+        return 'Drop obsolete settings tables';
35
+    }
36 36
 
37
-	public function description(): string {
38
-		return 'Drops the following obsolete tables: "admin_sections", "admin_settings", "personal_sections" and "personal_settings"';
39
-	}
37
+    public function description(): string {
38
+        return 'Drops the following obsolete tables: "admin_sections", "admin_settings", "personal_sections" and "personal_settings"';
39
+    }
40 40
 
41
-	/**
42
-	 * @param IOutput $output
43
-	 * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
44
-	 * @param array $options
45
-	 * @return null|ISchemaWrapper
46
-	 * @since 13.0.0
47
-	 */
48
-	public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
49
-		/** @var ISchemaWrapper $schema */
50
-		$schema = $schemaClosure();
41
+    /**
42
+     * @param IOutput $output
43
+     * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
44
+     * @param array $options
45
+     * @return null|ISchemaWrapper
46
+     * @since 13.0.0
47
+     */
48
+    public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
49
+        /** @var ISchemaWrapper $schema */
50
+        $schema = $schemaClosure();
51 51
 
52
-		$schema->dropTable('admin_sections');
53
-		$schema->dropTable('admin_settings');
54
-		$schema->dropTable('personal_sections');
55
-		$schema->dropTable('personal_settings');
52
+        $schema->dropTable('admin_sections');
53
+        $schema->dropTable('admin_settings');
54
+        $schema->dropTable('personal_sections');
55
+        $schema->dropTable('personal_settings');
56 56
 
57
-		return $schema;
58
-	}
57
+        return $schema;
58
+    }
59 59
 }
Please login to merge, or discard this patch.
apps/dav/lib/Direct/Server.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@
 block discarded – undo
25 25
 namespace OCA\DAV\Direct;
26 26
 
27 27
 class Server extends \Sabre\DAV\Server {
28
-	public function __construct($treeOrNode = null) {
29
-		parent::__construct($treeOrNode);
30
-		self::$exposeVersion = false;
31
-		$this->enablePropfindDepthInfinityf = false;
32
-	}
28
+    public function __construct($treeOrNode = null) {
29
+        parent::__construct($treeOrNode);
30
+        self::$exposeVersion = false;
31
+        $this->enablePropfindDepthInfinityf = false;
32
+    }
33 33
 }
Please login to merge, or discard this patch.
apps/dav/lib/Db/Direct.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -37,22 +37,22 @@
 block discarded – undo
37 37
  * @method void setExpiration(int $expiration)
38 38
  */
39 39
 class Direct extends Entity {
40
-	/** @var string */
41
-	protected $userId;
40
+    /** @var string */
41
+    protected $userId;
42 42
 
43
-	/** @var int */
44
-	protected $fileId;
43
+    /** @var int */
44
+    protected $fileId;
45 45
 
46
-	/** @var string */
47
-	protected $token;
46
+    /** @var string */
47
+    protected $token;
48 48
 
49
-	/** @var int */
50
-	protected $expiration;
49
+    /** @var int */
50
+    protected $expiration;
51 51
 
52
-	public function __construct() {
53
-		$this->addType('userId', 'string');
54
-		$this->addType('fileId', 'int');
55
-		$this->addType('token', 'string');
56
-		$this->addType('expiration', 'int');
57
-	}
52
+    public function __construct() {
53
+        $this->addType('userId', 'string');
54
+        $this->addType('fileId', 'int');
55
+        $this->addType('token', 'string');
56
+        $this->addType('expiration', 'int');
57
+    }
58 58
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Service/LegacyStoragesService.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	) {
59 59
 		$backend = $this->backendService->getBackend($storageOptions['backend']);
60 60
 		if (!$backend) {
61
-			throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']);
61
+			throw new \UnexpectedValueException('Invalid backend '.$storageOptions['backend']);
62 62
 		}
63 63
 		$storageConfig->setBackend($backend);
64 64
 		if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			$storageOptions['authMechanism'] = 'null'; // to make error handling easier
69 69
 		}
70 70
 		if (!$authMechanism) {
71
-			throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']);
71
+			throw new \UnexpectedValueException('Invalid authentication mechanism '.$storageOptions['authMechanism']);
72 72
 		}
73 73
 		$storageConfig->setAuthMechanism($authMechanism);
74 74
 		$storageConfig->setBackendOptions($storageOptions['options']);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 					$parts = explode('/', ltrim($rootMountPath, '/'), 3);
141 141
 					if (count($parts) < 3) {
142 142
 						// something went wrong, skip
143
-						\OC::$server->getLogger()->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']);
143
+						\OC::$server->getLogger()->error('Could not parse mount point "'.$rootMountPath.'"', ['app' => 'files_external']);
144 144
 						continue;
145 145
 					}
146 146
 					$relativeMountPath = rtrim($parts[2], '/');
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 						$storageOptions['authMechanism'] = null; // ensure config hash works
155 155
 					}
156 156
 					if (isset($storageOptions['id'])) {
157
-						$configId = (int)$storageOptions['id'];
157
+						$configId = (int) $storageOptions['id'];
158 158
 						if (isset($storages[$configId])) {
159 159
 							$currentStorage = $storages[$configId];
160 160
 						}
Please login to merge, or discard this patch.
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -34,179 +34,179 @@
 block discarded – undo
34 34
  * Read mount config from legacy mount.json
35 35
  */
36 36
 abstract class LegacyStoragesService {
37
-	/** @var BackendService */
38
-	protected $backendService;
37
+    /** @var BackendService */
38
+    protected $backendService;
39 39
 
40
-	/**
41
-	 * Read legacy config data
42
-	 *
43
-	 * @return array list of mount configs
44
-	 */
45
-	abstract protected function readLegacyConfig();
40
+    /**
41
+     * Read legacy config data
42
+     *
43
+     * @return array list of mount configs
44
+     */
45
+    abstract protected function readLegacyConfig();
46 46
 
47
-	/**
48
-	 * Copy legacy storage options into the given storage config object.
49
-	 *
50
-	 * @param StorageConfig $storageConfig storage config to populate
51
-	 * @param string $mountType mount type
52
-	 * @param string $applicable applicable user or group
53
-	 * @param array $storageOptions legacy storage options
54
-	 *
55
-	 * @return StorageConfig populated storage config
56
-	 */
57
-	protected function populateStorageConfigWithLegacyOptions(
58
-		&$storageConfig,
59
-		$mountType,
60
-		$applicable,
61
-		$storageOptions
62
-	) {
63
-		$backend = $this->backendService->getBackend($storageOptions['backend']);
64
-		if (!$backend) {
65
-			throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']);
66
-		}
67
-		$storageConfig->setBackend($backend);
68
-		if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') {
69
-			$authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']);
70
-		} else {
71
-			$authMechanism = $backend->getLegacyAuthMechanism($storageOptions);
72
-			$storageOptions['authMechanism'] = 'null'; // to make error handling easier
73
-		}
74
-		if (!$authMechanism) {
75
-			throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']);
76
-		}
77
-		$storageConfig->setAuthMechanism($authMechanism);
78
-		$storageConfig->setBackendOptions($storageOptions['options']);
79
-		if (isset($storageOptions['mountOptions'])) {
80
-			$storageConfig->setMountOptions($storageOptions['mountOptions']);
81
-		}
82
-		if (!isset($storageOptions['priority'])) {
83
-			$storageOptions['priority'] = $backend->getPriority();
84
-		}
85
-		$storageConfig->setPriority($storageOptions['priority']);
86
-		if ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_USER) {
87
-			$applicableUsers = $storageConfig->getApplicableUsers();
88
-			if ($applicable !== 'all') {
89
-				$applicableUsers[] = $applicable;
90
-				$storageConfig->setApplicableUsers($applicableUsers);
91
-			}
92
-		} elseif ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP) {
93
-			$applicableGroups = $storageConfig->getApplicableGroups();
94
-			$applicableGroups[] = $applicable;
95
-			$storageConfig->setApplicableGroups($applicableGroups);
96
-		}
97
-		return $storageConfig;
98
-	}
47
+    /**
48
+     * Copy legacy storage options into the given storage config object.
49
+     *
50
+     * @param StorageConfig $storageConfig storage config to populate
51
+     * @param string $mountType mount type
52
+     * @param string $applicable applicable user or group
53
+     * @param array $storageOptions legacy storage options
54
+     *
55
+     * @return StorageConfig populated storage config
56
+     */
57
+    protected function populateStorageConfigWithLegacyOptions(
58
+        &$storageConfig,
59
+        $mountType,
60
+        $applicable,
61
+        $storageOptions
62
+    ) {
63
+        $backend = $this->backendService->getBackend($storageOptions['backend']);
64
+        if (!$backend) {
65
+            throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']);
66
+        }
67
+        $storageConfig->setBackend($backend);
68
+        if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') {
69
+            $authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']);
70
+        } else {
71
+            $authMechanism = $backend->getLegacyAuthMechanism($storageOptions);
72
+            $storageOptions['authMechanism'] = 'null'; // to make error handling easier
73
+        }
74
+        if (!$authMechanism) {
75
+            throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']);
76
+        }
77
+        $storageConfig->setAuthMechanism($authMechanism);
78
+        $storageConfig->setBackendOptions($storageOptions['options']);
79
+        if (isset($storageOptions['mountOptions'])) {
80
+            $storageConfig->setMountOptions($storageOptions['mountOptions']);
81
+        }
82
+        if (!isset($storageOptions['priority'])) {
83
+            $storageOptions['priority'] = $backend->getPriority();
84
+        }
85
+        $storageConfig->setPriority($storageOptions['priority']);
86
+        if ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_USER) {
87
+            $applicableUsers = $storageConfig->getApplicableUsers();
88
+            if ($applicable !== 'all') {
89
+                $applicableUsers[] = $applicable;
90
+                $storageConfig->setApplicableUsers($applicableUsers);
91
+            }
92
+        } elseif ($mountType === \OCA\Files_External\MountConfig::MOUNT_TYPE_GROUP) {
93
+            $applicableGroups = $storageConfig->getApplicableGroups();
94
+            $applicableGroups[] = $applicable;
95
+            $storageConfig->setApplicableGroups($applicableGroups);
96
+        }
97
+        return $storageConfig;
98
+    }
99 99
 
100
-	/**
101
-	 * Read the external storages config
102
-	 *
103
-	 * @return StorageConfig[] map of storage id to storage config
104
-	 */
105
-	public function getAllStorages() {
106
-		$mountPoints = $this->readLegacyConfig();
107
-		/**
108
-		 * Here is the how the horribly messy mount point array looks like
109
-		 * from the mount.json file:
110
-		 *
111
-		 * $storageOptions = $mountPoints[$mountType][$applicable][$mountPath]
112
-		 *
113
-		 * - $mountType is either "user" or "group"
114
-		 * - $applicable is the name of a user or group (or the current user for personal mounts)
115
-		 * - $mountPath is the mount point path (where the storage must be mounted)
116
-		 * - $storageOptions is a map of storage options:
117
-		 *     - "priority": storage priority
118
-		 *     - "backend": backend identifier
119
-		 *     - "class": LEGACY backend class name
120
-		 *     - "options": backend-specific options
121
-		 *     - "authMechanism": authentication mechanism identifier
122
-		 *     - "mountOptions": mount-specific options (ex: disable previews, scanner, etc)
123
-		 */
124
-		// group by storage id
125
-		/** @var StorageConfig[] $storages */
126
-		$storages = [];
127
-		// for storages without id (legacy), group by config hash for
128
-		// later processing
129
-		$storagesWithConfigHash = [];
130
-		foreach ($mountPoints as $mountType => $applicables) {
131
-			foreach ($applicables as $applicable => $mountPaths) {
132
-				foreach ($mountPaths as $rootMountPath => $storageOptions) {
133
-					$currentStorage = null;
134
-					/**
135
-					 * Flag whether the config that was read already has an id.
136
-					 * If not, it will use a config hash instead and generate
137
-					 * a proper id later
138
-					 *
139
-					 * @var boolean
140
-					 */
141
-					$hasId = false;
142
-					// the root mount point is in the format "/$user/files/the/mount/point"
143
-					// we remove the "/$user/files" prefix
144
-					$parts = explode('/', ltrim($rootMountPath, '/'), 3);
145
-					if (count($parts) < 3) {
146
-						// something went wrong, skip
147
-						\OC::$server->getLogger()->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']);
148
-						continue;
149
-					}
150
-					$relativeMountPath = rtrim($parts[2], '/');
151
-					// note: we cannot do this after the loop because the decrypted config
152
-					// options might be needed for the config hash
153
-					$storageOptions['options'] = \OCA\Files_External\MountConfig::decryptPasswords($storageOptions['options']);
154
-					if (!isset($storageOptions['backend'])) {
155
-						$storageOptions['backend'] = $storageOptions['class']; // legacy compat
156
-					}
157
-					if (!isset($storageOptions['authMechanism'])) {
158
-						$storageOptions['authMechanism'] = null; // ensure config hash works
159
-					}
160
-					if (isset($storageOptions['id'])) {
161
-						$configId = (int)$storageOptions['id'];
162
-						if (isset($storages[$configId])) {
163
-							$currentStorage = $storages[$configId];
164
-						}
165
-						$hasId = true;
166
-					} else {
167
-						// missing id in legacy config, need to generate
168
-						// but at this point we don't know the max-id, so use
169
-						// first group it by config hash
170
-						$storageOptions['mountpoint'] = $rootMountPath;
171
-						$configId = \OCA\Files_External\MountConfig::makeConfigHash($storageOptions);
172
-						if (isset($storagesWithConfigHash[$configId])) {
173
-							$currentStorage = $storagesWithConfigHash[$configId];
174
-						}
175
-					}
176
-					if (is_null($currentStorage)) {
177
-						// create new
178
-						$currentStorage = new StorageConfig($configId);
179
-						$currentStorage->setMountPoint($relativeMountPath);
180
-					}
181
-					try {
182
-						$this->populateStorageConfigWithLegacyOptions(
183
-							$currentStorage,
184
-							$mountType,
185
-							$applicable,
186
-							$storageOptions
187
-						);
188
-						if ($hasId) {
189
-							$storages[$configId] = $currentStorage;
190
-						} else {
191
-							$storagesWithConfigHash[$configId] = $currentStorage;
192
-						}
193
-					} catch (\UnexpectedValueException $e) {
194
-						// don't die if a storage backend doesn't exist
195
-						\OC::$server->getLogger()->logException($e, [
196
-							'message' => 'Could not load storage.',
197
-							'level' => ILogger::ERROR,
198
-							'app' => 'files_external',
199
-						]);
200
-					}
201
-				}
202
-			}
203
-		}
100
+    /**
101
+     * Read the external storages config
102
+     *
103
+     * @return StorageConfig[] map of storage id to storage config
104
+     */
105
+    public function getAllStorages() {
106
+        $mountPoints = $this->readLegacyConfig();
107
+        /**
108
+         * Here is the how the horribly messy mount point array looks like
109
+         * from the mount.json file:
110
+         *
111
+         * $storageOptions = $mountPoints[$mountType][$applicable][$mountPath]
112
+         *
113
+         * - $mountType is either "user" or "group"
114
+         * - $applicable is the name of a user or group (or the current user for personal mounts)
115
+         * - $mountPath is the mount point path (where the storage must be mounted)
116
+         * - $storageOptions is a map of storage options:
117
+         *     - "priority": storage priority
118
+         *     - "backend": backend identifier
119
+         *     - "class": LEGACY backend class name
120
+         *     - "options": backend-specific options
121
+         *     - "authMechanism": authentication mechanism identifier
122
+         *     - "mountOptions": mount-specific options (ex: disable previews, scanner, etc)
123
+         */
124
+        // group by storage id
125
+        /** @var StorageConfig[] $storages */
126
+        $storages = [];
127
+        // for storages without id (legacy), group by config hash for
128
+        // later processing
129
+        $storagesWithConfigHash = [];
130
+        foreach ($mountPoints as $mountType => $applicables) {
131
+            foreach ($applicables as $applicable => $mountPaths) {
132
+                foreach ($mountPaths as $rootMountPath => $storageOptions) {
133
+                    $currentStorage = null;
134
+                    /**
135
+                     * Flag whether the config that was read already has an id.
136
+                     * If not, it will use a config hash instead and generate
137
+                     * a proper id later
138
+                     *
139
+                     * @var boolean
140
+                     */
141
+                    $hasId = false;
142
+                    // the root mount point is in the format "/$user/files/the/mount/point"
143
+                    // we remove the "/$user/files" prefix
144
+                    $parts = explode('/', ltrim($rootMountPath, '/'), 3);
145
+                    if (count($parts) < 3) {
146
+                        // something went wrong, skip
147
+                        \OC::$server->getLogger()->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']);
148
+                        continue;
149
+                    }
150
+                    $relativeMountPath = rtrim($parts[2], '/');
151
+                    // note: we cannot do this after the loop because the decrypted config
152
+                    // options might be needed for the config hash
153
+                    $storageOptions['options'] = \OCA\Files_External\MountConfig::decryptPasswords($storageOptions['options']);
154
+                    if (!isset($storageOptions['backend'])) {
155
+                        $storageOptions['backend'] = $storageOptions['class']; // legacy compat
156
+                    }
157
+                    if (!isset($storageOptions['authMechanism'])) {
158
+                        $storageOptions['authMechanism'] = null; // ensure config hash works
159
+                    }
160
+                    if (isset($storageOptions['id'])) {
161
+                        $configId = (int)$storageOptions['id'];
162
+                        if (isset($storages[$configId])) {
163
+                            $currentStorage = $storages[$configId];
164
+                        }
165
+                        $hasId = true;
166
+                    } else {
167
+                        // missing id in legacy config, need to generate
168
+                        // but at this point we don't know the max-id, so use
169
+                        // first group it by config hash
170
+                        $storageOptions['mountpoint'] = $rootMountPath;
171
+                        $configId = \OCA\Files_External\MountConfig::makeConfigHash($storageOptions);
172
+                        if (isset($storagesWithConfigHash[$configId])) {
173
+                            $currentStorage = $storagesWithConfigHash[$configId];
174
+                        }
175
+                    }
176
+                    if (is_null($currentStorage)) {
177
+                        // create new
178
+                        $currentStorage = new StorageConfig($configId);
179
+                        $currentStorage->setMountPoint($relativeMountPath);
180
+                    }
181
+                    try {
182
+                        $this->populateStorageConfigWithLegacyOptions(
183
+                            $currentStorage,
184
+                            $mountType,
185
+                            $applicable,
186
+                            $storageOptions
187
+                        );
188
+                        if ($hasId) {
189
+                            $storages[$configId] = $currentStorage;
190
+                        } else {
191
+                            $storagesWithConfigHash[$configId] = $currentStorage;
192
+                        }
193
+                    } catch (\UnexpectedValueException $e) {
194
+                        // don't die if a storage backend doesn't exist
195
+                        \OC::$server->getLogger()->logException($e, [
196
+                            'message' => 'Could not load storage.',
197
+                            'level' => ILogger::ERROR,
198
+                            'app' => 'files_external',
199
+                        ]);
200
+                    }
201
+                }
202
+            }
203
+        }
204 204
 
205
-		// convert parameter values
206
-		foreach ($storages as $storage) {
207
-			$storage->getBackend()->validateStorageDefinition($storage);
208
-			$storage->getAuthMechanism()->validateStorageDefinition($storage);
209
-		}
210
-		return $storages;
211
-	}
205
+        // convert parameter values
206
+        foreach ($storages as $storage) {
207
+            $storage->getBackend()->validateStorageDefinition($storage);
208
+            $storage->getAuthMechanism()->validateStorageDefinition($storage);
209
+        }
210
+        return $storages;
211
+    }
212 212
 }
Please login to merge, or discard this patch.
lib/public/Group/Backend/IGroupDetailsBackend.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@
 block discarded – undo
29 29
  */
30 30
 interface IGroupDetailsBackend {
31 31
 
32
-	/**
33
-	 * @since 14.0.0
34
-	 */
35
-	public function getGroupDetails(string $gid): array;
32
+    /**
33
+     * @since 14.0.0
34
+     */
35
+    public function getGroupDetails(string $gid): array;
36 36
 }
Please login to merge, or discard this patch.
lib/public/Group/Backend/IIsAdminBackend.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@
 block discarded – undo
29 29
  */
30 30
 interface IIsAdminBackend {
31 31
 
32
-	/**
33
-	 * @since 14.0.0
34
-	 */
35
-	public function isAdmin(string $uid): bool;
32
+    /**
33
+     * @since 14.0.0
34
+     */
35
+    public function isAdmin(string $uid): bool;
36 36
 }
Please login to merge, or discard this patch.
lib/public/Group/Backend/ICreateGroupBackend.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@
 block discarded – undo
29 29
  */
30 30
 interface ICreateGroupBackend {
31 31
 
32
-	/**
33
-	 * @since 14.0.0
34
-	 */
35
-	public function createGroup(string $gid): bool;
32
+    /**
33
+     * @since 14.0.0
34
+     */
35
+    public function createGroup(string $gid): bool;
36 36
 }
Please login to merge, or discard this patch.