Passed
Push — master ( 3d6223...41dc18 )
by Lukas
14:59 queued 11s
created
apps/settings/lib/Controller/CheckSetupController.php 1 patch
Indentation   +674 added lines, -674 removed lines patch added patch discarded remove patch
@@ -82,298 +82,298 @@  discard block
 block discarded – undo
82 82
 use Symfony\Component\EventDispatcher\GenericEvent;
83 83
 
84 84
 class CheckSetupController extends Controller {
85
-	/** @var IConfig */
86
-	private $config;
87
-	/** @var IClientService */
88
-	private $clientService;
89
-	/** @var IURLGenerator */
90
-	private $urlGenerator;
91
-	/** @var IL10N */
92
-	private $l10n;
93
-	/** @var Checker */
94
-	private $checker;
95
-	/** @var ILogger */
96
-	private $logger;
97
-	/** @var EventDispatcherInterface */
98
-	private $dispatcher;
99
-	/** @var Connection */
100
-	private $db;
101
-	/** @var ILockingProvider */
102
-	private $lockingProvider;
103
-	/** @var IDateTimeFormatter */
104
-	private $dateTimeFormatter;
105
-	/** @var MemoryInfo */
106
-	private $memoryInfo;
107
-	/** @var ISecureRandom */
108
-	private $secureRandom;
109
-	/** @var IniGetWrapper */
110
-	private $iniGetWrapper;
111
-	/** @var IDBConnection */
112
-	private $connection;
113
-
114
-	public function __construct($AppName,
115
-								IRequest $request,
116
-								IConfig $config,
117
-								IClientService $clientService,
118
-								IURLGenerator $urlGenerator,
119
-								IL10N $l10n,
120
-								Checker $checker,
121
-								ILogger $logger,
122
-								EventDispatcherInterface $dispatcher,
123
-								Connection $db,
124
-								ILockingProvider $lockingProvider,
125
-								IDateTimeFormatter $dateTimeFormatter,
126
-								MemoryInfo $memoryInfo,
127
-								ISecureRandom $secureRandom,
128
-								IniGetWrapper $iniGetWrapper,
129
-								IDBConnection $connection) {
130
-		parent::__construct($AppName, $request);
131
-		$this->config = $config;
132
-		$this->clientService = $clientService;
133
-		$this->urlGenerator = $urlGenerator;
134
-		$this->l10n = $l10n;
135
-		$this->checker = $checker;
136
-		$this->logger = $logger;
137
-		$this->dispatcher = $dispatcher;
138
-		$this->db = $db;
139
-		$this->lockingProvider = $lockingProvider;
140
-		$this->dateTimeFormatter = $dateTimeFormatter;
141
-		$this->memoryInfo = $memoryInfo;
142
-		$this->secureRandom = $secureRandom;
143
-		$this->iniGetWrapper = $iniGetWrapper;
144
-		$this->connection = $connection;
145
-	}
146
-
147
-	/**
148
-	 * Checks if the server can connect to the internet using HTTPS and HTTP
149
-	 * @return bool
150
-	 */
151
-	private function hasInternetConnectivityProblems(): bool {
152
-		if ($this->config->getSystemValue('has_internet_connection', true) === false) {
153
-			return false;
154
-		}
155
-
156
-		$siteArray = $this->config->getSystemValue('connectivity_check_domains', [
157
-			'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'
158
-		]);
159
-
160
-		foreach ($siteArray as $site) {
161
-			if ($this->isSiteReachable($site)) {
162
-				return false;
163
-			}
164
-		}
165
-		return true;
166
-	}
167
-
168
-	/**
169
-	 * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP
170
-	 * @return bool
171
-	 */
172
-	private function isSiteReachable($sitename) {
173
-		$httpSiteName = 'http://' . $sitename . '/';
174
-		$httpsSiteName = 'https://' . $sitename . '/';
175
-
176
-		try {
177
-			$client = $this->clientService->newClient();
178
-			$client->get($httpSiteName);
179
-			$client->get($httpsSiteName);
180
-		} catch (\Exception $e) {
181
-			$this->logger->logException($e, ['app' => 'internet_connection_check']);
182
-			return false;
183
-		}
184
-		return true;
185
-	}
186
-
187
-	/**
188
-	 * Checks whether a local memcache is installed or not
189
-	 * @return bool
190
-	 */
191
-	private function isMemcacheConfigured() {
192
-		return $this->config->getSystemValue('memcache.local', null) !== null;
193
-	}
194
-
195
-	/**
196
-	 * Whether PHP can generate "secure" pseudorandom integers
197
-	 *
198
-	 * @return bool
199
-	 */
200
-	private function isRandomnessSecure() {
201
-		try {
202
-			$this->secureRandom->generate(1);
203
-		} catch (\Exception $ex) {
204
-			return false;
205
-		}
206
-		return true;
207
-	}
208
-
209
-	/**
210
-	 * Public for the sake of unit-testing
211
-	 *
212
-	 * @return array
213
-	 */
214
-	protected function getCurlVersion() {
215
-		return curl_version();
216
-	}
217
-
218
-	/**
219
-	 * Check if the used  SSL lib is outdated. Older OpenSSL and NSS versions do
220
-	 * have multiple bugs which likely lead to problems in combination with
221
-	 * functionality required by ownCloud such as SNI.
222
-	 *
223
-	 * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546
224
-	 * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172
225
-	 * @return string
226
-	 */
227
-	private function isUsedTlsLibOutdated() {
228
-		// Don't run check when:
229
-		// 1. Server has `has_internet_connection` set to false
230
-		// 2. AppStore AND S2S is disabled
231
-		if (!$this->config->getSystemValue('has_internet_connection', true)) {
232
-			return '';
233
-		}
234
-		if (!$this->config->getSystemValue('appstoreenabled', true)
235
-			&& $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no'
236
-			&& $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') {
237
-			return '';
238
-		}
239
-
240
-		$versionString = $this->getCurlVersion();
241
-		if (isset($versionString['ssl_version'])) {
242
-			$versionString = $versionString['ssl_version'];
243
-		} else {
244
-			return '';
245
-		}
246
-
247
-		$features = $this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing');
248
-		if (!$this->config->getSystemValue('appstoreenabled', true)) {
249
-			$features = $this->l10n->t('Federated Cloud Sharing');
250
-		}
251
-
252
-		// Check if at least OpenSSL after 1.01d or 1.0.2b
253
-		if (strpos($versionString, 'OpenSSL/') === 0) {
254
-			$majorVersion = substr($versionString, 8, 5);
255
-			$patchRelease = substr($versionString, 13, 6);
256
-
257
-			if (($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) ||
258
-				($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) {
259
-				return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['OpenSSL', $versionString, $features]);
260
-			}
261
-		}
262
-
263
-		// Check if NSS and perform heuristic check
264
-		if (strpos($versionString, 'NSS/') === 0) {
265
-			try {
266
-				$firstClient = $this->clientService->newClient();
267
-				$firstClient->get('https://nextcloud.com/');
268
-
269
-				$secondClient = $this->clientService->newClient();
270
-				$secondClient->get('https://nextcloud.com/');
271
-			} catch (ClientException $e) {
272
-				if ($e->getResponse()->getStatusCode() === 400) {
273
-					return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['NSS', $versionString, $features]);
274
-				}
275
-			} catch (\Exception $e) {
276
-				$this->logger->logException($e, ['app' => 'settings', 'level' => \OCP\ILogger::WARN]);
277
-				return $this->l10n->t('Could not determine if TLS version of cURL is outdated or not because an error happened during the HTTPS request against https://nextcloud.com. Please check the nextcloud log file for more details.');
278
-			}
279
-		}
280
-
281
-		return '';
282
-	}
283
-
284
-	/**
285
-	 * Whether the version is outdated
286
-	 *
287
-	 * @return bool
288
-	 */
289
-	protected function isPhpOutdated(): bool {
290
-		return PHP_VERSION_ID < 70300;
291
-	}
292
-
293
-	/**
294
-	 * Whether the php version is still supported (at time of release)
295
-	 * according to: https://www.php.net/supported-versions.php
296
-	 *
297
-	 * @return array
298
-	 */
299
-	private function isPhpSupported(): array {
300
-		return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION];
301
-	}
302
-
303
-	/**
304
-	 * Check if the reverse proxy configuration is working as expected
305
-	 *
306
-	 * @return bool
307
-	 */
308
-	private function forwardedForHeadersWorking() {
309
-		$trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
310
-		$remoteAddress = $this->request->getHeader('REMOTE_ADDR');
311
-
312
-		if (empty($trustedProxies) && $this->request->getHeader('X-Forwarded-Host') !== '') {
313
-			return false;
314
-		}
315
-
316
-		if (\is_array($trustedProxies) && \in_array($remoteAddress, $trustedProxies, true)) {
317
-			return $remoteAddress !== $this->request->getRemoteAddress();
318
-		}
319
-
320
-		// either not enabled or working correctly
321
-		return true;
322
-	}
323
-
324
-	/**
325
-	 * Checks if the correct memcache module for PHP is installed. Only
326
-	 * fails if memcached is configured and the working module is not installed.
327
-	 *
328
-	 * @return bool
329
-	 */
330
-	private function isCorrectMemcachedPHPModuleInstalled() {
331
-		if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') {
332
-			return true;
333
-		}
334
-
335
-		// there are two different memcached modules for PHP
336
-		// we only support memcached and not memcache
337
-		// https://code.google.com/p/memcached/wiki/PHPClientComparison
338
-		return !(!extension_loaded('memcached') && extension_loaded('memcache'));
339
-	}
340
-
341
-	/**
342
-	 * Checks if set_time_limit is not disabled.
343
-	 *
344
-	 * @return bool
345
-	 */
346
-	private function isSettimelimitAvailable() {
347
-		if (function_exists('set_time_limit')
348
-			&& strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
349
-			return true;
350
-		}
351
-
352
-		return false;
353
-	}
354
-
355
-	/**
356
-	 * @return RedirectResponse
357
-	 */
358
-	public function rescanFailedIntegrityCheck() {
359
-		$this->checker->runInstanceVerification();
360
-		return new RedirectResponse(
361
-			$this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'overview'])
362
-		);
363
-	}
364
-
365
-	/**
366
-	 * @NoCSRFRequired
367
-	 */
368
-	public function getFailedIntegrityCheckFiles(): DataDisplayResponse {
369
-		if (!$this->checker->isCodeCheckEnforced()) {
370
-			return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
371
-		}
372
-
373
-		$completeResults = $this->checker->getResults();
374
-
375
-		if (!empty($completeResults)) {
376
-			$formattedTextResponse = 'Technical information
85
+    /** @var IConfig */
86
+    private $config;
87
+    /** @var IClientService */
88
+    private $clientService;
89
+    /** @var IURLGenerator */
90
+    private $urlGenerator;
91
+    /** @var IL10N */
92
+    private $l10n;
93
+    /** @var Checker */
94
+    private $checker;
95
+    /** @var ILogger */
96
+    private $logger;
97
+    /** @var EventDispatcherInterface */
98
+    private $dispatcher;
99
+    /** @var Connection */
100
+    private $db;
101
+    /** @var ILockingProvider */
102
+    private $lockingProvider;
103
+    /** @var IDateTimeFormatter */
104
+    private $dateTimeFormatter;
105
+    /** @var MemoryInfo */
106
+    private $memoryInfo;
107
+    /** @var ISecureRandom */
108
+    private $secureRandom;
109
+    /** @var IniGetWrapper */
110
+    private $iniGetWrapper;
111
+    /** @var IDBConnection */
112
+    private $connection;
113
+
114
+    public function __construct($AppName,
115
+                                IRequest $request,
116
+                                IConfig $config,
117
+                                IClientService $clientService,
118
+                                IURLGenerator $urlGenerator,
119
+                                IL10N $l10n,
120
+                                Checker $checker,
121
+                                ILogger $logger,
122
+                                EventDispatcherInterface $dispatcher,
123
+                                Connection $db,
124
+                                ILockingProvider $lockingProvider,
125
+                                IDateTimeFormatter $dateTimeFormatter,
126
+                                MemoryInfo $memoryInfo,
127
+                                ISecureRandom $secureRandom,
128
+                                IniGetWrapper $iniGetWrapper,
129
+                                IDBConnection $connection) {
130
+        parent::__construct($AppName, $request);
131
+        $this->config = $config;
132
+        $this->clientService = $clientService;
133
+        $this->urlGenerator = $urlGenerator;
134
+        $this->l10n = $l10n;
135
+        $this->checker = $checker;
136
+        $this->logger = $logger;
137
+        $this->dispatcher = $dispatcher;
138
+        $this->db = $db;
139
+        $this->lockingProvider = $lockingProvider;
140
+        $this->dateTimeFormatter = $dateTimeFormatter;
141
+        $this->memoryInfo = $memoryInfo;
142
+        $this->secureRandom = $secureRandom;
143
+        $this->iniGetWrapper = $iniGetWrapper;
144
+        $this->connection = $connection;
145
+    }
146
+
147
+    /**
148
+     * Checks if the server can connect to the internet using HTTPS and HTTP
149
+     * @return bool
150
+     */
151
+    private function hasInternetConnectivityProblems(): bool {
152
+        if ($this->config->getSystemValue('has_internet_connection', true) === false) {
153
+            return false;
154
+        }
155
+
156
+        $siteArray = $this->config->getSystemValue('connectivity_check_domains', [
157
+            'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'
158
+        ]);
159
+
160
+        foreach ($siteArray as $site) {
161
+            if ($this->isSiteReachable($site)) {
162
+                return false;
163
+            }
164
+        }
165
+        return true;
166
+    }
167
+
168
+    /**
169
+     * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP
170
+     * @return bool
171
+     */
172
+    private function isSiteReachable($sitename) {
173
+        $httpSiteName = 'http://' . $sitename . '/';
174
+        $httpsSiteName = 'https://' . $sitename . '/';
175
+
176
+        try {
177
+            $client = $this->clientService->newClient();
178
+            $client->get($httpSiteName);
179
+            $client->get($httpsSiteName);
180
+        } catch (\Exception $e) {
181
+            $this->logger->logException($e, ['app' => 'internet_connection_check']);
182
+            return false;
183
+        }
184
+        return true;
185
+    }
186
+
187
+    /**
188
+     * Checks whether a local memcache is installed or not
189
+     * @return bool
190
+     */
191
+    private function isMemcacheConfigured() {
192
+        return $this->config->getSystemValue('memcache.local', null) !== null;
193
+    }
194
+
195
+    /**
196
+     * Whether PHP can generate "secure" pseudorandom integers
197
+     *
198
+     * @return bool
199
+     */
200
+    private function isRandomnessSecure() {
201
+        try {
202
+            $this->secureRandom->generate(1);
203
+        } catch (\Exception $ex) {
204
+            return false;
205
+        }
206
+        return true;
207
+    }
208
+
209
+    /**
210
+     * Public for the sake of unit-testing
211
+     *
212
+     * @return array
213
+     */
214
+    protected function getCurlVersion() {
215
+        return curl_version();
216
+    }
217
+
218
+    /**
219
+     * Check if the used  SSL lib is outdated. Older OpenSSL and NSS versions do
220
+     * have multiple bugs which likely lead to problems in combination with
221
+     * functionality required by ownCloud such as SNI.
222
+     *
223
+     * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546
224
+     * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172
225
+     * @return string
226
+     */
227
+    private function isUsedTlsLibOutdated() {
228
+        // Don't run check when:
229
+        // 1. Server has `has_internet_connection` set to false
230
+        // 2. AppStore AND S2S is disabled
231
+        if (!$this->config->getSystemValue('has_internet_connection', true)) {
232
+            return '';
233
+        }
234
+        if (!$this->config->getSystemValue('appstoreenabled', true)
235
+            && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no'
236
+            && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') {
237
+            return '';
238
+        }
239
+
240
+        $versionString = $this->getCurlVersion();
241
+        if (isset($versionString['ssl_version'])) {
242
+            $versionString = $versionString['ssl_version'];
243
+        } else {
244
+            return '';
245
+        }
246
+
247
+        $features = $this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing');
248
+        if (!$this->config->getSystemValue('appstoreenabled', true)) {
249
+            $features = $this->l10n->t('Federated Cloud Sharing');
250
+        }
251
+
252
+        // Check if at least OpenSSL after 1.01d or 1.0.2b
253
+        if (strpos($versionString, 'OpenSSL/') === 0) {
254
+            $majorVersion = substr($versionString, 8, 5);
255
+            $patchRelease = substr($versionString, 13, 6);
256
+
257
+            if (($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) ||
258
+                ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) {
259
+                return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['OpenSSL', $versionString, $features]);
260
+            }
261
+        }
262
+
263
+        // Check if NSS and perform heuristic check
264
+        if (strpos($versionString, 'NSS/') === 0) {
265
+            try {
266
+                $firstClient = $this->clientService->newClient();
267
+                $firstClient->get('https://nextcloud.com/');
268
+
269
+                $secondClient = $this->clientService->newClient();
270
+                $secondClient->get('https://nextcloud.com/');
271
+            } catch (ClientException $e) {
272
+                if ($e->getResponse()->getStatusCode() === 400) {
273
+                    return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['NSS', $versionString, $features]);
274
+                }
275
+            } catch (\Exception $e) {
276
+                $this->logger->logException($e, ['app' => 'settings', 'level' => \OCP\ILogger::WARN]);
277
+                return $this->l10n->t('Could not determine if TLS version of cURL is outdated or not because an error happened during the HTTPS request against https://nextcloud.com. Please check the nextcloud log file for more details.');
278
+            }
279
+        }
280
+
281
+        return '';
282
+    }
283
+
284
+    /**
285
+     * Whether the version is outdated
286
+     *
287
+     * @return bool
288
+     */
289
+    protected function isPhpOutdated(): bool {
290
+        return PHP_VERSION_ID < 70300;
291
+    }
292
+
293
+    /**
294
+     * Whether the php version is still supported (at time of release)
295
+     * according to: https://www.php.net/supported-versions.php
296
+     *
297
+     * @return array
298
+     */
299
+    private function isPhpSupported(): array {
300
+        return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION];
301
+    }
302
+
303
+    /**
304
+     * Check if the reverse proxy configuration is working as expected
305
+     *
306
+     * @return bool
307
+     */
308
+    private function forwardedForHeadersWorking() {
309
+        $trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
310
+        $remoteAddress = $this->request->getHeader('REMOTE_ADDR');
311
+
312
+        if (empty($trustedProxies) && $this->request->getHeader('X-Forwarded-Host') !== '') {
313
+            return false;
314
+        }
315
+
316
+        if (\is_array($trustedProxies) && \in_array($remoteAddress, $trustedProxies, true)) {
317
+            return $remoteAddress !== $this->request->getRemoteAddress();
318
+        }
319
+
320
+        // either not enabled or working correctly
321
+        return true;
322
+    }
323
+
324
+    /**
325
+     * Checks if the correct memcache module for PHP is installed. Only
326
+     * fails if memcached is configured and the working module is not installed.
327
+     *
328
+     * @return bool
329
+     */
330
+    private function isCorrectMemcachedPHPModuleInstalled() {
331
+        if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') {
332
+            return true;
333
+        }
334
+
335
+        // there are two different memcached modules for PHP
336
+        // we only support memcached and not memcache
337
+        // https://code.google.com/p/memcached/wiki/PHPClientComparison
338
+        return !(!extension_loaded('memcached') && extension_loaded('memcache'));
339
+    }
340
+
341
+    /**
342
+     * Checks if set_time_limit is not disabled.
343
+     *
344
+     * @return bool
345
+     */
346
+    private function isSettimelimitAvailable() {
347
+        if (function_exists('set_time_limit')
348
+            && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
349
+            return true;
350
+        }
351
+
352
+        return false;
353
+    }
354
+
355
+    /**
356
+     * @return RedirectResponse
357
+     */
358
+    public function rescanFailedIntegrityCheck() {
359
+        $this->checker->runInstanceVerification();
360
+        return new RedirectResponse(
361
+            $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'overview'])
362
+        );
363
+    }
364
+
365
+    /**
366
+     * @NoCSRFRequired
367
+     */
368
+    public function getFailedIntegrityCheckFiles(): DataDisplayResponse {
369
+        if (!$this->checker->isCodeCheckEnforced()) {
370
+            return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
371
+        }
372
+
373
+        $completeResults = $this->checker->getResults();
374
+
375
+        if (!empty($completeResults)) {
376
+            $formattedTextResponse = 'Technical information
377 377
 =====================
378 378
 The following list covers which files have failed the integrity check. Please read
379 379
 the previous linked documentation to learn more about the errors and how to fix
@@ -382,389 +382,389 @@  discard block
 block discarded – undo
382 382
 Results
383 383
 =======
384 384
 ';
385
-			foreach ($completeResults as $context => $contextResult) {
386
-				$formattedTextResponse .= "- $context\n";
387
-
388
-				foreach ($contextResult as $category => $result) {
389
-					$formattedTextResponse .= "\t- $category\n";
390
-					if ($category !== 'EXCEPTION') {
391
-						foreach ($result as $key => $results) {
392
-							$formattedTextResponse .= "\t\t- $key\n";
393
-						}
394
-					} else {
395
-						foreach ($result as $key => $results) {
396
-							$formattedTextResponse .= "\t\t- $results\n";
397
-						}
398
-					}
399
-				}
400
-			}
401
-
402
-			$formattedTextResponse .= '
385
+            foreach ($completeResults as $context => $contextResult) {
386
+                $formattedTextResponse .= "- $context\n";
387
+
388
+                foreach ($contextResult as $category => $result) {
389
+                    $formattedTextResponse .= "\t- $category\n";
390
+                    if ($category !== 'EXCEPTION') {
391
+                        foreach ($result as $key => $results) {
392
+                            $formattedTextResponse .= "\t\t- $key\n";
393
+                        }
394
+                    } else {
395
+                        foreach ($result as $key => $results) {
396
+                            $formattedTextResponse .= "\t\t- $results\n";
397
+                        }
398
+                    }
399
+                }
400
+            }
401
+
402
+            $formattedTextResponse .= '
403 403
 Raw output
404 404
 ==========
405 405
 ';
406
-			$formattedTextResponse .= print_r($completeResults, true);
407
-		} else {
408
-			$formattedTextResponse = 'No errors have been found.';
409
-		}
410
-
411
-
412
-		return new DataDisplayResponse(
413
-			$formattedTextResponse,
414
-			Http::STATUS_OK,
415
-			[
416
-				'Content-Type' => 'text/plain',
417
-			]
418
-		);
419
-	}
420
-
421
-	/**
422
-	 * Checks whether a PHP opcache is properly set up
423
-	 * @return bool
424
-	 */
425
-	protected function isOpcacheProperlySetup() {
426
-		if (!$this->iniGetWrapper->getBool('opcache.enable')) {
427
-			return false;
428
-		}
429
-
430
-		if (!$this->iniGetWrapper->getBool('opcache.save_comments')) {
431
-			return false;
432
-		}
433
-
434
-		if ($this->iniGetWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
435
-			return false;
436
-		}
437
-
438
-		if ($this->iniGetWrapper->getNumeric('opcache.memory_consumption') < 128) {
439
-			return false;
440
-		}
441
-
442
-		if ($this->iniGetWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
443
-			return false;
444
-		}
445
-
446
-		return true;
447
-	}
448
-
449
-	/**
450
-	 * Check if the required FreeType functions are present
451
-	 * @return bool
452
-	 */
453
-	protected function hasFreeTypeSupport() {
454
-		return function_exists('imagettfbbox') && function_exists('imagettftext');
455
-	}
456
-
457
-	protected function hasMissingIndexes(): array {
458
-		$indexInfo = new MissingIndexInformation();
459
-		// Dispatch event so apps can also hint for pending index updates if needed
460
-		$event = new GenericEvent($indexInfo);
461
-		$this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event);
462
-
463
-		return $indexInfo->getListOfMissingIndexes();
464
-	}
465
-
466
-	protected function hasMissingPrimaryKeys(): array {
467
-		$info = new MissingPrimaryKeyInformation();
468
-		// Dispatch event so apps can also hint for pending index updates if needed
469
-		$event = new GenericEvent($info);
470
-		$this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, $event);
471
-
472
-		return $info->getListOfMissingPrimaryKeys();
473
-	}
474
-
475
-	protected function hasMissingColumns(): array {
476
-		$indexInfo = new MissingColumnInformation();
477
-		// Dispatch event so apps can also hint for pending index updates if needed
478
-		$event = new GenericEvent($indexInfo);
479
-		$this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, $event);
480
-
481
-		return $indexInfo->getListOfMissingColumns();
482
-	}
483
-
484
-	protected function isSqliteUsed() {
485
-		return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
486
-	}
487
-
488
-	protected function isReadOnlyConfig(): bool {
489
-		return \OC_Helper::isReadOnlyConfigEnabled();
490
-	}
491
-
492
-	protected function hasValidTransactionIsolationLevel(): bool {
493
-		try {
494
-			if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
495
-				return true;
496
-			}
497
-
498
-			return $this->db->getTransactionIsolation() === TransactionIsolationLevel::READ_COMMITTED;
499
-		} catch (Exception $e) {
500
-			// ignore
501
-		}
502
-
503
-		return true;
504
-	}
505
-
506
-	protected function hasFileinfoInstalled(): bool {
507
-		return \OC_Util::fileInfoLoaded();
508
-	}
509
-
510
-	protected function hasWorkingFileLocking(): bool {
511
-		return !($this->lockingProvider instanceof NoopLockingProvider);
512
-	}
513
-
514
-	protected function getSuggestedOverwriteCliURL(): string {
515
-		$suggestedOverwriteCliUrl = '';
516
-		if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
517
-			$suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
518
-			if (!$this->config->getSystemValue('config_is_read_only', false)) {
519
-				// Set the overwrite URL when it was not set yet.
520
-				$this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
521
-				$suggestedOverwriteCliUrl = '';
522
-			}
523
-		}
524
-		return $suggestedOverwriteCliUrl;
525
-	}
526
-
527
-	protected function getLastCronInfo(): array {
528
-		$lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
529
-		return [
530
-			'diffInSeconds' => time() - $lastCronRun,
531
-			'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),
532
-			'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs',
533
-		];
534
-	}
535
-
536
-	protected function getCronErrors() {
537
-		$errors = json_decode($this->config->getAppValue('core', 'cronErrors', ''), true);
538
-
539
-		if (is_array($errors)) {
540
-			return $errors;
541
-		}
542
-
543
-		return [];
544
-	}
545
-
546
-	protected function hasOpcacheLoaded(): bool {
547
-		return extension_loaded('Zend OPcache');
548
-	}
549
-
550
-	/**
551
-	 * Iterates through the configured app roots and
552
-	 * tests if the subdirectories are owned by the same user than the current user.
553
-	 *
554
-	 * @return array
555
-	 */
556
-	protected function getAppDirsWithDifferentOwner(): array {
557
-		$currentUser = posix_getuid();
558
-		$appDirsWithDifferentOwner = [[]];
559
-
560
-		foreach (OC::$APPSROOTS as $appRoot) {
561
-			if ($appRoot['writable'] === true) {
562
-				$appDirsWithDifferentOwner[] = $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot);
563
-			}
564
-		}
565
-
566
-		$appDirsWithDifferentOwner = array_merge(...$appDirsWithDifferentOwner);
567
-		sort($appDirsWithDifferentOwner);
568
-
569
-		return $appDirsWithDifferentOwner;
570
-	}
571
-
572
-	/**
573
-	 * Tests if the directories for one apps directory are writable by the current user.
574
-	 *
575
-	 * @param int $currentUser The current user
576
-	 * @param array $appRoot The app root config
577
-	 * @return string[] The none writable directory paths inside the app root
578
-	 */
579
-	private function getAppDirsWithDifferentOwnerForAppRoot(int $currentUser, array $appRoot): array {
580
-		$appDirsWithDifferentOwner = [];
581
-		$appsPath = $appRoot['path'];
582
-		$appsDir = new DirectoryIterator($appRoot['path']);
583
-
584
-		foreach ($appsDir as $fileInfo) {
585
-			if ($fileInfo->isDir() && !$fileInfo->isDot()) {
586
-				$absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
587
-				$appDirUser = fileowner($absAppPath);
588
-				if ($appDirUser !== $currentUser) {
589
-					$appDirsWithDifferentOwner[] = $absAppPath;
590
-				}
591
-			}
592
-		}
593
-
594
-		return $appDirsWithDifferentOwner;
595
-	}
596
-
597
-	/**
598
-	 * Checks for potential PHP modules that would improve the instance
599
-	 *
600
-	 * @return string[] A list of PHP modules that is recommended
601
-	 */
602
-	protected function hasRecommendedPHPModules(): array {
603
-		$recommendedPHPModules = [];
604
-
605
-		if (!extension_loaded('intl')) {
606
-			$recommendedPHPModules[] = 'intl';
607
-		}
608
-
609
-		if (!extension_loaded('bcmath')) {
610
-			$recommendedPHPModules[] = 'bcmath';
611
-		}
612
-
613
-		if (!extension_loaded('gmp')) {
614
-			$recommendedPHPModules[] = 'gmp';
615
-		}
616
-
617
-		if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
618
-			if (!extension_loaded('imagick')) {
619
-				$recommendedPHPModules[] = 'imagick';
620
-			}
621
-		}
622
-
623
-		return $recommendedPHPModules;
624
-	}
625
-
626
-	protected function isMysqlUsedWithoutUTF8MB4(): bool {
627
-		return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
628
-	}
629
-
630
-	protected function hasBigIntConversionPendingColumns(): array {
631
-		// copy of ConvertFilecacheBigInt::getColumnsByTable()
632
-		$tables = [
633
-			'activity' => ['activity_id', 'object_id'],
634
-			'activity_mq' => ['mail_id'],
635
-			'authtoken' => ['id'],
636
-			'bruteforce_attempts' => ['id'],
637
-			'federated_reshares' => ['share_id'],
638
-			'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
639
-			'filecache_extended' => ['fileid'],
640
-			'file_locks' => ['id'],
641
-			'jobs' => ['id'],
642
-			'mimetypes' => ['id'],
643
-			'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'],
644
-			'share_external' => ['id', 'parent'],
645
-			'storages' => ['numeric_id'],
646
-		];
647
-
648
-		$schema = new SchemaWrapper($this->db);
649
-		$isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform;
650
-		$pendingColumns = [];
651
-
652
-		foreach ($tables as $tableName => $columns) {
653
-			if (!$schema->hasTable($tableName)) {
654
-				continue;
655
-			}
656
-
657
-			$table = $schema->getTable($tableName);
658
-			foreach ($columns as $columnName) {
659
-				$column = $table->getColumn($columnName);
660
-				$isAutoIncrement = $column->getAutoincrement();
661
-				$isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
662
-				if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
663
-					$pendingColumns[] = $tableName . '.' . $columnName;
664
-				}
665
-			}
666
-		}
667
-
668
-		return $pendingColumns;
669
-	}
670
-
671
-	protected function isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(): bool {
672
-		$objectStore = $this->config->getSystemValue('objectstore', null);
673
-		$objectStoreMultibucket = $this->config->getSystemValue('objectstore_multibucket', null);
674
-
675
-		if (!isset($objectStoreMultibucket) && !isset($objectStore)) {
676
-			return true;
677
-		}
678
-
679
-		if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== 'OC\\Files\\ObjectStore\\S3') {
680
-			return true;
681
-		}
682
-
683
-		if (isset($objectStore['class']) && $objectStore['class'] !== 'OC\\Files\\ObjectStore\\S3') {
684
-			return true;
685
-		}
686
-
687
-		$tempPath = sys_get_temp_dir();
688
-		if (!is_dir($tempPath)) {
689
-			$this->logger->error('Error while checking the temporary PHP path - it was not properly set to a directory. value: ' . $tempPath);
690
-			return false;
691
-		}
692
-		$freeSpaceInTemp = disk_free_space($tempPath);
693
-		if ($freeSpaceInTemp === false) {
694
-			$this->logger->error('Error while checking the available disk space of temporary PHP path - no free disk space returned. temporary path: ' . $tempPath);
695
-			return false;
696
-		}
697
-
698
-		$freeSpaceInTempInGB = $freeSpaceInTemp / 1024 / 1024 / 1024;
699
-		if ($freeSpaceInTempInGB > 50) {
700
-			return true;
701
-		}
702
-
703
-		$this->logger->warning('Checking the available space in the temporary path resulted in ' . round($freeSpaceInTempInGB, 1) . ' GB instead of the recommended 50GB. Path: ' . $tempPath);
704
-		return false;
705
-	}
706
-
707
-	protected function imageMagickLacksSVGSupport(): bool {
708
-		return extension_loaded('imagick') && count(\Imagick::queryFormats('SVG')) === 0;
709
-	}
710
-
711
-	/**
712
-	 * @return DataResponse
713
-	 */
714
-	public function check() {
715
-		$phpDefaultCharset = new PhpDefaultCharset();
716
-		$phpOutputBuffering = new PhpOutputBuffering();
717
-		$legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator);
718
-		$checkUserCertificates = new CheckUserCertificates($this->l10n, $this->config, $this->urlGenerator);
719
-		$supportedDatabases = new SupportedDatabase($this->l10n, $this->connection);
720
-
721
-		return new DataResponse(
722
-			[
723
-				'isGetenvServerWorking' => !empty(getenv('PATH')),
724
-				'isReadOnlyConfig' => $this->isReadOnlyConfig(),
725
-				'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
726
-				'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
727
-				'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
728
-				'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
729
-				'cronInfo' => $this->getLastCronInfo(),
730
-				'cronErrors' => $this->getCronErrors(),
731
-				'serverHasInternetConnectionProblems' => $this->hasInternetConnectivityProblems(),
732
-				'isMemcacheConfigured' => $this->isMemcacheConfigured(),
733
-				'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
734
-				'isRandomnessSecure' => $this->isRandomnessSecure(),
735
-				'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
736
-				'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
737
-				'phpSupported' => $this->isPhpSupported(),
738
-				'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
739
-				'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
740
-				'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
741
-				'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
742
-				'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
743
-				'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
744
-				'hasOpcacheLoaded' => $this->hasOpcacheLoaded(),
745
-				'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
746
-				'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
747
-				'hasFreeTypeSupport' => $this->hasFreeTypeSupport(),
748
-				'missingPrimaryKeys' => $this->hasMissingPrimaryKeys(),
749
-				'missingIndexes' => $this->hasMissingIndexes(),
750
-				'missingColumns' => $this->hasMissingColumns(),
751
-				'isSqliteUsed' => $this->isSqliteUsed(),
752
-				'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
753
-				'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
754
-				'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
755
-				'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
756
-				'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
757
-				'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
758
-				'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
759
-				'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'),
760
-				'imageMagickLacksSVGSupport' => $this->imageMagickLacksSVGSupport(),
761
-				PhpDefaultCharset::class => ['pass' => $phpDefaultCharset->run(), 'description' => $phpDefaultCharset->description(), 'severity' => $phpDefaultCharset->severity()],
762
-				PhpOutputBuffering::class => ['pass' => $phpOutputBuffering->run(), 'description' => $phpOutputBuffering->description(), 'severity' => $phpOutputBuffering->severity()],
763
-				LegacySSEKeyFormat::class => ['pass' => $legacySSEKeyFormat->run(), 'description' => $legacySSEKeyFormat->description(), 'severity' => $legacySSEKeyFormat->severity(), 'linkToDocumentation' => $legacySSEKeyFormat->linkToDocumentation()],
764
-				CheckUserCertificates::class => ['pass' => $checkUserCertificates->run(), 'description' => $checkUserCertificates->description(), 'severity' => $checkUserCertificates->severity(), 'elements' => $checkUserCertificates->elements()],
765
-				'isDefaultPhoneRegionSet' => $this->config->getSystemValueString('default_phone_region', '') !== '',
766
-				SupportedDatabase::class => ['pass' => $supportedDatabases->run(), 'description' => $supportedDatabases->description(), 'severity' => $supportedDatabases->severity()],
767
-			]
768
-		);
769
-	}
406
+            $formattedTextResponse .= print_r($completeResults, true);
407
+        } else {
408
+            $formattedTextResponse = 'No errors have been found.';
409
+        }
410
+
411
+
412
+        return new DataDisplayResponse(
413
+            $formattedTextResponse,
414
+            Http::STATUS_OK,
415
+            [
416
+                'Content-Type' => 'text/plain',
417
+            ]
418
+        );
419
+    }
420
+
421
+    /**
422
+     * Checks whether a PHP opcache is properly set up
423
+     * @return bool
424
+     */
425
+    protected function isOpcacheProperlySetup() {
426
+        if (!$this->iniGetWrapper->getBool('opcache.enable')) {
427
+            return false;
428
+        }
429
+
430
+        if (!$this->iniGetWrapper->getBool('opcache.save_comments')) {
431
+            return false;
432
+        }
433
+
434
+        if ($this->iniGetWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
435
+            return false;
436
+        }
437
+
438
+        if ($this->iniGetWrapper->getNumeric('opcache.memory_consumption') < 128) {
439
+            return false;
440
+        }
441
+
442
+        if ($this->iniGetWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
443
+            return false;
444
+        }
445
+
446
+        return true;
447
+    }
448
+
449
+    /**
450
+     * Check if the required FreeType functions are present
451
+     * @return bool
452
+     */
453
+    protected function hasFreeTypeSupport() {
454
+        return function_exists('imagettfbbox') && function_exists('imagettftext');
455
+    }
456
+
457
+    protected function hasMissingIndexes(): array {
458
+        $indexInfo = new MissingIndexInformation();
459
+        // Dispatch event so apps can also hint for pending index updates if needed
460
+        $event = new GenericEvent($indexInfo);
461
+        $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event);
462
+
463
+        return $indexInfo->getListOfMissingIndexes();
464
+    }
465
+
466
+    protected function hasMissingPrimaryKeys(): array {
467
+        $info = new MissingPrimaryKeyInformation();
468
+        // Dispatch event so apps can also hint for pending index updates if needed
469
+        $event = new GenericEvent($info);
470
+        $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, $event);
471
+
472
+        return $info->getListOfMissingPrimaryKeys();
473
+    }
474
+
475
+    protected function hasMissingColumns(): array {
476
+        $indexInfo = new MissingColumnInformation();
477
+        // Dispatch event so apps can also hint for pending index updates if needed
478
+        $event = new GenericEvent($indexInfo);
479
+        $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, $event);
480
+
481
+        return $indexInfo->getListOfMissingColumns();
482
+    }
483
+
484
+    protected function isSqliteUsed() {
485
+        return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
486
+    }
487
+
488
+    protected function isReadOnlyConfig(): bool {
489
+        return \OC_Helper::isReadOnlyConfigEnabled();
490
+    }
491
+
492
+    protected function hasValidTransactionIsolationLevel(): bool {
493
+        try {
494
+            if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
495
+                return true;
496
+            }
497
+
498
+            return $this->db->getTransactionIsolation() === TransactionIsolationLevel::READ_COMMITTED;
499
+        } catch (Exception $e) {
500
+            // ignore
501
+        }
502
+
503
+        return true;
504
+    }
505
+
506
+    protected function hasFileinfoInstalled(): bool {
507
+        return \OC_Util::fileInfoLoaded();
508
+    }
509
+
510
+    protected function hasWorkingFileLocking(): bool {
511
+        return !($this->lockingProvider instanceof NoopLockingProvider);
512
+    }
513
+
514
+    protected function getSuggestedOverwriteCliURL(): string {
515
+        $suggestedOverwriteCliUrl = '';
516
+        if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
517
+            $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
518
+            if (!$this->config->getSystemValue('config_is_read_only', false)) {
519
+                // Set the overwrite URL when it was not set yet.
520
+                $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
521
+                $suggestedOverwriteCliUrl = '';
522
+            }
523
+        }
524
+        return $suggestedOverwriteCliUrl;
525
+    }
526
+
527
+    protected function getLastCronInfo(): array {
528
+        $lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
529
+        return [
530
+            'diffInSeconds' => time() - $lastCronRun,
531
+            'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),
532
+            'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs',
533
+        ];
534
+    }
535
+
536
+    protected function getCronErrors() {
537
+        $errors = json_decode($this->config->getAppValue('core', 'cronErrors', ''), true);
538
+
539
+        if (is_array($errors)) {
540
+            return $errors;
541
+        }
542
+
543
+        return [];
544
+    }
545
+
546
+    protected function hasOpcacheLoaded(): bool {
547
+        return extension_loaded('Zend OPcache');
548
+    }
549
+
550
+    /**
551
+     * Iterates through the configured app roots and
552
+     * tests if the subdirectories are owned by the same user than the current user.
553
+     *
554
+     * @return array
555
+     */
556
+    protected function getAppDirsWithDifferentOwner(): array {
557
+        $currentUser = posix_getuid();
558
+        $appDirsWithDifferentOwner = [[]];
559
+
560
+        foreach (OC::$APPSROOTS as $appRoot) {
561
+            if ($appRoot['writable'] === true) {
562
+                $appDirsWithDifferentOwner[] = $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot);
563
+            }
564
+        }
565
+
566
+        $appDirsWithDifferentOwner = array_merge(...$appDirsWithDifferentOwner);
567
+        sort($appDirsWithDifferentOwner);
568
+
569
+        return $appDirsWithDifferentOwner;
570
+    }
571
+
572
+    /**
573
+     * Tests if the directories for one apps directory are writable by the current user.
574
+     *
575
+     * @param int $currentUser The current user
576
+     * @param array $appRoot The app root config
577
+     * @return string[] The none writable directory paths inside the app root
578
+     */
579
+    private function getAppDirsWithDifferentOwnerForAppRoot(int $currentUser, array $appRoot): array {
580
+        $appDirsWithDifferentOwner = [];
581
+        $appsPath = $appRoot['path'];
582
+        $appsDir = new DirectoryIterator($appRoot['path']);
583
+
584
+        foreach ($appsDir as $fileInfo) {
585
+            if ($fileInfo->isDir() && !$fileInfo->isDot()) {
586
+                $absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
587
+                $appDirUser = fileowner($absAppPath);
588
+                if ($appDirUser !== $currentUser) {
589
+                    $appDirsWithDifferentOwner[] = $absAppPath;
590
+                }
591
+            }
592
+        }
593
+
594
+        return $appDirsWithDifferentOwner;
595
+    }
596
+
597
+    /**
598
+     * Checks for potential PHP modules that would improve the instance
599
+     *
600
+     * @return string[] A list of PHP modules that is recommended
601
+     */
602
+    protected function hasRecommendedPHPModules(): array {
603
+        $recommendedPHPModules = [];
604
+
605
+        if (!extension_loaded('intl')) {
606
+            $recommendedPHPModules[] = 'intl';
607
+        }
608
+
609
+        if (!extension_loaded('bcmath')) {
610
+            $recommendedPHPModules[] = 'bcmath';
611
+        }
612
+
613
+        if (!extension_loaded('gmp')) {
614
+            $recommendedPHPModules[] = 'gmp';
615
+        }
616
+
617
+        if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
618
+            if (!extension_loaded('imagick')) {
619
+                $recommendedPHPModules[] = 'imagick';
620
+            }
621
+        }
622
+
623
+        return $recommendedPHPModules;
624
+    }
625
+
626
+    protected function isMysqlUsedWithoutUTF8MB4(): bool {
627
+        return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
628
+    }
629
+
630
+    protected function hasBigIntConversionPendingColumns(): array {
631
+        // copy of ConvertFilecacheBigInt::getColumnsByTable()
632
+        $tables = [
633
+            'activity' => ['activity_id', 'object_id'],
634
+            'activity_mq' => ['mail_id'],
635
+            'authtoken' => ['id'],
636
+            'bruteforce_attempts' => ['id'],
637
+            'federated_reshares' => ['share_id'],
638
+            'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
639
+            'filecache_extended' => ['fileid'],
640
+            'file_locks' => ['id'],
641
+            'jobs' => ['id'],
642
+            'mimetypes' => ['id'],
643
+            'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'],
644
+            'share_external' => ['id', 'parent'],
645
+            'storages' => ['numeric_id'],
646
+        ];
647
+
648
+        $schema = new SchemaWrapper($this->db);
649
+        $isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform;
650
+        $pendingColumns = [];
651
+
652
+        foreach ($tables as $tableName => $columns) {
653
+            if (!$schema->hasTable($tableName)) {
654
+                continue;
655
+            }
656
+
657
+            $table = $schema->getTable($tableName);
658
+            foreach ($columns as $columnName) {
659
+                $column = $table->getColumn($columnName);
660
+                $isAutoIncrement = $column->getAutoincrement();
661
+                $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
662
+                if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
663
+                    $pendingColumns[] = $tableName . '.' . $columnName;
664
+                }
665
+            }
666
+        }
667
+
668
+        return $pendingColumns;
669
+    }
670
+
671
+    protected function isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(): bool {
672
+        $objectStore = $this->config->getSystemValue('objectstore', null);
673
+        $objectStoreMultibucket = $this->config->getSystemValue('objectstore_multibucket', null);
674
+
675
+        if (!isset($objectStoreMultibucket) && !isset($objectStore)) {
676
+            return true;
677
+        }
678
+
679
+        if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== 'OC\\Files\\ObjectStore\\S3') {
680
+            return true;
681
+        }
682
+
683
+        if (isset($objectStore['class']) && $objectStore['class'] !== 'OC\\Files\\ObjectStore\\S3') {
684
+            return true;
685
+        }
686
+
687
+        $tempPath = sys_get_temp_dir();
688
+        if (!is_dir($tempPath)) {
689
+            $this->logger->error('Error while checking the temporary PHP path - it was not properly set to a directory. value: ' . $tempPath);
690
+            return false;
691
+        }
692
+        $freeSpaceInTemp = disk_free_space($tempPath);
693
+        if ($freeSpaceInTemp === false) {
694
+            $this->logger->error('Error while checking the available disk space of temporary PHP path - no free disk space returned. temporary path: ' . $tempPath);
695
+            return false;
696
+        }
697
+
698
+        $freeSpaceInTempInGB = $freeSpaceInTemp / 1024 / 1024 / 1024;
699
+        if ($freeSpaceInTempInGB > 50) {
700
+            return true;
701
+        }
702
+
703
+        $this->logger->warning('Checking the available space in the temporary path resulted in ' . round($freeSpaceInTempInGB, 1) . ' GB instead of the recommended 50GB. Path: ' . $tempPath);
704
+        return false;
705
+    }
706
+
707
+    protected function imageMagickLacksSVGSupport(): bool {
708
+        return extension_loaded('imagick') && count(\Imagick::queryFormats('SVG')) === 0;
709
+    }
710
+
711
+    /**
712
+     * @return DataResponse
713
+     */
714
+    public function check() {
715
+        $phpDefaultCharset = new PhpDefaultCharset();
716
+        $phpOutputBuffering = new PhpOutputBuffering();
717
+        $legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator);
718
+        $checkUserCertificates = new CheckUserCertificates($this->l10n, $this->config, $this->urlGenerator);
719
+        $supportedDatabases = new SupportedDatabase($this->l10n, $this->connection);
720
+
721
+        return new DataResponse(
722
+            [
723
+                'isGetenvServerWorking' => !empty(getenv('PATH')),
724
+                'isReadOnlyConfig' => $this->isReadOnlyConfig(),
725
+                'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
726
+                'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
727
+                'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
728
+                'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
729
+                'cronInfo' => $this->getLastCronInfo(),
730
+                'cronErrors' => $this->getCronErrors(),
731
+                'serverHasInternetConnectionProblems' => $this->hasInternetConnectivityProblems(),
732
+                'isMemcacheConfigured' => $this->isMemcacheConfigured(),
733
+                'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
734
+                'isRandomnessSecure' => $this->isRandomnessSecure(),
735
+                'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
736
+                'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
737
+                'phpSupported' => $this->isPhpSupported(),
738
+                'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
739
+                'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
740
+                'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
741
+                'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
742
+                'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
743
+                'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
744
+                'hasOpcacheLoaded' => $this->hasOpcacheLoaded(),
745
+                'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
746
+                'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
747
+                'hasFreeTypeSupport' => $this->hasFreeTypeSupport(),
748
+                'missingPrimaryKeys' => $this->hasMissingPrimaryKeys(),
749
+                'missingIndexes' => $this->hasMissingIndexes(),
750
+                'missingColumns' => $this->hasMissingColumns(),
751
+                'isSqliteUsed' => $this->isSqliteUsed(),
752
+                'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
753
+                'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
754
+                'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
755
+                'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
756
+                'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
757
+                'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
758
+                'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
759
+                'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'),
760
+                'imageMagickLacksSVGSupport' => $this->imageMagickLacksSVGSupport(),
761
+                PhpDefaultCharset::class => ['pass' => $phpDefaultCharset->run(), 'description' => $phpDefaultCharset->description(), 'severity' => $phpDefaultCharset->severity()],
762
+                PhpOutputBuffering::class => ['pass' => $phpOutputBuffering->run(), 'description' => $phpOutputBuffering->description(), 'severity' => $phpOutputBuffering->severity()],
763
+                LegacySSEKeyFormat::class => ['pass' => $legacySSEKeyFormat->run(), 'description' => $legacySSEKeyFormat->description(), 'severity' => $legacySSEKeyFormat->severity(), 'linkToDocumentation' => $legacySSEKeyFormat->linkToDocumentation()],
764
+                CheckUserCertificates::class => ['pass' => $checkUserCertificates->run(), 'description' => $checkUserCertificates->description(), 'severity' => $checkUserCertificates->severity(), 'elements' => $checkUserCertificates->elements()],
765
+                'isDefaultPhoneRegionSet' => $this->config->getSystemValueString('default_phone_region', '') !== '',
766
+                SupportedDatabase::class => ['pass' => $supportedDatabases->run(), 'description' => $supportedDatabases->description(), 'severity' => $supportedDatabases->severity()],
767
+            ]
768
+        );
769
+    }
770 770
 }
Please login to merge, or discard this patch.