Completed
Pull Request — master (#10075)
by
unknown
27:10
created
lib/private/Files/FileInfo.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param \OCP\Files\Mount\IMountPoint $mount
88 88
 	 * @param \OCP\IUser|null $owner
89 89
 	 */
90
-	public function __construct($path, $storage, $internalPath, $data, $mount, $owner= null) {
90
+	public function __construct($path, $storage, $internalPath, $data, $mount, $owner = null) {
91 91
 		$this->path = $path;
92 92
 		$this->storage = $storage;
93 93
 		$this->internalPath = $internalPath;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @return int|null
154 154
 	 */
155 155
 	public function getId() {
156
-		return isset($this->data['fileid']) ? (int)  $this->data['fileid'] : null;
156
+		return isset($this->data['fileid']) ? (int) $this->data['fileid'] : null;
157 157
 	}
158 158
 
159 159
 	/**
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	public function getEtag() {
184 184
 		$this->updateEntryfromSubMounts();
185 185
 		if (count($this->childEtags) > 0) {
186
-			$combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags);
186
+			$combinedEtag = $this->data['etag'].'::'.implode('::', $this->childEtags);
187 187
 			return md5($combinedEtag);
188 188
 		} else {
189 189
 			return $this->data['etag'];
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 			$relativeEntryPath = substr($entryPath, strlen($this->getPath()));
380 380
 			// attach the permissions to propagate etag on permision changes of submounts
381 381
 			$permissions = isset($data['permissions']) ? $data['permissions'] : 0;
382
-			$this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions;
382
+			$this->childEtags[] = $relativeEntryPath.'/'.$data['etag'].$permissions;
383 383
 		}
384 384
 	}
385 385
 
Please login to merge, or discard this patch.
Indentation   +352 added lines, -352 removed lines patch added patch discarded remove patch
@@ -35,356 +35,356 @@
 block discarded – undo
35 35
 use OCP\IUser;
36 36
 
37 37
 class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
38
-	/**
39
-	 * @var array $data
40
-	 */
41
-	private $data;
42
-
43
-	/**
44
-	 * @var string $path
45
-	 */
46
-	private $path;
47
-
48
-	/**
49
-	 * @var \OC\Files\Storage\Storage $storage
50
-	 */
51
-	private $storage;
52
-
53
-	/**
54
-	 * @var string $internalPath
55
-	 */
56
-	private $internalPath;
57
-
58
-	/**
59
-	 * @var \OCP\Files\Mount\IMountPoint
60
-	 */
61
-	private $mount;
62
-
63
-	/**
64
-	 * @var IUser
65
-	 */
66
-	private $owner;
67
-
68
-	/**
69
-	 * @var string[]
70
-	 */
71
-	private $childEtags = [];
72
-
73
-	/**
74
-	 * @var IMountPoint[]
75
-	 */
76
-	private $subMounts = [];
77
-
78
-	private $subMountsUsed = false;
79
-
80
-	/**
81
-	 * @param string|boolean $path
82
-	 * @param Storage\Storage $storage
83
-	 * @param string $internalPath
84
-	 * @param array|ICacheEntry $data
85
-	 * @param \OCP\Files\Mount\IMountPoint $mount
86
-	 * @param \OCP\IUser|null $owner
87
-	 */
88
-	public function __construct($path, $storage, $internalPath, $data, $mount, $owner= null) {
89
-		$this->path = $path;
90
-		$this->storage = $storage;
91
-		$this->internalPath = $internalPath;
92
-		$this->data = $data;
93
-		$this->mount = $mount;
94
-		$this->owner = $owner;
95
-	}
96
-
97
-	public function offsetSet($offset, $value) {
98
-		$this->data[$offset] = $value;
99
-	}
100
-
101
-	public function offsetExists($offset) {
102
-		return isset($this->data[$offset]);
103
-	}
104
-
105
-	public function offsetUnset($offset) {
106
-		unset($this->data[$offset]);
107
-	}
108
-
109
-	public function offsetGet($offset) {
110
-		if ($offset === 'type') {
111
-			return $this->getType();
112
-		} else if ($offset === 'etag') {
113
-			return $this->getEtag();
114
-		} else if ($offset === 'size') {
115
-			return $this->getSize();
116
-		} else if ($offset === 'mtime') {
117
-			return $this->getMTime();
118
-		} elseif ($offset === 'permissions') {
119
-			return $this->getPermissions();
120
-		} elseif (isset($this->data[$offset])) {
121
-			return $this->data[$offset];
122
-		} else {
123
-			return null;
124
-		}
125
-	}
126
-
127
-	/**
128
-	 * @return string
129
-	 */
130
-	public function getPath() {
131
-		return $this->path;
132
-	}
133
-
134
-	/**
135
-	 * @return \OCP\Files\Storage
136
-	 */
137
-	public function getStorage() {
138
-		return $this->storage;
139
-	}
140
-
141
-	/**
142
-	 * @return string
143
-	 */
144
-	public function getInternalPath() {
145
-		return $this->internalPath;
146
-	}
147
-
148
-	/**
149
-	 * Get FileInfo ID or null in case of part file
150
-	 *
151
-	 * @return int|null
152
-	 */
153
-	public function getId() {
154
-		return isset($this->data['fileid']) ? (int)  $this->data['fileid'] : null;
155
-	}
156
-
157
-	/**
158
-	 * @return string
159
-	 */
160
-	public function getMimetype() {
161
-		return $this->data['mimetype'];
162
-	}
163
-
164
-	/**
165
-	 * @return string
166
-	 */
167
-	public function getMimePart() {
168
-		return $this->data['mimepart'];
169
-	}
170
-
171
-	/**
172
-	 * @return string
173
-	 */
174
-	public function getName() {
175
-		return basename($this->getPath());
176
-	}
177
-
178
-	/**
179
-	 * @return string
180
-	 */
181
-	public function getEtag() {
182
-		$this->updateEntryfromSubMounts();
183
-		if (count($this->childEtags) > 0) {
184
-			$combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags);
185
-			return md5($combinedEtag);
186
-		} else {
187
-			return $this->data['etag'];
188
-		}
189
-	}
190
-
191
-	/**
192
-	 * @return int
193
-	 */
194
-	public function getSize() {
195
-		$this->updateEntryfromSubMounts();
196
-		return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
197
-	}
198
-
199
-	/**
200
-	 * @return int
201
-	 */
202
-	public function getMTime() {
203
-		$this->updateEntryfromSubMounts();
204
-		return (int) $this->data['mtime'];
205
-	}
206
-
207
-	/**
208
-	 * @return bool
209
-	 */
210
-	public function isEncrypted() {
211
-		return $this->data['encrypted'];
212
-	}
213
-
214
-	/**
215
-	 * Return the currently version used for the HMAC in the encryption app
216
-	 *
217
-	 * @return int
218
-	 */
219
-	public function getEncryptedVersion() {
220
-		return isset($this->data['encryptedVersion']) ? (int) $this->data['encryptedVersion'] : 1;
221
-	}
222
-
223
-	/**
224
-	 * @return int
225
-	 */
226
-	public function getPermissions() {
227
-		$perms = (int) $this->data['permissions'];
228
-		if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) {
229
-			$perms = $perms & ~\OCP\Constants::PERMISSION_SHARE;
230
-		}
231
-		return (int) $perms;
232
-	}
233
-
234
-	/**
235
-	 * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
236
-	 */
237
-	public function getType() {
238
-		if (!isset($this->data['type'])) {
239
-			$this->data['type'] = ($this->getMimetype() === 'httpd/unix-directory') ? self::TYPE_FOLDER : self::TYPE_FILE;
240
-		}
241
-		return $this->data['type'];
242
-	}
243
-
244
-	public function getData() {
245
-		return $this->data;
246
-	}
247
-
248
-	/**
249
-	 * @param int $permissions
250
-	 * @return bool
251
-	 */
252
-	protected function checkPermissions($permissions) {
253
-		return ($this->getPermissions() & $permissions) === $permissions;
254
-	}
255
-
256
-	/**
257
-	 * @return bool
258
-	 */
259
-	public function isReadable() {
260
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_READ);
261
-	}
262
-
263
-	/**
264
-	 * @return bool
265
-	 */
266
-	public function isUpdateable() {
267
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE);
268
-	}
269
-
270
-	/**
271
-	 * Check whether new files or folders can be created inside this folder
272
-	 *
273
-	 * @return bool
274
-	 */
275
-	public function isCreatable() {
276
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE);
277
-	}
278
-
279
-	/**
280
-	 * @return bool
281
-	 */
282
-	public function isDeletable() {
283
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE);
284
-	}
285
-
286
-	/**
287
-	 * @return bool
288
-	 */
289
-	public function isShareable() {
290
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE);
291
-	}
292
-
293
-	/**
294
-	 * Check if a file or folder is shared
295
-	 *
296
-	 * @return bool
297
-	 */
298
-	public function isShared() {
299
-		$sid = $this->getStorage()->getId();
300
-		if (!is_null($sid)) {
301
-			$sid = explode(':', $sid);
302
-			return ($sid[0] === 'shared');
303
-		}
304
-
305
-		return false;
306
-	}
307
-
308
-	public function isMounted() {
309
-		$storage = $this->getStorage();
310
-		if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
311
-			return false;
312
-		}
313
-		$sid = $storage->getId();
314
-		if (!is_null($sid)) {
315
-			$sid = explode(':', $sid);
316
-			return ($sid[0] !== 'home' and $sid[0] !== 'shared');
317
-		}
318
-
319
-		return false;
320
-	}
321
-
322
-	/**
323
-	 * Get the mountpoint the file belongs to
324
-	 *
325
-	 * @return \OCP\Files\Mount\IMountPoint
326
-	 */
327
-	public function getMountPoint() {
328
-		return $this->mount;
329
-	}
330
-
331
-	/**
332
-	 * Get the owner of the file
333
-	 *
334
-	 * @return \OCP\IUser
335
-	 */
336
-	public function getOwner() {
337
-		return $this->owner;
338
-	}
339
-
340
-	/**
341
-	 * @param IMountPoint[] $mounts
342
-	 */
343
-	public function setSubMounts(array $mounts) {
344
-		$this->subMounts = $mounts;
345
-	}
346
-
347
-	private function updateEntryfromSubMounts() {
348
-		if ($this->subMountsUsed) {
349
-			return;
350
-		}
351
-		$this->subMountsUsed = true;
352
-		foreach ($this->subMounts as $mount) {
353
-			$subStorage = $mount->getStorage();
354
-			if ($subStorage) {
355
-				$subCache = $subStorage->getCache('');
356
-				$rootEntry = $subCache->get('');
357
-				$this->addSubEntry($rootEntry, $mount->getMountPoint());
358
-			}
359
-		}
360
-	}
361
-
362
-	/**
363
-	 * Add a cache entry which is the child of this folder
364
-	 *
365
-	 * Sets the size, etag and size to for cross-storage childs
366
-	 *
367
-	 * @param array|ICacheEntry $data cache entry for the child
368
-	 * @param string $entryPath full path of the child entry
369
-	 */
370
-	public function addSubEntry($data, $entryPath) {
371
-		$this->data['size'] += isset($data['size']) ? $data['size'] : 0;
372
-		if (isset($data['mtime'])) {
373
-			$this->data['mtime'] = max($this->data['mtime'], $data['mtime']);
374
-		}
375
-		if (isset($data['etag'])) {
376
-			// prefix the etag with the relative path of the subentry to propagate etag on mount moves
377
-			$relativeEntryPath = substr($entryPath, strlen($this->getPath()));
378
-			// attach the permissions to propagate etag on permision changes of submounts
379
-			$permissions = isset($data['permissions']) ? $data['permissions'] : 0;
380
-			$this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions;
381
-		}
382
-	}
383
-
384
-	/**
385
-	 * @inheritdoc
386
-	 */
387
-	public function getChecksum() {
388
-		return $this->data['checksum'];
389
-	}
38
+    /**
39
+     * @var array $data
40
+     */
41
+    private $data;
42
+
43
+    /**
44
+     * @var string $path
45
+     */
46
+    private $path;
47
+
48
+    /**
49
+     * @var \OC\Files\Storage\Storage $storage
50
+     */
51
+    private $storage;
52
+
53
+    /**
54
+     * @var string $internalPath
55
+     */
56
+    private $internalPath;
57
+
58
+    /**
59
+     * @var \OCP\Files\Mount\IMountPoint
60
+     */
61
+    private $mount;
62
+
63
+    /**
64
+     * @var IUser
65
+     */
66
+    private $owner;
67
+
68
+    /**
69
+     * @var string[]
70
+     */
71
+    private $childEtags = [];
72
+
73
+    /**
74
+     * @var IMountPoint[]
75
+     */
76
+    private $subMounts = [];
77
+
78
+    private $subMountsUsed = false;
79
+
80
+    /**
81
+     * @param string|boolean $path
82
+     * @param Storage\Storage $storage
83
+     * @param string $internalPath
84
+     * @param array|ICacheEntry $data
85
+     * @param \OCP\Files\Mount\IMountPoint $mount
86
+     * @param \OCP\IUser|null $owner
87
+     */
88
+    public function __construct($path, $storage, $internalPath, $data, $mount, $owner= null) {
89
+        $this->path = $path;
90
+        $this->storage = $storage;
91
+        $this->internalPath = $internalPath;
92
+        $this->data = $data;
93
+        $this->mount = $mount;
94
+        $this->owner = $owner;
95
+    }
96
+
97
+    public function offsetSet($offset, $value) {
98
+        $this->data[$offset] = $value;
99
+    }
100
+
101
+    public function offsetExists($offset) {
102
+        return isset($this->data[$offset]);
103
+    }
104
+
105
+    public function offsetUnset($offset) {
106
+        unset($this->data[$offset]);
107
+    }
108
+
109
+    public function offsetGet($offset) {
110
+        if ($offset === 'type') {
111
+            return $this->getType();
112
+        } else if ($offset === 'etag') {
113
+            return $this->getEtag();
114
+        } else if ($offset === 'size') {
115
+            return $this->getSize();
116
+        } else if ($offset === 'mtime') {
117
+            return $this->getMTime();
118
+        } elseif ($offset === 'permissions') {
119
+            return $this->getPermissions();
120
+        } elseif (isset($this->data[$offset])) {
121
+            return $this->data[$offset];
122
+        } else {
123
+            return null;
124
+        }
125
+    }
126
+
127
+    /**
128
+     * @return string
129
+     */
130
+    public function getPath() {
131
+        return $this->path;
132
+    }
133
+
134
+    /**
135
+     * @return \OCP\Files\Storage
136
+     */
137
+    public function getStorage() {
138
+        return $this->storage;
139
+    }
140
+
141
+    /**
142
+     * @return string
143
+     */
144
+    public function getInternalPath() {
145
+        return $this->internalPath;
146
+    }
147
+
148
+    /**
149
+     * Get FileInfo ID or null in case of part file
150
+     *
151
+     * @return int|null
152
+     */
153
+    public function getId() {
154
+        return isset($this->data['fileid']) ? (int)  $this->data['fileid'] : null;
155
+    }
156
+
157
+    /**
158
+     * @return string
159
+     */
160
+    public function getMimetype() {
161
+        return $this->data['mimetype'];
162
+    }
163
+
164
+    /**
165
+     * @return string
166
+     */
167
+    public function getMimePart() {
168
+        return $this->data['mimepart'];
169
+    }
170
+
171
+    /**
172
+     * @return string
173
+     */
174
+    public function getName() {
175
+        return basename($this->getPath());
176
+    }
177
+
178
+    /**
179
+     * @return string
180
+     */
181
+    public function getEtag() {
182
+        $this->updateEntryfromSubMounts();
183
+        if (count($this->childEtags) > 0) {
184
+            $combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags);
185
+            return md5($combinedEtag);
186
+        } else {
187
+            return $this->data['etag'];
188
+        }
189
+    }
190
+
191
+    /**
192
+     * @return int
193
+     */
194
+    public function getSize() {
195
+        $this->updateEntryfromSubMounts();
196
+        return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
197
+    }
198
+
199
+    /**
200
+     * @return int
201
+     */
202
+    public function getMTime() {
203
+        $this->updateEntryfromSubMounts();
204
+        return (int) $this->data['mtime'];
205
+    }
206
+
207
+    /**
208
+     * @return bool
209
+     */
210
+    public function isEncrypted() {
211
+        return $this->data['encrypted'];
212
+    }
213
+
214
+    /**
215
+     * Return the currently version used for the HMAC in the encryption app
216
+     *
217
+     * @return int
218
+     */
219
+    public function getEncryptedVersion() {
220
+        return isset($this->data['encryptedVersion']) ? (int) $this->data['encryptedVersion'] : 1;
221
+    }
222
+
223
+    /**
224
+     * @return int
225
+     */
226
+    public function getPermissions() {
227
+        $perms = (int) $this->data['permissions'];
228
+        if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) {
229
+            $perms = $perms & ~\OCP\Constants::PERMISSION_SHARE;
230
+        }
231
+        return (int) $perms;
232
+    }
233
+
234
+    /**
235
+     * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
236
+     */
237
+    public function getType() {
238
+        if (!isset($this->data['type'])) {
239
+            $this->data['type'] = ($this->getMimetype() === 'httpd/unix-directory') ? self::TYPE_FOLDER : self::TYPE_FILE;
240
+        }
241
+        return $this->data['type'];
242
+    }
243
+
244
+    public function getData() {
245
+        return $this->data;
246
+    }
247
+
248
+    /**
249
+     * @param int $permissions
250
+     * @return bool
251
+     */
252
+    protected function checkPermissions($permissions) {
253
+        return ($this->getPermissions() & $permissions) === $permissions;
254
+    }
255
+
256
+    /**
257
+     * @return bool
258
+     */
259
+    public function isReadable() {
260
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_READ);
261
+    }
262
+
263
+    /**
264
+     * @return bool
265
+     */
266
+    public function isUpdateable() {
267
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE);
268
+    }
269
+
270
+    /**
271
+     * Check whether new files or folders can be created inside this folder
272
+     *
273
+     * @return bool
274
+     */
275
+    public function isCreatable() {
276
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE);
277
+    }
278
+
279
+    /**
280
+     * @return bool
281
+     */
282
+    public function isDeletable() {
283
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE);
284
+    }
285
+
286
+    /**
287
+     * @return bool
288
+     */
289
+    public function isShareable() {
290
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE);
291
+    }
292
+
293
+    /**
294
+     * Check if a file or folder is shared
295
+     *
296
+     * @return bool
297
+     */
298
+    public function isShared() {
299
+        $sid = $this->getStorage()->getId();
300
+        if (!is_null($sid)) {
301
+            $sid = explode(':', $sid);
302
+            return ($sid[0] === 'shared');
303
+        }
304
+
305
+        return false;
306
+    }
307
+
308
+    public function isMounted() {
309
+        $storage = $this->getStorage();
310
+        if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
311
+            return false;
312
+        }
313
+        $sid = $storage->getId();
314
+        if (!is_null($sid)) {
315
+            $sid = explode(':', $sid);
316
+            return ($sid[0] !== 'home' and $sid[0] !== 'shared');
317
+        }
318
+
319
+        return false;
320
+    }
321
+
322
+    /**
323
+     * Get the mountpoint the file belongs to
324
+     *
325
+     * @return \OCP\Files\Mount\IMountPoint
326
+     */
327
+    public function getMountPoint() {
328
+        return $this->mount;
329
+    }
330
+
331
+    /**
332
+     * Get the owner of the file
333
+     *
334
+     * @return \OCP\IUser
335
+     */
336
+    public function getOwner() {
337
+        return $this->owner;
338
+    }
339
+
340
+    /**
341
+     * @param IMountPoint[] $mounts
342
+     */
343
+    public function setSubMounts(array $mounts) {
344
+        $this->subMounts = $mounts;
345
+    }
346
+
347
+    private function updateEntryfromSubMounts() {
348
+        if ($this->subMountsUsed) {
349
+            return;
350
+        }
351
+        $this->subMountsUsed = true;
352
+        foreach ($this->subMounts as $mount) {
353
+            $subStorage = $mount->getStorage();
354
+            if ($subStorage) {
355
+                $subCache = $subStorage->getCache('');
356
+                $rootEntry = $subCache->get('');
357
+                $this->addSubEntry($rootEntry, $mount->getMountPoint());
358
+            }
359
+        }
360
+    }
361
+
362
+    /**
363
+     * Add a cache entry which is the child of this folder
364
+     *
365
+     * Sets the size, etag and size to for cross-storage childs
366
+     *
367
+     * @param array|ICacheEntry $data cache entry for the child
368
+     * @param string $entryPath full path of the child entry
369
+     */
370
+    public function addSubEntry($data, $entryPath) {
371
+        $this->data['size'] += isset($data['size']) ? $data['size'] : 0;
372
+        if (isset($data['mtime'])) {
373
+            $this->data['mtime'] = max($this->data['mtime'], $data['mtime']);
374
+        }
375
+        if (isset($data['etag'])) {
376
+            // prefix the etag with the relative path of the subentry to propagate etag on mount moves
377
+            $relativeEntryPath = substr($entryPath, strlen($this->getPath()));
378
+            // attach the permissions to propagate etag on permision changes of submounts
379
+            $permissions = isset($data['permissions']) ? $data['permissions'] : 0;
380
+            $this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions;
381
+        }
382
+    }
383
+
384
+    /**
385
+     * @inheritdoc
386
+     */
387
+    public function getChecksum() {
388
+        return $this->data['checksum'];
389
+    }
390 390
 }
Please login to merge, or discard this patch.
lib/private/RedisFactory.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -23,86 +23,86 @@
 block discarded – undo
23 23
 namespace OC;
24 24
 
25 25
 class RedisFactory {
26
-	/** @var  \Redis */
27
-	private $instance;
26
+    /** @var  \Redis */
27
+    private $instance;
28 28
 
29
-	/** @var  SystemConfig */
30
-	private $config;
29
+    /** @var  SystemConfig */
30
+    private $config;
31 31
 
32
-	/**
33
-	 * RedisFactory constructor.
34
-	 *
35
-	 * @param SystemConfig $config
36
-	 */
37
-	public function __construct(SystemConfig $config) {
38
-		$this->config = $config;
39
-	}
32
+    /**
33
+     * RedisFactory constructor.
34
+     *
35
+     * @param SystemConfig $config
36
+     */
37
+    public function __construct(SystemConfig $config) {
38
+        $this->config = $config;
39
+    }
40 40
 
41
-	private function create() {
42
-		if ($config = $this->config->getValue('redis.cluster', [])) {
43
-			if (!class_exists('RedisCluster')) {
44
-				throw new \Exception('Redis Cluster support is not available');
45
-			}
46
-			// cluster config
47
-			if (isset($config['timeout'])) {
48
-				$timeout = $config['timeout'];
49
-			} else {
50
-				$timeout = null;
51
-			}
52
-			if (isset($config['read_timeout'])) {
53
-				$readTimeout = $config['read_timeout'];
54
-			} else {
55
-				$readTimeout = null;
56
-			}
57
-			$this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout);
41
+    private function create() {
42
+        if ($config = $this->config->getValue('redis.cluster', [])) {
43
+            if (!class_exists('RedisCluster')) {
44
+                throw new \Exception('Redis Cluster support is not available');
45
+            }
46
+            // cluster config
47
+            if (isset($config['timeout'])) {
48
+                $timeout = $config['timeout'];
49
+            } else {
50
+                $timeout = null;
51
+            }
52
+            if (isset($config['read_timeout'])) {
53
+                $readTimeout = $config['read_timeout'];
54
+            } else {
55
+                $readTimeout = null;
56
+            }
57
+            $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout);
58 58
 
59
-			if (isset($config['failover_mode'])) {
60
-				$this->instance->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, $config['failover_mode']);
61
-			}
62
-		} else {
59
+            if (isset($config['failover_mode'])) {
60
+                $this->instance->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, $config['failover_mode']);
61
+            }
62
+        } else {
63 63
 
64
-			$this->instance = new \Redis();
65
-			$config = $this->config->getValue('redis', []);
66
-			if (isset($config['host'])) {
67
-				$host = $config['host'];
68
-			} else {
69
-				$host = '127.0.0.1';
70
-			}
71
-			if (isset($config['port'])) {
72
-				$port = $config['port'];
73
-			} else {
74
-				$port = 6379;
75
-			}
76
-			if (isset($config['timeout'])) {
77
-				$timeout = $config['timeout'];
78
-			} else {
79
-				$timeout = 0.0; // unlimited
80
-			}
64
+            $this->instance = new \Redis();
65
+            $config = $this->config->getValue('redis', []);
66
+            if (isset($config['host'])) {
67
+                $host = $config['host'];
68
+            } else {
69
+                $host = '127.0.0.1';
70
+            }
71
+            if (isset($config['port'])) {
72
+                $port = $config['port'];
73
+            } else {
74
+                $port = 6379;
75
+            }
76
+            if (isset($config['timeout'])) {
77
+                $timeout = $config['timeout'];
78
+            } else {
79
+                $timeout = 0.0; // unlimited
80
+            }
81 81
 
82
-			$this->instance->connect($host, $port, $timeout);
83
-			if (isset($config['password']) && $config['password'] !== '') {
84
-				$this->instance->auth($config['password']);
85
-			}
82
+            $this->instance->connect($host, $port, $timeout);
83
+            if (isset($config['password']) && $config['password'] !== '') {
84
+                $this->instance->auth($config['password']);
85
+            }
86 86
 
87
-			if (isset($config['dbindex'])) {
88
-				$this->instance->select($config['dbindex']);
89
-			}
90
-		}
91
-	}
87
+            if (isset($config['dbindex'])) {
88
+                $this->instance->select($config['dbindex']);
89
+            }
90
+        }
91
+    }
92 92
 
93
-	public function getInstance() {
94
-		if (!$this->isAvailable()) {
95
-			throw new \Exception('Redis support is not available');
96
-		}
97
-		if (!$this->instance instanceof \Redis) {
98
-			$this->create();
99
-		}
93
+    public function getInstance() {
94
+        if (!$this->isAvailable()) {
95
+            throw new \Exception('Redis support is not available');
96
+        }
97
+        if (!$this->instance instanceof \Redis) {
98
+            $this->create();
99
+        }
100 100
 
101
-		return $this->instance;
102
-	}
101
+        return $this->instance;
102
+    }
103 103
 
104
-	public function isAvailable() {
105
-		return extension_loaded('redis')
106
-		&& version_compare(phpversion('redis'), '2.2.5', '>=');
107
-	}
104
+    public function isAvailable() {
105
+        return extension_loaded('redis')
106
+        && version_compare(phpversion('redis'), '2.2.5', '>=');
107
+    }
108 108
 }
Please login to merge, or discard this patch.
apps/dav/lib/Avatars/AvatarHome.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -98,6 +98,9 @@
 block discarded – undo
98 98
 		throw new Forbidden('Permission denied to delete this folder');
99 99
 	}
100 100
 
101
+	/**
102
+	 * @return string
103
+	 */
101 104
 	public function getName() {
102 105
 		list(,$name) = Uri\split($this->principalInfo['uri']);
103 106
 		return $name;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	public function getChild($name) {
60 60
 		$elements = pathinfo($name);
61 61
 		$ext = isset($elements['extension']) ? $elements['extension'] : '';
62
-		$size = (int)(isset($elements['filename']) ? $elements['filename'] : '64');
62
+		$size = (int) (isset($elements['filename']) ? $elements['filename'] : '64');
63 63
 		if (!in_array($ext, ['jpeg', 'png'], true)) {
64 64
 			throw new MethodNotAllowed('File format not allowed');
65 65
 		}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			return [
79 79
 				$this->getChild('96.jpeg')
80 80
 			];
81
-		} catch(NotFound $exception) {
81
+		} catch (NotFound $exception) {
82 82
 			return [];
83 83
 		}
84 84
 	}
Please login to merge, or discard this patch.
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -35,89 +35,89 @@
 block discarded – undo
35 35
 
36 36
 class AvatarHome implements ICollection {
37 37
 
38
-	/** @var array */
39
-	private $principalInfo;
40
-	/** @var IAvatarManager */
41
-	private $avatarManager;
42
-
43
-	/**
44
-	 * AvatarHome constructor.
45
-	 *
46
-	 * @param array $principalInfo
47
-	 * @param IAvatarManager $avatarManager
48
-	 */
49
-	public function __construct($principalInfo, IAvatarManager $avatarManager) {
50
-		$this->principalInfo = $principalInfo;
51
-		$this->avatarManager = $avatarManager;
52
-	}
53
-
54
-	public function createFile($name, $data = null) {
55
-		throw new Forbidden('Permission denied to create a file');
56
-	}
57
-
58
-	public function createDirectory($name) {
59
-		throw new Forbidden('Permission denied to create a folder');
60
-	}
61
-
62
-	public function getChild($name) {
63
-		$elements = pathinfo($name);
64
-		$ext = isset($elements['extension']) ? $elements['extension'] : '';
65
-		$size = (int)(isset($elements['filename']) ? $elements['filename'] : '64');
66
-		if (!in_array($ext, ['jpeg', 'png'], true)) {
67
-			throw new MethodNotAllowed('File format not allowed');
68
-		}
69
-		if ($size <= 0 || $size > 1024) {
70
-			throw new MethodNotAllowed('Invalid image size');
71
-		}
72
-		$avatar = $this->avatarManager->getAvatar($this->getName());
73
-		if (!$avatar->exists()) {
74
-			throw new NotFound();
75
-		}
76
-		return new AvatarNode($size, $ext, $avatar);
77
-	}
78
-
79
-	public function getChildren() {
80
-		try {
81
-			return [
82
-				$this->getChild('96.jpeg')
83
-			];
84
-		} catch(NotFound $exception) {
85
-			return [];
86
-		}
87
-	}
88
-
89
-	public function childExists($name) {
90
-		try {
91
-			$ret = $this->getChild($name);
92
-			return $ret !== null;
93
-		} catch (NotFound $ex) {
94
-			return false;
95
-		} catch (MethodNotAllowed $ex) {
96
-			return false;
97
-		}
98
-	}
99
-
100
-	public function delete() {
101
-		throw new Forbidden('Permission denied to delete this folder');
102
-	}
103
-
104
-	public function getName() {
105
-		list(,$name) = Uri\split($this->principalInfo['uri']);
106
-		return $name;
107
-	}
108
-
109
-	public function setName($name) {
110
-		throw new Forbidden('Permission denied to rename this folder');
111
-	}
112
-
113
-	/**
114
-	 * Returns the last modification time, as a unix timestamp
115
-	 *
116
-	 * @return int|null
117
-	 */
118
-	public function getLastModified() {
119
-		return null;
120
-	}
38
+    /** @var array */
39
+    private $principalInfo;
40
+    /** @var IAvatarManager */
41
+    private $avatarManager;
42
+
43
+    /**
44
+     * AvatarHome constructor.
45
+     *
46
+     * @param array $principalInfo
47
+     * @param IAvatarManager $avatarManager
48
+     */
49
+    public function __construct($principalInfo, IAvatarManager $avatarManager) {
50
+        $this->principalInfo = $principalInfo;
51
+        $this->avatarManager = $avatarManager;
52
+    }
53
+
54
+    public function createFile($name, $data = null) {
55
+        throw new Forbidden('Permission denied to create a file');
56
+    }
57
+
58
+    public function createDirectory($name) {
59
+        throw new Forbidden('Permission denied to create a folder');
60
+    }
61
+
62
+    public function getChild($name) {
63
+        $elements = pathinfo($name);
64
+        $ext = isset($elements['extension']) ? $elements['extension'] : '';
65
+        $size = (int)(isset($elements['filename']) ? $elements['filename'] : '64');
66
+        if (!in_array($ext, ['jpeg', 'png'], true)) {
67
+            throw new MethodNotAllowed('File format not allowed');
68
+        }
69
+        if ($size <= 0 || $size > 1024) {
70
+            throw new MethodNotAllowed('Invalid image size');
71
+        }
72
+        $avatar = $this->avatarManager->getAvatar($this->getName());
73
+        if (!$avatar->exists()) {
74
+            throw new NotFound();
75
+        }
76
+        return new AvatarNode($size, $ext, $avatar);
77
+    }
78
+
79
+    public function getChildren() {
80
+        try {
81
+            return [
82
+                $this->getChild('96.jpeg')
83
+            ];
84
+        } catch(NotFound $exception) {
85
+            return [];
86
+        }
87
+    }
88
+
89
+    public function childExists($name) {
90
+        try {
91
+            $ret = $this->getChild($name);
92
+            return $ret !== null;
93
+        } catch (NotFound $ex) {
94
+            return false;
95
+        } catch (MethodNotAllowed $ex) {
96
+            return false;
97
+        }
98
+    }
99
+
100
+    public function delete() {
101
+        throw new Forbidden('Permission denied to delete this folder');
102
+    }
103
+
104
+    public function getName() {
105
+        list(,$name) = Uri\split($this->principalInfo['uri']);
106
+        return $name;
107
+    }
108
+
109
+    public function setName($name) {
110
+        throw new Forbidden('Permission denied to rename this folder');
111
+    }
112
+
113
+    /**
114
+     * Returns the last modification time, as a unix timestamp
115
+     *
116
+     * @return int|null
117
+     */
118
+    public function getLastModified() {
119
+        return null;
120
+    }
121 121
 
122 122
 
123 123
 }
Please login to merge, or discard this patch.
apps/dav/lib/Avatars/AvatarNode.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
 	public function getLastModified() {
90 90
 		$timestamp = $this->avatar->getFile($this->size)->getMTime();
91 91
 		if (!empty($timestamp)) {
92
-			return (int)$timestamp;
92
+			return (int) $timestamp;
93 93
 		}
94 94
 		return $timestamp;
95 95
 
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -27,72 +27,72 @@
 block discarded – undo
27 27
 use Sabre\DAV\File;
28 28
 
29 29
 class AvatarNode extends File {
30
-	private $ext;
31
-	private $size;
32
-	private $avatar;
30
+    private $ext;
31
+    private $size;
32
+    private $avatar;
33 33
 
34
-	/**
35
-	 * AvatarNode constructor.
36
-	 *
37
-	 * @param integer $size
38
-	 * @param string $ext
39
-	 * @param IAvatar $avatar
40
-	 */
41
-	public function __construct($size, $ext, $avatar) {
42
-		$this->size = $size;
43
-		$this->ext = $ext;
44
-		$this->avatar = $avatar;
45
-	}
34
+    /**
35
+     * AvatarNode constructor.
36
+     *
37
+     * @param integer $size
38
+     * @param string $ext
39
+     * @param IAvatar $avatar
40
+     */
41
+    public function __construct($size, $ext, $avatar) {
42
+        $this->size = $size;
43
+        $this->ext = $ext;
44
+        $this->avatar = $avatar;
45
+    }
46 46
 
47
-	/**
48
-	 * Returns the name of the node.
49
-	 *
50
-	 * This is used to generate the url.
51
-	 *
52
-	 * @return string
53
-	 */
54
-	public function getName() {
55
-		return "$this->size.$this->ext";
56
-	}
47
+    /**
48
+     * Returns the name of the node.
49
+     *
50
+     * This is used to generate the url.
51
+     *
52
+     * @return string
53
+     */
54
+    public function getName() {
55
+        return "$this->size.$this->ext";
56
+    }
57 57
 
58
-	public function get() {
59
-		$image = $this->avatar->get($this->size);
60
-		$res = $image->resource();
58
+    public function get() {
59
+        $image = $this->avatar->get($this->size);
60
+        $res = $image->resource();
61 61
 
62
-		ob_start();
63
-		if ($this->ext === 'png') {
64
-			imagepng($res);
65
-		} else {
66
-			imagejpeg($res);
67
-		}
62
+        ob_start();
63
+        if ($this->ext === 'png') {
64
+            imagepng($res);
65
+        } else {
66
+            imagejpeg($res);
67
+        }
68 68
 
69
-		return ob_get_clean();
70
-	}
69
+        return ob_get_clean();
70
+    }
71 71
 
72
-	/**
73
-	 * Returns the mime-type for a file
74
-	 *
75
-	 * If null is returned, we'll assume application/octet-stream
76
-	 *
77
-	 * @return string|null
78
-	 */
79
-	public function getContentType() {
80
-		if ($this->ext === 'png') {
81
-			return 'image/png';
82
-		}
83
-		return 'image/jpeg';
84
-	}
72
+    /**
73
+     * Returns the mime-type for a file
74
+     *
75
+     * If null is returned, we'll assume application/octet-stream
76
+     *
77
+     * @return string|null
78
+     */
79
+    public function getContentType() {
80
+        if ($this->ext === 'png') {
81
+            return 'image/png';
82
+        }
83
+        return 'image/jpeg';
84
+    }
85 85
 
86
-	public function getETag() {
87
-		return $this->avatar->getFile($this->size)->getEtag();
88
-	}
86
+    public function getETag() {
87
+        return $this->avatar->getFile($this->size)->getEtag();
88
+    }
89 89
 
90
-	public function getLastModified() {
91
-		$timestamp = $this->avatar->getFile($this->size)->getMTime();
92
-		if (!empty($timestamp)) {
93
-			return (int)$timestamp;
94
-		}
95
-		return $timestamp;
90
+    public function getLastModified() {
91
+        $timestamp = $this->avatar->getFile($this->size)->getMTime();
92
+        if (!empty($timestamp)) {
93
+            return (int)$timestamp;
94
+        }
95
+        return $timestamp;
96 96
 
97
-	}
97
+    }
98 98
 }
Please login to merge, or discard this patch.
apps/dav/lib/Avatars/RootCollection.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,23 +7,23 @@
 block discarded – undo
7 7
 
8 8
 class RootCollection extends AbstractPrincipalCollection {
9 9
 
10
-	/**
11
-	 * This method returns a node for a principal.
12
-	 *
13
-	 * The passed array contains principal information, and is guaranteed to
14
-	 * at least contain a uri item. Other properties may or may not be
15
-	 * supplied by the authentication backend.
16
-	 *
17
-	 * @param array $principalInfo
18
-	 * @return AvatarHome
19
-	 */
20
-	public function getChildForPrincipal(array $principalInfo) {
21
-		$avatarManager = \OC::$server->getAvatarManager();
22
-		return new AvatarHome($principalInfo, $avatarManager);
23
-	}
10
+    /**
11
+     * This method returns a node for a principal.
12
+     *
13
+     * The passed array contains principal information, and is guaranteed to
14
+     * at least contain a uri item. Other properties may or may not be
15
+     * supplied by the authentication backend.
16
+     *
17
+     * @param array $principalInfo
18
+     * @return AvatarHome
19
+     */
20
+    public function getChildForPrincipal(array $principalInfo) {
21
+        $avatarManager = \OC::$server->getAvatarManager();
22
+        return new AvatarHome($principalInfo, $avatarManager);
23
+    }
24 24
 
25
-	public function getName() {
26
-		return 'avatars';
27
-	}
25
+    public function getName() {
26
+        return 'avatars';
27
+    }
28 28
 
29 29
 }
Please login to merge, or discard this patch.
apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -97,6 +97,9 @@
 block discarded – undo
97 97
 		}
98 98
 	}
99 99
 
100
+	/**
101
+	 * @param string $pattern
102
+	 */
100 103
 	protected function getInvalidObjects($pattern) {
101 104
 		$query = $this->db->getQueryBuilder();
102 105
 		$query->select(['calendarid', 'uri'])
Please login to merge, or discard this patch.
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -33,87 +33,87 @@
 block discarded – undo
33 33
 
34 34
 class CalDAVRemoveEmptyValue implements IRepairStep {
35 35
 
36
-	/** @var IDBConnection */
37
-	private $db;
38
-
39
-	/** @var CalDavBackend */
40
-	private $calDavBackend;
41
-
42
-	/** @var ILogger */
43
-	private $logger;
44
-
45
-	/**
46
-	 * @param IDBConnection $db
47
-	 * @param CalDavBackend $calDavBackend
48
-	 * @param ILogger $logger
49
-	 */
50
-	public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) {
51
-		$this->db = $db;
52
-		$this->calDavBackend = $calDavBackend;
53
-		$this->logger = $logger;
54
-	}
55
-
56
-	public function getName() {
57
-		return 'Fix broken values of calendar objects';
58
-	}
59
-
60
-	public function run(IOutput $output) {
61
-		$pattern = ';VALUE=:';
62
-		$count = $warnings = 0;
63
-
64
-		$objects = $this->getInvalidObjects($pattern);
65
-
66
-		$output->startProgress(count($objects));
67
-		foreach ($objects as $row) {
68
-			$calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']);
69
-			$data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']);
70
-
71
-			if ($data !== $calObject['calendardata']) {
72
-				$output->advance();
73
-
74
-				try {
75
-					$this->calDavBackend->getDenormalizedData($data);
76
-				} catch (InvalidDataException $e) {
77
-					$this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [
78
-						'app' => 'dav',
79
-						'cal' => (int)$row['calendarid'],
80
-						'uri' => $row['uri'],
81
-					]);
82
-					$warnings++;
83
-					continue;
84
-				}
85
-
86
-				$this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data);
87
-				$count++;
88
-			}
89
-		}
90
-		$output->finishProgress();
91
-
92
-		if ($warnings > 0) {
93
-			$output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings));
94
-		}
95
-		if ($count > 0) {
96
-			$output->info(sprintf('Updated %d events', $count));
97
-		}
98
-	}
99
-
100
-	protected function getInvalidObjects($pattern) {
101
-		$query = $this->db->getQueryBuilder();
102
-		$query->select(['calendarid', 'uri'])
103
-			->from('calendarobjects')
104
-			->where($query->expr()->like(
105
-				'calendardata',
106
-				$query->createNamedParameter(
107
-					'%' . $this->db->escapeLikeParameter($pattern) . '%',
108
-					IQueryBuilder::PARAM_STR
109
-				),
110
-				IQueryBuilder::PARAM_STR
111
-			));
112
-
113
-		$result = $query->execute();
114
-		$rows = $result->fetchAll();
115
-		$result->closeCursor();
116
-
117
-		return $rows;
118
-	}
36
+    /** @var IDBConnection */
37
+    private $db;
38
+
39
+    /** @var CalDavBackend */
40
+    private $calDavBackend;
41
+
42
+    /** @var ILogger */
43
+    private $logger;
44
+
45
+    /**
46
+     * @param IDBConnection $db
47
+     * @param CalDavBackend $calDavBackend
48
+     * @param ILogger $logger
49
+     */
50
+    public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) {
51
+        $this->db = $db;
52
+        $this->calDavBackend = $calDavBackend;
53
+        $this->logger = $logger;
54
+    }
55
+
56
+    public function getName() {
57
+        return 'Fix broken values of calendar objects';
58
+    }
59
+
60
+    public function run(IOutput $output) {
61
+        $pattern = ';VALUE=:';
62
+        $count = $warnings = 0;
63
+
64
+        $objects = $this->getInvalidObjects($pattern);
65
+
66
+        $output->startProgress(count($objects));
67
+        foreach ($objects as $row) {
68
+            $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']);
69
+            $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']);
70
+
71
+            if ($data !== $calObject['calendardata']) {
72
+                $output->advance();
73
+
74
+                try {
75
+                    $this->calDavBackend->getDenormalizedData($data);
76
+                } catch (InvalidDataException $e) {
77
+                    $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [
78
+                        'app' => 'dav',
79
+                        'cal' => (int)$row['calendarid'],
80
+                        'uri' => $row['uri'],
81
+                    ]);
82
+                    $warnings++;
83
+                    continue;
84
+                }
85
+
86
+                $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data);
87
+                $count++;
88
+            }
89
+        }
90
+        $output->finishProgress();
91
+
92
+        if ($warnings > 0) {
93
+            $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings));
94
+        }
95
+        if ($count > 0) {
96
+            $output->info(sprintf('Updated %d events', $count));
97
+        }
98
+    }
99
+
100
+    protected function getInvalidObjects($pattern) {
101
+        $query = $this->db->getQueryBuilder();
102
+        $query->select(['calendarid', 'uri'])
103
+            ->from('calendarobjects')
104
+            ->where($query->expr()->like(
105
+                'calendardata',
106
+                $query->createNamedParameter(
107
+                    '%' . $this->db->escapeLikeParameter($pattern) . '%',
108
+                    IQueryBuilder::PARAM_STR
109
+                ),
110
+                IQueryBuilder::PARAM_STR
111
+            ));
112
+
113
+        $result = $query->execute();
114
+        $rows = $result->fetchAll();
115
+        $result->closeCursor();
116
+
117
+        return $rows;
118
+    }
119 119
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 
66 66
 		$output->startProgress(count($objects));
67 67
 		foreach ($objects as $row) {
68
-			$calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']);
69
-			$data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']);
68
+			$calObject = $this->calDavBackend->getCalendarObject((int) $row['calendarid'], $row['uri']);
69
+			$data = preg_replace('/'.$pattern.'/', ':', $calObject['calendardata']);
70 70
 
71 71
 			if ($data !== $calObject['calendardata']) {
72 72
 				$output->advance();
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
 				} catch (InvalidDataException $e) {
77 77
 					$this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [
78 78
 						'app' => 'dav',
79
-						'cal' => (int)$row['calendarid'],
79
+						'cal' => (int) $row['calendarid'],
80 80
 						'uri' => $row['uri'],
81 81
 					]);
82 82
 					$warnings++;
83 83
 					continue;
84 84
 				}
85 85
 
86
-				$this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data);
86
+				$this->calDavBackend->updateCalendarObject((int) $row['calendarid'], $row['uri'], $data);
87 87
 				$count++;
88 88
 			}
89 89
 		}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			->where($query->expr()->like(
105 105
 				'calendardata',
106 106
 				$query->createNamedParameter(
107
-					'%' . $this->db->escapeLikeParameter($pattern) . '%',
107
+					'%'.$this->db->escapeLikeParameter($pattern).'%',
108 108
 					IQueryBuilder::PARAM_STR
109 109
 				),
110 110
 				IQueryBuilder::PARAM_STR
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
 	 * the next element.
80 80
 	 *
81 81
 	 * @param Reader $reader
82
-	 * @return mixed
82
+	 * @return CalendarSearchReport
83 83
 	 */
84 84
 	static function xmlDeserialize(Reader $reader) {
85 85
 		$elems = $reader->parseInnerTree([
Please login to merge, or discard this patch.
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -35,133 +35,133 @@
 block discarded – undo
35 35
  */
36 36
 class CalendarSearchReport implements XmlDeserializable {
37 37
 
38
-	/**
39
-	 * An array with requested properties.
40
-	 *
41
-	 * @var array
42
-	 */
43
-	public $properties;
44
-
45
-	/**
46
-	 * List of property/component filters.
47
-	 *
48
-	 * @var array
49
-	 */
50
-	public $filters;
51
-
52
-	/**
53
-	 * @var int
54
-	 */
55
-	public $limit;
56
-
57
-	/**
58
-	 * @var int
59
-	 */
60
-	public $offset;
61
-
62
-	/**
63
-	 * The deserialize method is called during xml parsing.
64
-	 *
65
-	 * This method is called statically, this is because in theory this method
66
-	 * may be used as a type of constructor, or factory method.
67
-	 *
68
-	 * Often you want to return an instance of the current class, but you are
69
-	 * free to return other data as well.
70
-	 *
71
-	 * You are responsible for advancing the reader to the next element. Not
72
-	 * doing anything will result in a never-ending loop.
73
-	 *
74
-	 * If you just want to skip parsing for this element altogether, you can
75
-	 * just call $reader->next();
76
-	 *
77
-	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
78
-	 * the next element.
79
-	 *
80
-	 * @param Reader $reader
81
-	 * @return mixed
82
-	 */
83
-	static function xmlDeserialize(Reader $reader) {
84
-		$elems = $reader->parseInnerTree([
85
-			'{http://nextcloud.com/ns}comp-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
86
-			'{http://nextcloud.com/ns}prop-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
87
-			'{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
88
-			'{http://nextcloud.com/ns}search-term'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
89
-			'{http://nextcloud.com/ns}limit'        => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
90
-			'{http://nextcloud.com/ns}offset'       => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
91
-			'{DAV:}prop'                            => 'Sabre\\Xml\\Element\\KeyValue',
92
-		]);
93
-
94
-		$newProps = [
95
-			'filters'    => [],
96
-			'properties' => [],
97
-			'limit'      => null,
98
-			'offset'     => null
99
-		];
100
-
101
-		if (!is_array($elems)) {
102
-			$elems = [];
103
-		}
104
-
105
-		foreach ($elems as $elem) {
106
-			switch ($elem['name']) {
107
-				case '{DAV:}prop':
108
-					$newProps['properties'] = array_keys($elem['value']);
109
-					break;
110
-				case '{' . SearchPlugin::NS_Nextcloud . '}filter':
111
-					foreach ($elem['value'] as $subElem) {
112
-						if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
113
-							if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114
-								$newProps['filters']['comps'] = [];
115
-							}
116
-							$newProps['filters']['comps'][] = $subElem['value'];
117
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
118
-							if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119
-								$newProps['filters']['props'] = [];
120
-							}
121
-							$newProps['filters']['props'][] = $subElem['value'];
122
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
123
-							if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124
-								$newProps['filters']['params'] = [];
125
-							}
126
-							$newProps['filters']['params'][] = $subElem['value'];
127
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
128
-							$newProps['filters']['search-term'] = $subElem['value'];
129
-						}
130
-					}
131
-					break;
132
-				case '{' . SearchPlugin::NS_Nextcloud . '}limit':
133
-					$newProps['limit'] = $elem['value'];
134
-					break;
135
-				case '{' . SearchPlugin::NS_Nextcloud . '}offset':
136
-					$newProps['offset'] = $elem['value'];
137
-					break;
138
-
139
-			}
140
-		}
141
-
142
-		if (empty($newProps['filters'])) {
143
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
144
-		}
145
-
146
-		$propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147
-		$noCompsDefined = empty($newProps['filters']['comps']);
148
-		if ($propsOrParamsDefined && $noCompsDefined) {
149
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
150
-		}
151
-
152
-		if (!isset($newProps['filters']['search-term'])) {
153
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
154
-		}
155
-
156
-		if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
-			throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
158
-		}
159
-
160
-
161
-		$obj = new self();
162
-		foreach ($newProps as $key => $value) {
163
-			$obj->$key = $value;
164
-		}
165
-		return $obj;
166
-	}
38
+    /**
39
+     * An array with requested properties.
40
+     *
41
+     * @var array
42
+     */
43
+    public $properties;
44
+
45
+    /**
46
+     * List of property/component filters.
47
+     *
48
+     * @var array
49
+     */
50
+    public $filters;
51
+
52
+    /**
53
+     * @var int
54
+     */
55
+    public $limit;
56
+
57
+    /**
58
+     * @var int
59
+     */
60
+    public $offset;
61
+
62
+    /**
63
+     * The deserialize method is called during xml parsing.
64
+     *
65
+     * This method is called statically, this is because in theory this method
66
+     * may be used as a type of constructor, or factory method.
67
+     *
68
+     * Often you want to return an instance of the current class, but you are
69
+     * free to return other data as well.
70
+     *
71
+     * You are responsible for advancing the reader to the next element. Not
72
+     * doing anything will result in a never-ending loop.
73
+     *
74
+     * If you just want to skip parsing for this element altogether, you can
75
+     * just call $reader->next();
76
+     *
77
+     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
78
+     * the next element.
79
+     *
80
+     * @param Reader $reader
81
+     * @return mixed
82
+     */
83
+    static function xmlDeserialize(Reader $reader) {
84
+        $elems = $reader->parseInnerTree([
85
+            '{http://nextcloud.com/ns}comp-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
86
+            '{http://nextcloud.com/ns}prop-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
87
+            '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
88
+            '{http://nextcloud.com/ns}search-term'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
89
+            '{http://nextcloud.com/ns}limit'        => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
90
+            '{http://nextcloud.com/ns}offset'       => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
91
+            '{DAV:}prop'                            => 'Sabre\\Xml\\Element\\KeyValue',
92
+        ]);
93
+
94
+        $newProps = [
95
+            'filters'    => [],
96
+            'properties' => [],
97
+            'limit'      => null,
98
+            'offset'     => null
99
+        ];
100
+
101
+        if (!is_array($elems)) {
102
+            $elems = [];
103
+        }
104
+
105
+        foreach ($elems as $elem) {
106
+            switch ($elem['name']) {
107
+                case '{DAV:}prop':
108
+                    $newProps['properties'] = array_keys($elem['value']);
109
+                    break;
110
+                case '{' . SearchPlugin::NS_Nextcloud . '}filter':
111
+                    foreach ($elem['value'] as $subElem) {
112
+                        if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
113
+                            if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114
+                                $newProps['filters']['comps'] = [];
115
+                            }
116
+                            $newProps['filters']['comps'][] = $subElem['value'];
117
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
118
+                            if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119
+                                $newProps['filters']['props'] = [];
120
+                            }
121
+                            $newProps['filters']['props'][] = $subElem['value'];
122
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
123
+                            if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124
+                                $newProps['filters']['params'] = [];
125
+                            }
126
+                            $newProps['filters']['params'][] = $subElem['value'];
127
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
128
+                            $newProps['filters']['search-term'] = $subElem['value'];
129
+                        }
130
+                    }
131
+                    break;
132
+                case '{' . SearchPlugin::NS_Nextcloud . '}limit':
133
+                    $newProps['limit'] = $elem['value'];
134
+                    break;
135
+                case '{' . SearchPlugin::NS_Nextcloud . '}offset':
136
+                    $newProps['offset'] = $elem['value'];
137
+                    break;
138
+
139
+            }
140
+        }
141
+
142
+        if (empty($newProps['filters'])) {
143
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
144
+        }
145
+
146
+        $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147
+        $noCompsDefined = empty($newProps['filters']['comps']);
148
+        if ($propsOrParamsDefined && $noCompsDefined) {
149
+            throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
150
+        }
151
+
152
+        if (!isset($newProps['filters']['search-term'])) {
153
+            throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
154
+        }
155
+
156
+        if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
+            throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
158
+        }
159
+
160
+
161
+        $obj = new self();
162
+        foreach ($newProps as $key => $value) {
163
+            $obj->$key = $value;
164
+        }
165
+        return $obj;
166
+    }
167 167
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -107,32 +107,32 @@  discard block
 block discarded – undo
107 107
 				case '{DAV:}prop':
108 108
 					$newProps['properties'] = array_keys($elem['value']);
109 109
 					break;
110
-				case '{' . SearchPlugin::NS_Nextcloud . '}filter':
110
+				case '{'.SearchPlugin::NS_Nextcloud.'}filter':
111 111
 					foreach ($elem['value'] as $subElem) {
112
-						if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
112
+						if ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}comp-filter') {
113 113
 							if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114 114
 								$newProps['filters']['comps'] = [];
115 115
 							}
116 116
 							$newProps['filters']['comps'][] = $subElem['value'];
117
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
117
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}prop-filter') {
118 118
 							if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119 119
 								$newProps['filters']['props'] = [];
120 120
 							}
121 121
 							$newProps['filters']['props'][] = $subElem['value'];
122
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
122
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}param-filter') {
123 123
 							if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124 124
 								$newProps['filters']['params'] = [];
125 125
 							}
126 126
 							$newProps['filters']['params'][] = $subElem['value'];
127
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
127
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}search-term') {
128 128
 							$newProps['filters']['search-term'] = $subElem['value'];
129 129
 						}
130 130
 					}
131 131
 					break;
132
-				case '{' . SearchPlugin::NS_Nextcloud . '}limit':
132
+				case '{'.SearchPlugin::NS_Nextcloud.'}limit':
133 133
 					$newProps['limit'] = $elem['value'];
134 134
 					break;
135
-				case '{' . SearchPlugin::NS_Nextcloud . '}offset':
135
+				case '{'.SearchPlugin::NS_Nextcloud.'}offset':
136 136
 					$newProps['offset'] = $elem['value'];
137 137
 					break;
138 138
 
@@ -140,21 +140,21 @@  discard block
 block discarded – undo
140 140
 		}
141 141
 
142 142
 		if (empty($newProps['filters'])) {
143
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
143
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}filter element is required for this request');
144 144
 		}
145 145
 
146 146
 		$propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147 147
 		$noCompsDefined = empty($newProps['filters']['comps']);
148 148
 		if ($propsOrParamsDefined && $noCompsDefined) {
149
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
149
+			throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter given without any {'.SearchPlugin::NS_Nextcloud.'}comp-filter');
150 150
 		}
151 151
 
152 152
 		if (!isset($newProps['filters']['search-term'])) {
153
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
153
+			throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}search-term is required for this request');
154 154
 		}
155 155
 
156 156
 		if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
-			throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
157
+			throw new BadRequest('At least one{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter is required for this request');
158 158
 		}
159 159
 
160 160
 
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Filter/CompFilter.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@
 block discarded – undo
27 27
 
28 28
 class CompFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return string
34
-	 */
35
-	static function xmlDeserialize(Reader $reader) {
36
-		$att = $reader->parseAttributes();
37
-		$componentName = $att['name'];
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return string
34
+     */
35
+    static function xmlDeserialize(Reader $reader) {
36
+        $att = $reader->parseAttributes();
37
+        $componentName = $att['name'];
38 38
 
39
-		$reader->parseInnerTree();
39
+        $reader->parseInnerTree();
40 40
 
41
-		if (!is_string($componentName)) {
42
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute');
43
-		}
41
+        if (!is_string($componentName)) {
42
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute');
43
+        }
44 44
 
45
-		return $componentName;
46
-	}
45
+        return $componentName;
46
+    }
47 47
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 		$reader->parseInnerTree();
40 40
 
41 41
 		if (!is_string($componentName)) {
42
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute');
42
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}comp-filter requires a valid name attribute');
43 43
 		}
44 44
 
45 45
 		return $componentName;
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Filter/SearchTermFilter.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,17 +27,17 @@
 block discarded – undo
27 27
 
28 28
 class SearchTermFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return string
34
-	 */
35
-	static function xmlDeserialize(Reader $reader) {
36
-		$value = $reader->parseInnerTree();
37
-		if (!is_string($value)) {
38
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value');
39
-		}
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return string
34
+     */
35
+    static function xmlDeserialize(Reader $reader) {
36
+        $value = $reader->parseInnerTree();
37
+        if (!is_string($value)) {
38
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value');
39
+        }
40 40
 
41
-		return $value;
42
-	}
41
+        return $value;
42
+    }
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 	static function xmlDeserialize(Reader $reader) {
36 36
 		$value = $reader->parseInnerTree();
37 37
 		if (!is_string($value)) {
38
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value');
38
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}search-term has illegal value');
39 39
 		}
40 40
 
41 41
 		return $value;
Please login to merge, or discard this patch.