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