Completed
Push — master ( 247b25...4111bd )
by Thomas
26:36 queued 10s
created
apps/dav/lib/Upload/AssemblyStream.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 		$this->loadContext('assembly');
74 74
 
75 75
 		$nodes = $this->nodes;
76
-		usort($nodes, function (IFile $a, IFile $b) {
76
+		usort($nodes, function(IFile $a, IFile $b) {
77 77
 			return strnatcmp($a->getName(), $b->getName());
78 78
 		});
79 79
 		$this->nodes = array_values($nodes);
80
-		$this->size = array_reduce($this->nodes, function ($size, IFile $file) {
80
+		$this->size = array_reduce($this->nodes, function($size, IFile $file) {
81 81
 			return $size + $file->getSize();
82 82
 		}, 0);
83 83
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 				fclose($this->currentStream);
157 157
 				$currentNodeSize = $this->nodes[$this->currentNode]->getSize();
158 158
 				if ($this->currentNodeRead < $currentNodeSize) {
159
-					throw new \Exception('Stream from assembly node shorter than expected, got ' . $this->currentNodeRead . ' bytes, expected ' . $currentNodeSize);
159
+					throw new \Exception('Stream from assembly node shorter than expected, got '.$this->currentNodeRead.' bytes, expected '.$currentNodeSize);
160 160
 				}
161 161
 				$this->currentNode++;
162 162
 				$this->currentNodeRead = 0;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 		if (isset($context[$name])) {
254 254
 			$context = $context[$name];
255 255
 		} else {
256
-			throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
256
+			throw new \BadMethodCallException('Invalid context, "'.$name.'" options not set');
257 257
 		}
258 258
 		if (isset($context['nodes']) and is_array($context['nodes'])) {
259 259
 			$this->nodes = $context['nodes'];
Please login to merge, or discard this patch.
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -20,270 +20,270 @@
 block discarded – undo
20 20
  */
21 21
 class AssemblyStream implements \Icewind\Streams\File {
22 22
 
23
-	/** @var resource */
24
-	private $context;
25
-
26
-	/** @var IFile[] */
27
-	private $nodes;
28
-
29
-	/** @var int */
30
-	private $pos = 0;
31
-
32
-	/** @var int */
33
-	private $size = 0;
34
-
35
-	/** @var resource */
36
-	private $currentStream = null;
37
-
38
-	/** @var int */
39
-	private $currentNode = 0;
40
-
41
-	/** @var int */
42
-	private $currentNodeRead = 0;
43
-
44
-	/**
45
-	 * @param string $path
46
-	 * @param string $mode
47
-	 * @param int $options
48
-	 * @param string &$opened_path
49
-	 * @return bool
50
-	 */
51
-	public function stream_open($path, $mode, $options, &$opened_path) {
52
-		$this->loadContext('assembly');
53
-
54
-		$nodes = $this->nodes;
55
-		usort($nodes, function (IFile $a, IFile $b) {
56
-			return strnatcmp($a->getName(), $b->getName());
57
-		});
58
-		$this->nodes = array_values($nodes);
59
-		$this->size = array_reduce($this->nodes, function ($size, IFile $file) {
60
-			return $size + $file->getSize();
61
-		}, 0);
62
-
63
-		return true;
64
-	}
65
-
66
-	/**
67
-	 * @param int $offset
68
-	 * @param int $whence
69
-	 * @return bool
70
-	 */
71
-	public function stream_seek($offset, $whence = SEEK_SET) {
72
-		if ($whence === SEEK_CUR) {
73
-			$offset = $this->stream_tell() + $offset;
74
-		} elseif ($whence === SEEK_END) {
75
-			$offset = $this->size + $offset;
76
-		}
77
-
78
-		if ($offset === $this->pos) {
79
-			return true;
80
-		}
81
-
82
-		if ($offset > $this->size) {
83
-			return false;
84
-		}
85
-
86
-		$nodeIndex = 0;
87
-		$nodeStart = 0;
88
-		while (true) {
89
-			if (!isset($this->nodes[$nodeIndex + 1])) {
90
-				break;
91
-			}
92
-			$node = $this->nodes[$nodeIndex];
93
-			if ($nodeStart + $node->getSize() > $offset) {
94
-				break;
95
-			}
96
-			$nodeIndex++;
97
-			$nodeStart += $node->getSize();
98
-		}
99
-
100
-		$stream = $this->getStream($this->nodes[$nodeIndex]);
101
-		$nodeOffset = $offset - $nodeStart;
102
-		if ($nodeOffset > 0 && fseek($stream, $nodeOffset) === -1) {
103
-			return false;
104
-		}
105
-		$this->currentNode = $nodeIndex;
106
-		$this->currentNodeRead = $nodeOffset;
107
-		$this->currentStream = $stream;
108
-		$this->pos = $offset;
109
-
110
-		return true;
111
-	}
112
-
113
-	/**
114
-	 * @return int
115
-	 */
116
-	public function stream_tell() {
117
-		return $this->pos;
118
-	}
119
-
120
-	/**
121
-	 * @param int $count
122
-	 * @return string
123
-	 */
124
-	public function stream_read($count) {
125
-		if (is_null($this->currentStream)) {
126
-			if ($this->currentNode < count($this->nodes)) {
127
-				$this->currentStream = $this->getStream($this->nodes[$this->currentNode]);
128
-			} else {
129
-				return '';
130
-			}
131
-		}
132
-
133
-		$collectedData = '';
134
-		// read data until we either got all the data requested or there is no more stream left
135
-		while ($count > 0 && !is_null($this->currentStream)) {
136
-			$data = fread($this->currentStream, $count);
137
-			$read = strlen($data);
138
-
139
-			$count -= $read;
140
-			$collectedData .= $data;
141
-			$this->currentNodeRead += $read;
142
-
143
-			if (feof($this->currentStream)) {
144
-				fclose($this->currentStream);
145
-				$currentNodeSize = $this->nodes[$this->currentNode]->getSize();
146
-				if ($this->currentNodeRead < $currentNodeSize) {
147
-					throw new \Exception('Stream from assembly node shorter than expected, got ' . $this->currentNodeRead . ' bytes, expected ' . $currentNodeSize);
148
-				}
149
-				$this->currentNode++;
150
-				$this->currentNodeRead = 0;
151
-				if ($this->currentNode < count($this->nodes)) {
152
-					$this->currentStream = $this->getStream($this->nodes[$this->currentNode]);
153
-				} else {
154
-					$this->currentStream = null;
155
-				}
156
-			}
157
-		}
158
-
159
-		// update position
160
-		$this->pos += strlen($collectedData);
161
-		return $collectedData;
162
-	}
163
-
164
-	/**
165
-	 * @param string $data
166
-	 * @return int
167
-	 */
168
-	public function stream_write($data) {
169
-		return false;
170
-	}
171
-
172
-	/**
173
-	 * @param int $option
174
-	 * @param int $arg1
175
-	 * @param int $arg2
176
-	 * @return bool
177
-	 */
178
-	public function stream_set_option($option, $arg1, $arg2) {
179
-		return false;
180
-	}
181
-
182
-	/**
183
-	 * @param int $size
184
-	 * @return bool
185
-	 */
186
-	public function stream_truncate($size) {
187
-		return false;
188
-	}
189
-
190
-	/**
191
-	 * @return array
192
-	 */
193
-	public function stream_stat() {
194
-		return [
195
-			'size' => $this->size,
196
-		];
197
-	}
198
-
199
-	/**
200
-	 * @param int $operation
201
-	 * @return bool
202
-	 */
203
-	public function stream_lock($operation) {
204
-		return false;
205
-	}
206
-
207
-	/**
208
-	 * @return bool
209
-	 */
210
-	public function stream_flush() {
211
-		return false;
212
-	}
213
-
214
-	/**
215
-	 * @return bool
216
-	 */
217
-	public function stream_eof() {
218
-		return $this->pos >= $this->size || ($this->currentNode >= count($this->nodes) && $this->currentNode === null);
219
-	}
220
-
221
-	/**
222
-	 * @return bool
223
-	 */
224
-	public function stream_close() {
225
-		return true;
226
-	}
227
-
228
-
229
-	/**
230
-	 * Load the source from the stream context and return the context options
231
-	 *
232
-	 * @param string $name
233
-	 * @return array
234
-	 * @throws \BadMethodCallException
235
-	 */
236
-	protected function loadContext($name) {
237
-		$context = stream_context_get_options($this->context);
238
-		if (isset($context[$name])) {
239
-			$context = $context[$name];
240
-		} else {
241
-			throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
242
-		}
243
-		if (isset($context['nodes']) and is_array($context['nodes'])) {
244
-			$this->nodes = $context['nodes'];
245
-		} else {
246
-			throw new \BadMethodCallException('Invalid context, nodes not set');
247
-		}
248
-		return $context;
249
-	}
250
-
251
-	/**
252
-	 * @param IFile[] $nodes
253
-	 * @return resource
254
-	 *
255
-	 * @throws \BadMethodCallException
256
-	 */
257
-	public static function wrap(array $nodes) {
258
-		$context = stream_context_create([
259
-			'assembly' => [
260
-				'nodes' => $nodes
261
-			]
262
-		]);
263
-		stream_wrapper_register('assembly', self::class);
264
-		try {
265
-			$wrapped = fopen('assembly://', 'r', false, $context);
266
-		} catch (\BadMethodCallException $e) {
267
-			stream_wrapper_unregister('assembly');
268
-			throw $e;
269
-		}
270
-		stream_wrapper_unregister('assembly');
271
-		return $wrapped;
272
-	}
273
-
274
-	/**
275
-	 * @param IFile $node
276
-	 * @return resource
277
-	 */
278
-	private function getStream(IFile $node) {
279
-		$data = $node->get();
280
-		if (is_resource($data)) {
281
-			return $data;
282
-		} else {
283
-			$tmp = fopen('php://temp', 'w+');
284
-			fwrite($tmp, $data);
285
-			rewind($tmp);
286
-			return $tmp;
287
-		}
288
-	}
23
+    /** @var resource */
24
+    private $context;
25
+
26
+    /** @var IFile[] */
27
+    private $nodes;
28
+
29
+    /** @var int */
30
+    private $pos = 0;
31
+
32
+    /** @var int */
33
+    private $size = 0;
34
+
35
+    /** @var resource */
36
+    private $currentStream = null;
37
+
38
+    /** @var int */
39
+    private $currentNode = 0;
40
+
41
+    /** @var int */
42
+    private $currentNodeRead = 0;
43
+
44
+    /**
45
+     * @param string $path
46
+     * @param string $mode
47
+     * @param int $options
48
+     * @param string &$opened_path
49
+     * @return bool
50
+     */
51
+    public function stream_open($path, $mode, $options, &$opened_path) {
52
+        $this->loadContext('assembly');
53
+
54
+        $nodes = $this->nodes;
55
+        usort($nodes, function (IFile $a, IFile $b) {
56
+            return strnatcmp($a->getName(), $b->getName());
57
+        });
58
+        $this->nodes = array_values($nodes);
59
+        $this->size = array_reduce($this->nodes, function ($size, IFile $file) {
60
+            return $size + $file->getSize();
61
+        }, 0);
62
+
63
+        return true;
64
+    }
65
+
66
+    /**
67
+     * @param int $offset
68
+     * @param int $whence
69
+     * @return bool
70
+     */
71
+    public function stream_seek($offset, $whence = SEEK_SET) {
72
+        if ($whence === SEEK_CUR) {
73
+            $offset = $this->stream_tell() + $offset;
74
+        } elseif ($whence === SEEK_END) {
75
+            $offset = $this->size + $offset;
76
+        }
77
+
78
+        if ($offset === $this->pos) {
79
+            return true;
80
+        }
81
+
82
+        if ($offset > $this->size) {
83
+            return false;
84
+        }
85
+
86
+        $nodeIndex = 0;
87
+        $nodeStart = 0;
88
+        while (true) {
89
+            if (!isset($this->nodes[$nodeIndex + 1])) {
90
+                break;
91
+            }
92
+            $node = $this->nodes[$nodeIndex];
93
+            if ($nodeStart + $node->getSize() > $offset) {
94
+                break;
95
+            }
96
+            $nodeIndex++;
97
+            $nodeStart += $node->getSize();
98
+        }
99
+
100
+        $stream = $this->getStream($this->nodes[$nodeIndex]);
101
+        $nodeOffset = $offset - $nodeStart;
102
+        if ($nodeOffset > 0 && fseek($stream, $nodeOffset) === -1) {
103
+            return false;
104
+        }
105
+        $this->currentNode = $nodeIndex;
106
+        $this->currentNodeRead = $nodeOffset;
107
+        $this->currentStream = $stream;
108
+        $this->pos = $offset;
109
+
110
+        return true;
111
+    }
112
+
113
+    /**
114
+     * @return int
115
+     */
116
+    public function stream_tell() {
117
+        return $this->pos;
118
+    }
119
+
120
+    /**
121
+     * @param int $count
122
+     * @return string
123
+     */
124
+    public function stream_read($count) {
125
+        if (is_null($this->currentStream)) {
126
+            if ($this->currentNode < count($this->nodes)) {
127
+                $this->currentStream = $this->getStream($this->nodes[$this->currentNode]);
128
+            } else {
129
+                return '';
130
+            }
131
+        }
132
+
133
+        $collectedData = '';
134
+        // read data until we either got all the data requested or there is no more stream left
135
+        while ($count > 0 && !is_null($this->currentStream)) {
136
+            $data = fread($this->currentStream, $count);
137
+            $read = strlen($data);
138
+
139
+            $count -= $read;
140
+            $collectedData .= $data;
141
+            $this->currentNodeRead += $read;
142
+
143
+            if (feof($this->currentStream)) {
144
+                fclose($this->currentStream);
145
+                $currentNodeSize = $this->nodes[$this->currentNode]->getSize();
146
+                if ($this->currentNodeRead < $currentNodeSize) {
147
+                    throw new \Exception('Stream from assembly node shorter than expected, got ' . $this->currentNodeRead . ' bytes, expected ' . $currentNodeSize);
148
+                }
149
+                $this->currentNode++;
150
+                $this->currentNodeRead = 0;
151
+                if ($this->currentNode < count($this->nodes)) {
152
+                    $this->currentStream = $this->getStream($this->nodes[$this->currentNode]);
153
+                } else {
154
+                    $this->currentStream = null;
155
+                }
156
+            }
157
+        }
158
+
159
+        // update position
160
+        $this->pos += strlen($collectedData);
161
+        return $collectedData;
162
+    }
163
+
164
+    /**
165
+     * @param string $data
166
+     * @return int
167
+     */
168
+    public function stream_write($data) {
169
+        return false;
170
+    }
171
+
172
+    /**
173
+     * @param int $option
174
+     * @param int $arg1
175
+     * @param int $arg2
176
+     * @return bool
177
+     */
178
+    public function stream_set_option($option, $arg1, $arg2) {
179
+        return false;
180
+    }
181
+
182
+    /**
183
+     * @param int $size
184
+     * @return bool
185
+     */
186
+    public function stream_truncate($size) {
187
+        return false;
188
+    }
189
+
190
+    /**
191
+     * @return array
192
+     */
193
+    public function stream_stat() {
194
+        return [
195
+            'size' => $this->size,
196
+        ];
197
+    }
198
+
199
+    /**
200
+     * @param int $operation
201
+     * @return bool
202
+     */
203
+    public function stream_lock($operation) {
204
+        return false;
205
+    }
206
+
207
+    /**
208
+     * @return bool
209
+     */
210
+    public function stream_flush() {
211
+        return false;
212
+    }
213
+
214
+    /**
215
+     * @return bool
216
+     */
217
+    public function stream_eof() {
218
+        return $this->pos >= $this->size || ($this->currentNode >= count($this->nodes) && $this->currentNode === null);
219
+    }
220
+
221
+    /**
222
+     * @return bool
223
+     */
224
+    public function stream_close() {
225
+        return true;
226
+    }
227
+
228
+
229
+    /**
230
+     * Load the source from the stream context and return the context options
231
+     *
232
+     * @param string $name
233
+     * @return array
234
+     * @throws \BadMethodCallException
235
+     */
236
+    protected function loadContext($name) {
237
+        $context = stream_context_get_options($this->context);
238
+        if (isset($context[$name])) {
239
+            $context = $context[$name];
240
+        } else {
241
+            throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set');
242
+        }
243
+        if (isset($context['nodes']) and is_array($context['nodes'])) {
244
+            $this->nodes = $context['nodes'];
245
+        } else {
246
+            throw new \BadMethodCallException('Invalid context, nodes not set');
247
+        }
248
+        return $context;
249
+    }
250
+
251
+    /**
252
+     * @param IFile[] $nodes
253
+     * @return resource
254
+     *
255
+     * @throws \BadMethodCallException
256
+     */
257
+    public static function wrap(array $nodes) {
258
+        $context = stream_context_create([
259
+            'assembly' => [
260
+                'nodes' => $nodes
261
+            ]
262
+        ]);
263
+        stream_wrapper_register('assembly', self::class);
264
+        try {
265
+            $wrapped = fopen('assembly://', 'r', false, $context);
266
+        } catch (\BadMethodCallException $e) {
267
+            stream_wrapper_unregister('assembly');
268
+            throw $e;
269
+        }
270
+        stream_wrapper_unregister('assembly');
271
+        return $wrapped;
272
+    }
273
+
274
+    /**
275
+     * @param IFile $node
276
+     * @return resource
277
+     */
278
+    private function getStream(IFile $node) {
279
+        $data = $node->get();
280
+        if (is_resource($data)) {
281
+            return $data;
282
+        } else {
283
+            $tmp = fopen('php://temp', 'w+');
284
+            fwrite($tmp, $data);
285
+            rewind($tmp);
286
+            return $tmp;
287
+        }
288
+    }
289 289
 }
Please login to merge, or discard this patch.
apps/dav/lib/Settings/CalDAVSettings.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
 
86 86
 	public function getAuthorizedAppConfig(): array {
87 87
 		return [
88
-			'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/']
88
+			'dav' => ['/('.implode('|', array_keys(self::defaults)).')/']
89 89
 		];
90 90
 	}
91 91
 }
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -15,59 +15,59 @@
 block discarded – undo
15 15
 
16 16
 class CalDAVSettings implements IDelegatedSettings {
17 17
 
18
-	private const defaults = [
19
-		'sendInvitations' => 'yes',
20
-		'generateBirthdayCalendar' => 'yes',
21
-		'sendEventReminders' => 'yes',
22
-		'sendEventRemindersToSharedUsers' => 'yes',
23
-		'sendEventRemindersPush' => 'yes',
24
-	];
18
+    private const defaults = [
19
+        'sendInvitations' => 'yes',
20
+        'generateBirthdayCalendar' => 'yes',
21
+        'sendEventReminders' => 'yes',
22
+        'sendEventRemindersToSharedUsers' => 'yes',
23
+        'sendEventRemindersPush' => 'yes',
24
+    ];
25 25
 
26
-	/**
27
-	 * CalDAVSettings constructor.
28
-	 *
29
-	 * @param IConfig $config
30
-	 * @param IInitialState $initialState
31
-	 */
32
-	public function __construct(
33
-		private IConfig $config,
34
-		private IInitialState $initialState,
35
-		private IURLGenerator $urlGenerator,
36
-		private IAppManager $appManager,
37
-	) {
38
-	}
26
+    /**
27
+     * CalDAVSettings constructor.
28
+     *
29
+     * @param IConfig $config
30
+     * @param IInitialState $initialState
31
+     */
32
+    public function __construct(
33
+        private IConfig $config,
34
+        private IInitialState $initialState,
35
+        private IURLGenerator $urlGenerator,
36
+        private IAppManager $appManager,
37
+    ) {
38
+    }
39 39
 
40
-	public function getForm(): TemplateResponse {
41
-		$this->initialState->provideInitialState('userSyncCalendarsDocUrl', $this->urlGenerator->linkToDocs('user-sync-calendars'));
42
-		foreach (self::defaults as $key => $default) {
43
-			$value = $this->config->getAppValue(Application::APP_ID, $key, $default);
44
-			$this->initialState->provideInitialState($key, $value === 'yes');
45
-		}
46
-		return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav');
47
-	}
40
+    public function getForm(): TemplateResponse {
41
+        $this->initialState->provideInitialState('userSyncCalendarsDocUrl', $this->urlGenerator->linkToDocs('user-sync-calendars'));
42
+        foreach (self::defaults as $key => $default) {
43
+            $value = $this->config->getAppValue(Application::APP_ID, $key, $default);
44
+            $this->initialState->provideInitialState($key, $value === 'yes');
45
+        }
46
+        return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav');
47
+    }
48 48
 
49
-	public function getSection(): ?string {
50
-		if (!$this->appManager->isBackendRequired(IAppManager::BACKEND_CALDAV)) {
51
-			return null;
52
-		}
49
+    public function getSection(): ?string {
50
+        if (!$this->appManager->isBackendRequired(IAppManager::BACKEND_CALDAV)) {
51
+            return null;
52
+        }
53 53
 
54
-		return 'groupware';
55
-	}
54
+        return 'groupware';
55
+    }
56 56
 
57
-	/**
58
-	 * @return int
59
-	 */
60
-	public function getPriority() {
61
-		return 10;
62
-	}
57
+    /**
58
+     * @return int
59
+     */
60
+    public function getPriority() {
61
+        return 10;
62
+    }
63 63
 
64
-	public function getName(): ?string {
65
-		return null; // Only setting in this section
66
-	}
64
+    public function getName(): ?string {
65
+        return null; // Only setting in this section
66
+    }
67 67
 
68
-	public function getAuthorizedAppConfig(): array {
69
-		return [
70
-			'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/']
71
-		];
72
-	}
68
+    public function getAuthorizedAppConfig(): array {
69
+        return [
70
+            'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/']
71
+        ];
72
+    }
73 73
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/PagedResults/TLinkId.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,18 +27,18 @@
 block discarded – undo
27 27
 namespace OCA\User_LDAP\PagedResults;
28 28
 
29 29
 trait TLinkId {
30
-	public function getLinkId($link) {
31
-		if (is_object($link)) {
32
-			return spl_object_id($link);
33
-		} elseif (is_resource($link)) {
34
-			return (int)$link;
35
-		} elseif (is_array($link) && isset($link[0])) {
36
-			if (is_object($link[0])) {
37
-				return spl_object_id($link[0]);
38
-			} elseif (is_resource($link[0])) {
39
-				return (int)$link[0];
40
-			}
41
-		}
42
-		throw new \RuntimeException('No resource provided');
43
-	}
30
+    public function getLinkId($link) {
31
+        if (is_object($link)) {
32
+            return spl_object_id($link);
33
+        } elseif (is_resource($link)) {
34
+            return (int)$link;
35
+        } elseif (is_array($link) && isset($link[0])) {
36
+            if (is_object($link[0])) {
37
+                return spl_object_id($link[0]);
38
+            } elseif (is_resource($link[0])) {
39
+                return (int)$link[0];
40
+            }
41
+        }
42
+        throw new \RuntimeException('No resource provided');
43
+    }
44 44
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@
 block discarded – undo
31 31
 		if (is_object($link)) {
32 32
 			return spl_object_id($link);
33 33
 		} elseif (is_resource($link)) {
34
-			return (int)$link;
34
+			return (int) $link;
35 35
 		} elseif (is_array($link) && isset($link[0])) {
36 36
 			if (is_object($link[0])) {
37 37
 				return spl_object_id($link[0]);
38 38
 			} elseif (is_resource($link[0])) {
39
-				return (int)$link[0];
39
+				return (int) $link[0];
40 40
 			}
41 41
 		}
42 42
 		throw new \RuntimeException('No resource provided');
Please login to merge, or discard this patch.
apps/workflowengine/lib/Controller/AWorkflowController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		} catch (\DomainException $e) {
150 150
 			throw new OCSForbiddenException($e->getMessage(), $e);
151 151
 		} catch (Exception $e) {
152
-			$this->logger->error('Error when updating flow with id ' . $id, ['exception' => $e]);
152
+			$this->logger->error('Error when updating flow with id '.$id, ['exception' => $e]);
153 153
 			throw new OCSException('An internal error occurred', $e->getCode(), $e);
154 154
 		}
155 155
 	}
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		} catch (\DomainException $e) {
169 169
 			throw new OCSForbiddenException($e->getMessage(), $e);
170 170
 		} catch (Exception $e) {
171
-			$this->logger->error('Error when deleting flow with id ' . $id, ['exception' => $e]);
171
+			$this->logger->error('Error when deleting flow with id '.$id, ['exception' => $e]);
172 172
 			throw new OCSException('An internal error occurred', $e->getCode(), $e);
173 173
 		}
174 174
 	}
Please login to merge, or discard this patch.
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -22,130 +22,130 @@
 block discarded – undo
22 22
 
23 23
 abstract class AWorkflowController extends OCSController {
24 24
 
25
-	public function __construct(
26
-		$appName,
27
-		IRequest $request,
28
-		protected Manager $manager,
29
-		private LoggerInterface $logger,
30
-	) {
31
-		parent::__construct($appName, $request);
32
-	}
33
-
34
-	/**
35
-	 * @throws OCSForbiddenException
36
-	 */
37
-	abstract protected function getScopeContext(): ScopeContext;
38
-
39
-	/**
40
-	 * Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/global?format=json"
41
-	 *
42
-	 * @throws OCSForbiddenException
43
-	 */
44
-	public function index(): DataResponse {
45
-		$operationsByClass = $this->manager->getAllOperations($this->getScopeContext());
46
-
47
-		foreach ($operationsByClass as &$operations) {
48
-			foreach ($operations as &$operation) {
49
-				$operation = $this->manager->formatOperation($operation);
50
-			}
51
-		}
52
-
53
-		return new DataResponse($operationsByClass);
54
-	}
55
-
56
-	/**
57
-	 * Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/global/OCA\\Workflow_DocToPdf\\Operation?format=json"
58
-	 *
59
-	 * @throws OCSForbiddenException
60
-	 */
61
-	public function show(string $id): DataResponse {
62
-		$context = $this->getScopeContext();
63
-
64
-		// The ID corresponds to a class name
65
-		$operations = $this->manager->getOperations($id, $context);
66
-
67
-		foreach ($operations as &$operation) {
68
-			$operation = $this->manager->formatOperation($operation);
69
-		}
70
-
71
-		return new DataResponse($operations);
72
-	}
73
-
74
-	/**
75
-	 * @throws OCSBadRequestException
76
-	 * @throws OCSForbiddenException
77
-	 * @throws OCSException
78
-	 */
79
-	#[PasswordConfirmationRequired]
80
-	public function create(
81
-		string $class,
82
-		string $name,
83
-		array $checks,
84
-		string $operation,
85
-		string $entity,
86
-		array $events,
87
-	): DataResponse {
88
-		$context = $this->getScopeContext();
89
-		try {
90
-			$operation = $this->manager->addOperation($class, $name, $checks, $operation, $context, $entity, $events);
91
-			$operation = $this->manager->formatOperation($operation);
92
-			return new DataResponse($operation);
93
-		} catch (\UnexpectedValueException $e) {
94
-			throw new OCSBadRequestException($e->getMessage(), $e);
95
-		} catch (\DomainException $e) {
96
-			throw new OCSForbiddenException($e->getMessage(), $e);
97
-		} catch (Exception $e) {
98
-			$this->logger->error('Error when inserting flow', ['exception' => $e]);
99
-			throw new OCSException('An internal error occurred', $e->getCode(), $e);
100
-		}
101
-	}
102
-
103
-	/**
104
-	 * @throws OCSBadRequestException
105
-	 * @throws OCSForbiddenException
106
-	 * @throws OCSException
107
-	 */
108
-	#[PasswordConfirmationRequired]
109
-	public function update(
110
-		int $id,
111
-		string $name,
112
-		array $checks,
113
-		string $operation,
114
-		string $entity,
115
-		array $events,
116
-	): DataResponse {
117
-		try {
118
-			$context = $this->getScopeContext();
119
-			$operation = $this->manager->updateOperation($id, $name, $checks, $operation, $context, $entity, $events);
120
-			$operation = $this->manager->formatOperation($operation);
121
-			return new DataResponse($operation);
122
-		} catch (\UnexpectedValueException $e) {
123
-			throw new OCSBadRequestException($e->getMessage(), $e);
124
-		} catch (\DomainException $e) {
125
-			throw new OCSForbiddenException($e->getMessage(), $e);
126
-		} catch (Exception $e) {
127
-			$this->logger->error('Error when updating flow with id ' . $id, ['exception' => $e]);
128
-			throw new OCSException('An internal error occurred', $e->getCode(), $e);
129
-		}
130
-	}
131
-
132
-	/**
133
-	 * @throws OCSBadRequestException
134
-	 * @throws OCSForbiddenException
135
-	 * @throws OCSException
136
-	 */
137
-	#[PasswordConfirmationRequired]
138
-	public function destroy(int $id): DataResponse {
139
-		try {
140
-			$deleted = $this->manager->deleteOperation($id, $this->getScopeContext());
141
-			return new DataResponse($deleted);
142
-		} catch (\UnexpectedValueException $e) {
143
-			throw new OCSBadRequestException($e->getMessage(), $e);
144
-		} catch (\DomainException $e) {
145
-			throw new OCSForbiddenException($e->getMessage(), $e);
146
-		} catch (Exception $e) {
147
-			$this->logger->error('Error when deleting flow with id ' . $id, ['exception' => $e]);
148
-			throw new OCSException('An internal error occurred', $e->getCode(), $e);
149
-		}
150
-	}
25
+    public function __construct(
26
+        $appName,
27
+        IRequest $request,
28
+        protected Manager $manager,
29
+        private LoggerInterface $logger,
30
+    ) {
31
+        parent::__construct($appName, $request);
32
+    }
33
+
34
+    /**
35
+     * @throws OCSForbiddenException
36
+     */
37
+    abstract protected function getScopeContext(): ScopeContext;
38
+
39
+    /**
40
+     * Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/global?format=json"
41
+     *
42
+     * @throws OCSForbiddenException
43
+     */
44
+    public function index(): DataResponse {
45
+        $operationsByClass = $this->manager->getAllOperations($this->getScopeContext());
46
+
47
+        foreach ($operationsByClass as &$operations) {
48
+            foreach ($operations as &$operation) {
49
+                $operation = $this->manager->formatOperation($operation);
50
+            }
51
+        }
52
+
53
+        return new DataResponse($operationsByClass);
54
+    }
55
+
56
+    /**
57
+     * Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/global/OCA\\Workflow_DocToPdf\\Operation?format=json"
58
+     *
59
+     * @throws OCSForbiddenException
60
+     */
61
+    public function show(string $id): DataResponse {
62
+        $context = $this->getScopeContext();
63
+
64
+        // The ID corresponds to a class name
65
+        $operations = $this->manager->getOperations($id, $context);
66
+
67
+        foreach ($operations as &$operation) {
68
+            $operation = $this->manager->formatOperation($operation);
69
+        }
70
+
71
+        return new DataResponse($operations);
72
+    }
73
+
74
+    /**
75
+     * @throws OCSBadRequestException
76
+     * @throws OCSForbiddenException
77
+     * @throws OCSException
78
+     */
79
+    #[PasswordConfirmationRequired]
80
+    public function create(
81
+        string $class,
82
+        string $name,
83
+        array $checks,
84
+        string $operation,
85
+        string $entity,
86
+        array $events,
87
+    ): DataResponse {
88
+        $context = $this->getScopeContext();
89
+        try {
90
+            $operation = $this->manager->addOperation($class, $name, $checks, $operation, $context, $entity, $events);
91
+            $operation = $this->manager->formatOperation($operation);
92
+            return new DataResponse($operation);
93
+        } catch (\UnexpectedValueException $e) {
94
+            throw new OCSBadRequestException($e->getMessage(), $e);
95
+        } catch (\DomainException $e) {
96
+            throw new OCSForbiddenException($e->getMessage(), $e);
97
+        } catch (Exception $e) {
98
+            $this->logger->error('Error when inserting flow', ['exception' => $e]);
99
+            throw new OCSException('An internal error occurred', $e->getCode(), $e);
100
+        }
101
+    }
102
+
103
+    /**
104
+     * @throws OCSBadRequestException
105
+     * @throws OCSForbiddenException
106
+     * @throws OCSException
107
+     */
108
+    #[PasswordConfirmationRequired]
109
+    public function update(
110
+        int $id,
111
+        string $name,
112
+        array $checks,
113
+        string $operation,
114
+        string $entity,
115
+        array $events,
116
+    ): DataResponse {
117
+        try {
118
+            $context = $this->getScopeContext();
119
+            $operation = $this->manager->updateOperation($id, $name, $checks, $operation, $context, $entity, $events);
120
+            $operation = $this->manager->formatOperation($operation);
121
+            return new DataResponse($operation);
122
+        } catch (\UnexpectedValueException $e) {
123
+            throw new OCSBadRequestException($e->getMessage(), $e);
124
+        } catch (\DomainException $e) {
125
+            throw new OCSForbiddenException($e->getMessage(), $e);
126
+        } catch (Exception $e) {
127
+            $this->logger->error('Error when updating flow with id ' . $id, ['exception' => $e]);
128
+            throw new OCSException('An internal error occurred', $e->getCode(), $e);
129
+        }
130
+    }
131
+
132
+    /**
133
+     * @throws OCSBadRequestException
134
+     * @throws OCSForbiddenException
135
+     * @throws OCSException
136
+     */
137
+    #[PasswordConfirmationRequired]
138
+    public function destroy(int $id): DataResponse {
139
+        try {
140
+            $deleted = $this->manager->deleteOperation($id, $this->getScopeContext());
141
+            return new DataResponse($deleted);
142
+        } catch (\UnexpectedValueException $e) {
143
+            throw new OCSBadRequestException($e->getMessage(), $e);
144
+        } catch (\DomainException $e) {
145
+            throw new OCSForbiddenException($e->getMessage(), $e);
146
+        } catch (Exception $e) {
147
+            $this->logger->error('Error when deleting flow with id ' . $id, ['exception' => $e]);
148
+            throw new OCSException('An internal error occurred', $e->getCode(), $e);
149
+        }
150
+    }
151 151
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Migration/Version2000Date20190808074233.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -39,117 +39,117 @@
 block discarded – undo
39 39
 
40 40
 class Version2000Date20190808074233 extends SimpleMigrationStep {
41 41
 
42
-	/**
43
-	 * @param IOutput $output
44
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
45
-	 * @param array $options
46
-	 * @return null|ISchemaWrapper
47
-	 */
48
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
49
-		/** @var ISchemaWrapper $schema */
50
-		$schema = $schemaClosure();
42
+    /**
43
+     * @param IOutput $output
44
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
45
+     * @param array $options
46
+     * @return null|ISchemaWrapper
47
+     */
48
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
49
+        /** @var ISchemaWrapper $schema */
50
+        $schema = $schemaClosure();
51 51
 
52
-		if (!$schema->hasTable('flow_checks')) {
53
-			$table = $schema->createTable('flow_checks');
54
-			$table->addColumn('id', Types::INTEGER, [
55
-				'autoincrement' => true,
56
-				'notnull' => true,
57
-				'length' => 4,
58
-			]);
59
-			$table->addColumn('class', Types::STRING, [
60
-				'notnull' => true,
61
-				'length' => 256,
62
-				'default' => '',
63
-			]);
64
-			$table->addColumn('operator', Types::STRING, [
65
-				'notnull' => true,
66
-				'length' => 16,
67
-				'default' => '',
68
-			]);
69
-			$table->addColumn('value', Types::TEXT, [
70
-				'notnull' => false,
71
-			]);
72
-			$table->addColumn('hash', Types::STRING, [
73
-				'notnull' => true,
74
-				'length' => 32,
75
-				'default' => '',
76
-			]);
77
-			$table->setPrimaryKey(['id']);
78
-			$table->addUniqueIndex(['hash'], 'flow_unique_hash');
79
-		}
52
+        if (!$schema->hasTable('flow_checks')) {
53
+            $table = $schema->createTable('flow_checks');
54
+            $table->addColumn('id', Types::INTEGER, [
55
+                'autoincrement' => true,
56
+                'notnull' => true,
57
+                'length' => 4,
58
+            ]);
59
+            $table->addColumn('class', Types::STRING, [
60
+                'notnull' => true,
61
+                'length' => 256,
62
+                'default' => '',
63
+            ]);
64
+            $table->addColumn('operator', Types::STRING, [
65
+                'notnull' => true,
66
+                'length' => 16,
67
+                'default' => '',
68
+            ]);
69
+            $table->addColumn('value', Types::TEXT, [
70
+                'notnull' => false,
71
+            ]);
72
+            $table->addColumn('hash', Types::STRING, [
73
+                'notnull' => true,
74
+                'length' => 32,
75
+                'default' => '',
76
+            ]);
77
+            $table->setPrimaryKey(['id']);
78
+            $table->addUniqueIndex(['hash'], 'flow_unique_hash');
79
+        }
80 80
 
81
-		if (!$schema->hasTable('flow_operations')) {
82
-			$table = $schema->createTable('flow_operations');
83
-			$table->addColumn('id', Types::INTEGER, [
84
-				'autoincrement' => true,
85
-				'notnull' => true,
86
-				'length' => 4,
87
-			]);
88
-			$table->addColumn('class', Types::STRING, [
89
-				'notnull' => true,
90
-				'length' => 256,
91
-				'default' => '',
92
-			]);
93
-			$table->addColumn('name', Types::STRING, [
94
-				'notnull' => false,
95
-				'length' => 256,
96
-				'default' => '',
97
-			]);
98
-			$table->addColumn('checks', Types::TEXT, [
99
-				'notnull' => false,
100
-			]);
101
-			$table->addColumn('operation', Types::TEXT, [
102
-				'notnull' => false,
103
-			]);
104
-			$this->ensureEntityColumns($table);
105
-			$table->setPrimaryKey(['id']);
106
-		} else {
107
-			$table = $schema->getTable('flow_operations');
108
-			$this->ensureEntityColumns($table);
109
-		}
81
+        if (!$schema->hasTable('flow_operations')) {
82
+            $table = $schema->createTable('flow_operations');
83
+            $table->addColumn('id', Types::INTEGER, [
84
+                'autoincrement' => true,
85
+                'notnull' => true,
86
+                'length' => 4,
87
+            ]);
88
+            $table->addColumn('class', Types::STRING, [
89
+                'notnull' => true,
90
+                'length' => 256,
91
+                'default' => '',
92
+            ]);
93
+            $table->addColumn('name', Types::STRING, [
94
+                'notnull' => false,
95
+                'length' => 256,
96
+                'default' => '',
97
+            ]);
98
+            $table->addColumn('checks', Types::TEXT, [
99
+                'notnull' => false,
100
+            ]);
101
+            $table->addColumn('operation', Types::TEXT, [
102
+                'notnull' => false,
103
+            ]);
104
+            $this->ensureEntityColumns($table);
105
+            $table->setPrimaryKey(['id']);
106
+        } else {
107
+            $table = $schema->getTable('flow_operations');
108
+            $this->ensureEntityColumns($table);
109
+        }
110 110
 
111
-		if (!$schema->hasTable('flow_operations_scope')) {
112
-			$table = $schema->createTable('flow_operations_scope');
113
-			$table->addColumn('id', Types::BIGINT, [
114
-				'autoincrement' => true,
115
-				'notnull' => true,
116
-				'length' => 4,
117
-			]);
118
-			$table->addColumn('operation_id', Types::INTEGER, [
119
-				'notnull' => true,
120
-				'length' => 4,
121
-				'default' => 0,
122
-			]);
123
-			$table->addColumn('type', Types::INTEGER, [
124
-				'notnull' => true,
125
-				'length' => 4,
126
-				'default' => 0,
127
-			]);
128
-			$table->addColumn('value', Types::STRING, [
129
-				'notnull' => false,
130
-				'length' => 64,
131
-				'default' => '',
132
-			]);
133
-			$table->setPrimaryKey(['id']);
134
-			$table->addUniqueIndex(['operation_id', 'type', 'value'], 'flow_unique_scope');
135
-		}
111
+        if (!$schema->hasTable('flow_operations_scope')) {
112
+            $table = $schema->createTable('flow_operations_scope');
113
+            $table->addColumn('id', Types::BIGINT, [
114
+                'autoincrement' => true,
115
+                'notnull' => true,
116
+                'length' => 4,
117
+            ]);
118
+            $table->addColumn('operation_id', Types::INTEGER, [
119
+                'notnull' => true,
120
+                'length' => 4,
121
+                'default' => 0,
122
+            ]);
123
+            $table->addColumn('type', Types::INTEGER, [
124
+                'notnull' => true,
125
+                'length' => 4,
126
+                'default' => 0,
127
+            ]);
128
+            $table->addColumn('value', Types::STRING, [
129
+                'notnull' => false,
130
+                'length' => 64,
131
+                'default' => '',
132
+            ]);
133
+            $table->setPrimaryKey(['id']);
134
+            $table->addUniqueIndex(['operation_id', 'type', 'value'], 'flow_unique_scope');
135
+        }
136 136
 
137
-		return $schema;
138
-	}
137
+        return $schema;
138
+    }
139 139
 
140
-	protected function ensureEntityColumns(Table $table) {
141
-		if (!$table->hasColumn('entity')) {
142
-			$table->addColumn('entity', Types::STRING, [
143
-				'notnull' => true,
144
-				'length' => 256,
145
-				'default' => File::class,
146
-			]);
147
-		}
148
-		if (!$table->hasColumn('events')) {
149
-			$table->addColumn('events', Types::TEXT, [
150
-				'notnull' => true,
151
-				'default' => '[]',
152
-			]);
153
-		}
154
-	}
140
+    protected function ensureEntityColumns(Table $table) {
141
+        if (!$table->hasColumn('entity')) {
142
+            $table->addColumn('entity', Types::STRING, [
143
+                'notnull' => true,
144
+                'length' => 256,
145
+                'default' => File::class,
146
+            ]);
147
+        }
148
+        if (!$table->hasColumn('events')) {
149
+            $table->addColumn('events', Types::TEXT, [
150
+                'notnull' => true,
151
+                'default' => '[]',
152
+            ]);
153
+        }
154
+    }
155 155
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Migration/Version2200Date20210805101925.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -32,23 +32,23 @@
 block discarded – undo
32 32
 
33 33
 class Version2200Date20210805101925 extends SimpleMigrationStep {
34 34
 
35
-	/**
36
-	 * @param IOutput $output
37
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
38
-	 * @param array $options
39
-	 * @return null|ISchemaWrapper
40
-	 */
41
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
42
-		/** @var ISchemaWrapper $schema */
43
-		$schema = $schemaClosure();
35
+    /**
36
+     * @param IOutput $output
37
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
38
+     * @param array $options
39
+     * @return null|ISchemaWrapper
40
+     */
41
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
42
+        /** @var ISchemaWrapper $schema */
43
+        $schema = $schemaClosure();
44 44
 
45
-		if ($schema->hasTable('flow_operations')) {
46
-			$table = $schema->getTable('flow_operations');
47
-			$table->changeColumn('name', [
48
-				'notnull' => false,
49
-			]);
50
-		}
45
+        if ($schema->hasTable('flow_operations')) {
46
+            $table = $schema->getTable('flow_operations');
47
+            $table->changeColumn('name', [
48
+                'notnull' => false,
49
+            ]);
50
+        }
51 51
 
52
-		return $schema;
53
-	}
52
+        return $schema;
53
+    }
54 54
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Migration/Version1015Date20211104103506.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -59,19 +59,19 @@
 block discarded – undo
59 59
 		}
60 60
 
61 61
 		while ($mount = $mounts->fetch()) {
62
-			$config = $this->getStorageConfig((int)$mount['mount_id']);
62
+			$config = $this->getStorageConfig((int) $mount['mount_id']);
63 63
 			$hostname = $config['hostname'];
64 64
 			$bucket = $config['bucket'];
65 65
 			$key = $config['key'];
66
-			$oldId = Storage::adjustStorageId('amazon::' . $bucket);
67
-			$newId = Storage::adjustStorageId('amazon::external::' . md5($hostname . ':' . $bucket . ':' . $key));
66
+			$oldId = Storage::adjustStorageId('amazon::'.$bucket);
67
+			$newId = Storage::adjustStorageId('amazon::external::'.md5($hostname.':'.$bucket.':'.$key));
68 68
 			try {
69 69
 				$qb->setParameter('oldId', $oldId);
70 70
 				$qb->setParameter('newId', $newId);
71 71
 				$qb->execute();
72
-				$this->logger->info('Migrated s3 storage id for mount with id ' . $mount['mount_id'] . ' to ' . $newId);
72
+				$this->logger->info('Migrated s3 storage id for mount with id '.$mount['mount_id'].' to '.$newId);
73 73
 			} catch (Exception $e) {
74
-				$this->logger->error('Failed to migrate external s3 storage id for mount with id ' . $mount['mount_id'], [
74
+				$this->logger->error('Failed to migrate external s3 storage id for mount with id '.$mount['mount_id'], [
75 75
 					'exception' => $e
76 76
 				]);
77 77
 			}
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -20,71 +20,71 @@
 block discarded – undo
20 20
 
21 21
 class Version1015Date20211104103506 extends SimpleMigrationStep {
22 22
 
23
-	public function __construct(
24
-		private IDBConnection $connection,
25
-		private LoggerInterface $logger,
26
-	) {
27
-	}
23
+    public function __construct(
24
+        private IDBConnection $connection,
25
+        private LoggerInterface $logger,
26
+    ) {
27
+    }
28 28
 
29
-	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
30
-		$qb = $this->connection->getQueryBuilder();
31
-		$qb->update('storages')
32
-			->set('id', $qb->createParameter('newId'))
33
-			->where($qb->expr()->eq('id', $qb->createParameter('oldId')));
29
+    public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
30
+        $qb = $this->connection->getQueryBuilder();
31
+        $qb->update('storages')
32
+            ->set('id', $qb->createParameter('newId'))
33
+            ->where($qb->expr()->eq('id', $qb->createParameter('oldId')));
34 34
 
35
-		$mounts = $this->getS3Mounts();
36
-		if (!$mounts instanceof IResult) {
37
-			throw new \Exception('Could not fetch existing mounts for migration');
38
-		}
35
+        $mounts = $this->getS3Mounts();
36
+        if (!$mounts instanceof IResult) {
37
+            throw new \Exception('Could not fetch existing mounts for migration');
38
+        }
39 39
 
40
-		while ($mount = $mounts->fetch()) {
41
-			$config = $this->getStorageConfig((int)$mount['mount_id']);
42
-			$hostname = $config['hostname'];
43
-			$bucket = $config['bucket'];
44
-			$key = $config['key'];
45
-			$oldId = Storage::adjustStorageId('amazon::' . $bucket);
46
-			$newId = Storage::adjustStorageId('amazon::external::' . md5($hostname . ':' . $bucket . ':' . $key));
47
-			try {
48
-				$qb->setParameter('oldId', $oldId);
49
-				$qb->setParameter('newId', $newId);
50
-				$qb->execute();
51
-				$this->logger->info('Migrated s3 storage id for mount with id ' . $mount['mount_id'] . ' to ' . $newId);
52
-			} catch (Exception $e) {
53
-				$this->logger->error('Failed to migrate external s3 storage id for mount with id ' . $mount['mount_id'], [
54
-					'exception' => $e
55
-				]);
56
-			}
57
-		}
58
-		return null;
59
-	}
40
+        while ($mount = $mounts->fetch()) {
41
+            $config = $this->getStorageConfig((int)$mount['mount_id']);
42
+            $hostname = $config['hostname'];
43
+            $bucket = $config['bucket'];
44
+            $key = $config['key'];
45
+            $oldId = Storage::adjustStorageId('amazon::' . $bucket);
46
+            $newId = Storage::adjustStorageId('amazon::external::' . md5($hostname . ':' . $bucket . ':' . $key));
47
+            try {
48
+                $qb->setParameter('oldId', $oldId);
49
+                $qb->setParameter('newId', $newId);
50
+                $qb->execute();
51
+                $this->logger->info('Migrated s3 storage id for mount with id ' . $mount['mount_id'] . ' to ' . $newId);
52
+            } catch (Exception $e) {
53
+                $this->logger->error('Failed to migrate external s3 storage id for mount with id ' . $mount['mount_id'], [
54
+                    'exception' => $e
55
+                ]);
56
+            }
57
+        }
58
+        return null;
59
+    }
60 60
 
61
-	/**
62
-	 * @throws Exception
63
-	 * @return IResult|int
64
-	 */
65
-	private function getS3Mounts() {
66
-		$qb = $this->connection->getQueryBuilder();
67
-		$qb->select('m.mount_id')
68
-			->selectAlias('c.value', 'bucket')
69
-			->from('external_mounts', 'm')
70
-			->innerJoin('m', 'external_config', 'c', 'c.mount_id = m.mount_id')
71
-			->where($qb->expr()->eq('m.storage_backend', $qb->createPositionalParameter('amazons3')))
72
-			->andWhere($qb->expr()->eq('c.key', $qb->createPositionalParameter('bucket')));
73
-		return $qb->execute();
74
-	}
61
+    /**
62
+     * @throws Exception
63
+     * @return IResult|int
64
+     */
65
+    private function getS3Mounts() {
66
+        $qb = $this->connection->getQueryBuilder();
67
+        $qb->select('m.mount_id')
68
+            ->selectAlias('c.value', 'bucket')
69
+            ->from('external_mounts', 'm')
70
+            ->innerJoin('m', 'external_config', 'c', 'c.mount_id = m.mount_id')
71
+            ->where($qb->expr()->eq('m.storage_backend', $qb->createPositionalParameter('amazons3')))
72
+            ->andWhere($qb->expr()->eq('c.key', $qb->createPositionalParameter('bucket')));
73
+        return $qb->execute();
74
+    }
75 75
 
76
-	/**
77
-	 * @throws Exception
78
-	 */
79
-	private function getStorageConfig(int $mountId): array {
80
-		$qb = $this->connection->getQueryBuilder();
81
-		$qb->select('key', 'value')
82
-			->from('external_config')
83
-			->where($qb->expr()->eq('mount_id', $qb->createPositionalParameter($mountId)));
84
-		$config = [];
85
-		foreach ($qb->execute()->fetchAll() as $row) {
86
-			$config[$row['key']] = $row['value'];
87
-		}
88
-		return $config;
89
-	}
76
+    /**
77
+     * @throws Exception
78
+     */
79
+    private function getStorageConfig(int $mountId): array {
80
+        $qb = $this->connection->getQueryBuilder();
81
+        $qb->select('key', 'value')
82
+            ->from('external_config')
83
+            ->where($qb->expr()->eq('mount_id', $qb->createPositionalParameter($mountId)));
84
+        $config = [];
85
+        foreach ($qb->execute()->fetchAll() as $row) {
86
+            $config[$row['key']] = $row['value'];
87
+        }
88
+        return $config;
89
+    }
90 90
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/MtimeSanitizer.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,20 +23,20 @@
 block discarded – undo
23 23
 namespace OCA\DAV\Connector\Sabre;
24 24
 
25 25
 class MtimeSanitizer {
26
-	public static function sanitizeMtime(string $mtimeFromRequest): int {
27
-		// In PHP 5.X "is_numeric" returns true for strings in hexadecimal
28
-		// notation. This is no longer the case in PHP 7.X, so this check
29
-		// ensures that strings with hexadecimal notations fail too in PHP 5.X.
30
-		$isHexadecimal = preg_match('/^\s*0[xX]/', $mtimeFromRequest);
31
-		if ($isHexadecimal || !is_numeric($mtimeFromRequest)) {
32
-			throw new \InvalidArgumentException('X-OC-MTime header must be an integer (unix timestamp).');
33
-		}
26
+    public static function sanitizeMtime(string $mtimeFromRequest): int {
27
+        // In PHP 5.X "is_numeric" returns true for strings in hexadecimal
28
+        // notation. This is no longer the case in PHP 7.X, so this check
29
+        // ensures that strings with hexadecimal notations fail too in PHP 5.X.
30
+        $isHexadecimal = preg_match('/^\s*0[xX]/', $mtimeFromRequest);
31
+        if ($isHexadecimal || !is_numeric($mtimeFromRequest)) {
32
+            throw new \InvalidArgumentException('X-OC-MTime header must be an integer (unix timestamp).');
33
+        }
34 34
 
35
-		// Prevent writing invalid mtime (timezone-proof)
36
-		if ((int)$mtimeFromRequest <= 24 * 60 * 60) {
37
-			throw new \InvalidArgumentException('X-OC-MTime header must be a valid positive integer');
38
-		}
35
+        // Prevent writing invalid mtime (timezone-proof)
36
+        if ((int)$mtimeFromRequest <= 24 * 60 * 60) {
37
+            throw new \InvalidArgumentException('X-OC-MTime header must be a valid positive integer');
38
+        }
39 39
 
40
-		return (int)$mtimeFromRequest;
41
-	}
40
+        return (int)$mtimeFromRequest;
41
+    }
42 42
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@
 block discarded – undo
33 33
 		}
34 34
 
35 35
 		// Prevent writing invalid mtime (timezone-proof)
36
-		if ((int)$mtimeFromRequest <= 24 * 60 * 60) {
36
+		if ((int) $mtimeFromRequest <= 24 * 60 * 60) {
37 37
 			throw new \InvalidArgumentException('X-OC-MTime header must be a valid positive integer');
38 38
 		}
39 39
 
40
-		return (int)$mtimeFromRequest;
40
+		return (int) $mtimeFromRequest;
41 41
 	}
42 42
 }
Please login to merge, or discard this patch.
lib/private/Security/TrustedDomainHelper.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		}
71 71
 
72 72
 		if (isset($parsedUrl['port']) && $parsedUrl['port']) {
73
-			return $this->isTrustedDomain($parsedUrl['host'] . ':' . $parsedUrl['port']);
73
+			return $this->isTrustedDomain($parsedUrl['host'].':'.$parsedUrl['port']);
74 74
 		}
75 75
 
76 76
 		return $this->isTrustedDomain($parsedUrl['host']);
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 			if (gettype($trusted) !== 'string') {
107 107
 				break;
108 108
 			}
109
-			$regex = '/^' . implode('[-\.a-zA-Z0-9]*', array_map(function ($v) {
109
+			$regex = '/^'.implode('[-\.a-zA-Z0-9]*', array_map(function($v) {
110 110
 				return preg_quote($v, '/');
111
-			}, explode('*', $trusted))) . '$/i';
111
+			}, explode('*', $trusted))).'$/i';
112 112
 			if (preg_match($regex, $domain) || preg_match($regex, $domainWithPort)) {
113 113
 				return true;
114 114
 			}
Please login to merge, or discard this patch.
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -13,79 +13,79 @@
 block discarded – undo
13 13
 use OCP\Security\ITrustedDomainHelper;
14 14
 
15 15
 class TrustedDomainHelper implements ITrustedDomainHelper {
16
-	public function __construct(
17
-		private IConfig $config,
18
-	) {
19
-	}
16
+    public function __construct(
17
+        private IConfig $config,
18
+    ) {
19
+    }
20 20
 
21
-	/**
22
-	 * Strips a potential port from a domain (in format domain:port)
23
-	 * @return string $host without appended port
24
-	 */
25
-	private function getDomainWithoutPort(string $host): string {
26
-		$pos = strrpos($host, ':');
27
-		if ($pos !== false) {
28
-			$port = substr($host, $pos + 1);
29
-			if (is_numeric($port)) {
30
-				$host = substr($host, 0, $pos);
31
-			}
32
-		}
33
-		return $host;
34
-	}
21
+    /**
22
+     * Strips a potential port from a domain (in format domain:port)
23
+     * @return string $host without appended port
24
+     */
25
+    private function getDomainWithoutPort(string $host): string {
26
+        $pos = strrpos($host, ':');
27
+        if ($pos !== false) {
28
+            $port = substr($host, $pos + 1);
29
+            if (is_numeric($port)) {
30
+                $host = substr($host, 0, $pos);
31
+            }
32
+        }
33
+        return $host;
34
+    }
35 35
 
36
-	/**
37
-	 * {@inheritDoc}
38
-	 */
39
-	public function isTrustedUrl(string $url): bool {
40
-		$parsedUrl = parse_url($url);
41
-		if (empty($parsedUrl['host'])) {
42
-			return false;
43
-		}
36
+    /**
37
+     * {@inheritDoc}
38
+     */
39
+    public function isTrustedUrl(string $url): bool {
40
+        $parsedUrl = parse_url($url);
41
+        if (empty($parsedUrl['host'])) {
42
+            return false;
43
+        }
44 44
 
45
-		if (isset($parsedUrl['port']) && $parsedUrl['port']) {
46
-			return $this->isTrustedDomain($parsedUrl['host'] . ':' . $parsedUrl['port']);
47
-		}
45
+        if (isset($parsedUrl['port']) && $parsedUrl['port']) {
46
+            return $this->isTrustedDomain($parsedUrl['host'] . ':' . $parsedUrl['port']);
47
+        }
48 48
 
49
-		return $this->isTrustedDomain($parsedUrl['host']);
50
-	}
49
+        return $this->isTrustedDomain($parsedUrl['host']);
50
+    }
51 51
 
52
-	/**
53
-	 * {@inheritDoc}
54
-	 */
55
-	public function isTrustedDomain(string $domainWithPort): bool {
56
-		// overwritehost is always trusted
57
-		if ($this->config->getSystemValue('overwritehost') !== '') {
58
-			return true;
59
-		}
52
+    /**
53
+     * {@inheritDoc}
54
+     */
55
+    public function isTrustedDomain(string $domainWithPort): bool {
56
+        // overwritehost is always trusted
57
+        if ($this->config->getSystemValue('overwritehost') !== '') {
58
+            return true;
59
+        }
60 60
 
61
-		$domain = $this->getDomainWithoutPort($domainWithPort);
61
+        $domain = $this->getDomainWithoutPort($domainWithPort);
62 62
 
63
-		// Read trusted domains from config
64
-		$trustedList = $this->config->getSystemValue('trusted_domains', []);
65
-		if (!is_array($trustedList)) {
66
-			return false;
67
-		}
63
+        // Read trusted domains from config
64
+        $trustedList = $this->config->getSystemValue('trusted_domains', []);
65
+        if (!is_array($trustedList)) {
66
+            return false;
67
+        }
68 68
 
69
-		// Always allow access from localhost
70
-		if (preg_match(Request::REGEX_LOCALHOST, $domain) === 1) {
71
-			return true;
72
-		}
73
-		// Reject malformed domains in any case
74
-		if (str_starts_with($domain, '-') || str_contains($domain, '..')) {
75
-			return false;
76
-		}
77
-		// Match, allowing for * wildcards
78
-		foreach ($trustedList as $trusted) {
79
-			if (gettype($trusted) !== 'string') {
80
-				break;
81
-			}
82
-			$regex = '/^' . implode('[-\.a-zA-Z0-9]*', array_map(function ($v) {
83
-				return preg_quote($v, '/');
84
-			}, explode('*', $trusted))) . '$/i';
85
-			if (preg_match($regex, $domain) || preg_match($regex, $domainWithPort)) {
86
-				return true;
87
-			}
88
-		}
89
-		return false;
90
-	}
69
+        // Always allow access from localhost
70
+        if (preg_match(Request::REGEX_LOCALHOST, $domain) === 1) {
71
+            return true;
72
+        }
73
+        // Reject malformed domains in any case
74
+        if (str_starts_with($domain, '-') || str_contains($domain, '..')) {
75
+            return false;
76
+        }
77
+        // Match, allowing for * wildcards
78
+        foreach ($trustedList as $trusted) {
79
+            if (gettype($trusted) !== 'string') {
80
+                break;
81
+            }
82
+            $regex = '/^' . implode('[-\.a-zA-Z0-9]*', array_map(function ($v) {
83
+                return preg_quote($v, '/');
84
+            }, explode('*', $trusted))) . '$/i';
85
+            if (preg_match($regex, $domain) || preg_match($regex, $domainWithPort)) {
86
+                return true;
87
+            }
88
+        }
89
+        return false;
90
+    }
91 91
 }
Please login to merge, or discard this patch.