CheckSetupController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Bjoern Schiessle <bjoern@schiessle.org>
  7. * @author Derek <derek.kelly27@gmail.com>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Ko- <k.stoffelen@cs.ru.nl>
  10. * @author Lukas Reschke <lukas@statuscode.ch>
  11. * @author Morris Jobke <hey@morrisjobke.de>
  12. * @author Robin McCorkell <robin@mccorkell.me.uk>
  13. * @author Roeland Jago Douma <roeland@famdouma.nl>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. namespace OC\Settings\Controller;
  31. use bantu\IniGetWrapper\IniGetWrapper;
  32. use DirectoryIterator;
  33. use Doctrine\DBAL\DBALException;
  34. use Doctrine\DBAL\Platforms\SqlitePlatform;
  35. use Doctrine\DBAL\Types\Type;
  36. use GuzzleHttp\Exception\ClientException;
  37. use OC;
  38. use OC\AppFramework\Http;
  39. use OC\DB\Connection;
  40. use OC\DB\MissingIndexInformation;
  41. use OC\DB\SchemaWrapper;
  42. use OC\IntegrityCheck\Checker;
  43. use OC\Lock\NoopLockingProvider;
  44. use OC\MemoryInfo;
  45. use OCP\AppFramework\Controller;
  46. use OCP\AppFramework\Http\DataDisplayResponse;
  47. use OCP\AppFramework\Http\DataResponse;
  48. use OCP\AppFramework\Http\RedirectResponse;
  49. use OCP\Http\Client\IClientService;
  50. use OCP\IConfig;
  51. use OCP\IDateTimeFormatter;
  52. use OCP\IDBConnection;
  53. use OCP\IL10N;
  54. use OCP\ILogger;
  55. use OCP\IRequest;
  56. use OCP\IURLGenerator;
  57. use OCP\Lock\ILockingProvider;
  58. use OCP\Security\ISecureRandom;
  59. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  60. use Symfony\Component\EventDispatcher\GenericEvent;
  61. /**
  62. * @package OC\Settings\Controller
  63. */
  64. class CheckSetupController extends Controller {
  65. /** @var IConfig */
  66. private $config;
  67. /** @var IClientService */
  68. private $clientService;
  69. /** @var IURLGenerator */
  70. private $urlGenerator;
  71. /** @var IL10N */
  72. private $l10n;
  73. /** @var Checker */
  74. private $checker;
  75. /** @var ILogger */
  76. private $logger;
  77. /** @var EventDispatcherInterface */
  78. private $dispatcher;
  79. /** @var IDBConnection|Connection */
  80. private $db;
  81. /** @var ILockingProvider */
  82. private $lockingProvider;
  83. /** @var IDateTimeFormatter */
  84. private $dateTimeFormatter;
  85. /** @var MemoryInfo */
  86. private $memoryInfo;
  87. /** @var ISecureRandom */
  88. private $secureRandom;
  89. public function __construct($AppName,
  90. IRequest $request,
  91. IConfig $config,
  92. IClientService $clientService,
  93. IURLGenerator $urlGenerator,
  94. IL10N $l10n,
  95. Checker $checker,
  96. ILogger $logger,
  97. EventDispatcherInterface $dispatcher,
  98. IDBConnection $db,
  99. ILockingProvider $lockingProvider,
  100. IDateTimeFormatter $dateTimeFormatter,
  101. MemoryInfo $memoryInfo,
  102. ISecureRandom $secureRandom) {
  103. parent::__construct($AppName, $request);
  104. $this->config = $config;
  105. $this->clientService = $clientService;
  106. $this->urlGenerator = $urlGenerator;
  107. $this->l10n = $l10n;
  108. $this->checker = $checker;
  109. $this->logger = $logger;
  110. $this->dispatcher = $dispatcher;
  111. $this->db = $db;
  112. $this->lockingProvider = $lockingProvider;
  113. $this->dateTimeFormatter = $dateTimeFormatter;
  114. $this->memoryInfo = $memoryInfo;
  115. $this->secureRandom = $secureRandom;
  116. }
  117. /**
  118. * Checks if the server can connect to the internet using HTTPS and HTTP
  119. * @return bool
  120. */
  121. private function hasInternetConnectivityProblems(): bool {
  122. if ($this->config->getSystemValue('has_internet_connection', true) === false) {
  123. return false;
  124. }
  125. $siteArray = $this->config->getSystemValue('connectivity_check_domains', [
  126. 'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'
  127. ]);
  128. foreach($siteArray as $site) {
  129. if ($this->isSiteReachable($site)) {
  130. return false;
  131. }
  132. }
  133. return true;
  134. }
  135. /**
  136. * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP
  137. * @return bool
  138. */
  139. private function isSiteReachable($sitename) {
  140. $httpSiteName = 'http://' . $sitename . '/';
  141. $httpsSiteName = 'https://' . $sitename . '/';
  142. try {
  143. $client = $this->clientService->newClient();
  144. $client->get($httpSiteName);
  145. $client->get($httpsSiteName);
  146. } catch (\Exception $e) {
  147. $this->logger->logException($e, ['app' => 'internet_connection_check']);
  148. return false;
  149. }
  150. return true;
  151. }
  152. /**
  153. * Checks whether a local memcache is installed or not
  154. * @return bool
  155. */
  156. private function isMemcacheConfigured() {
  157. return $this->config->getSystemValue('memcache.local', null) !== null;
  158. }
  159. /**
  160. * Whether PHP can generate "secure" pseudorandom integers
  161. *
  162. * @return bool
  163. */
  164. private function isRandomnessSecure() {
  165. try {
  166. $this->secureRandom->generate(1);
  167. } catch (\Exception $ex) {
  168. return false;
  169. }
  170. return true;
  171. }
  172. /**
  173. * Public for the sake of unit-testing
  174. *
  175. * @return array
  176. */
  177. protected function getCurlVersion() {
  178. return curl_version();
  179. }
  180. /**
  181. * Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do
  182. * have multiple bugs which likely lead to problems in combination with
  183. * functionality required by ownCloud such as SNI.
  184. *
  185. * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546
  186. * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172
  187. * @return string
  188. */
  189. private function isUsedTlsLibOutdated() {
  190. // Don't run check when:
  191. // 1. Server has `has_internet_connection` set to false
  192. // 2. AppStore AND S2S is disabled
  193. if(!$this->config->getSystemValue('has_internet_connection', true)) {
  194. return '';
  195. }
  196. if(!$this->config->getSystemValue('appstoreenabled', true)
  197. && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no'
  198. && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') {
  199. return '';
  200. }
  201. $versionString = $this->getCurlVersion();
  202. if(isset($versionString['ssl_version'])) {
  203. $versionString = $versionString['ssl_version'];
  204. } else {
  205. return '';
  206. }
  207. $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing');
  208. if(!$this->config->getSystemValue('appstoreenabled', true)) {
  209. $features = (string)$this->l10n->t('Federated Cloud Sharing');
  210. }
  211. // Check if at least OpenSSL after 1.01d or 1.0.2b
  212. if(strpos($versionString, 'OpenSSL/') === 0) {
  213. $majorVersion = substr($versionString, 8, 5);
  214. $patchRelease = substr($versionString, 13, 6);
  215. if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) ||
  216. ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) {
  217. 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]);
  218. }
  219. }
  220. // Check if NSS and perform heuristic check
  221. if(strpos($versionString, 'NSS/') === 0) {
  222. try {
  223. $firstClient = $this->clientService->newClient();
  224. $firstClient->get('https://nextcloud.com/');
  225. $secondClient = $this->clientService->newClient();
  226. $secondClient->get('https://nextcloud.com/');
  227. } catch (ClientException $e) {
  228. if($e->getResponse()->getStatusCode() === 400) {
  229. 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]);
  230. }
  231. }
  232. }
  233. return '';
  234. }
  235. /**
  236. * Whether the version is outdated
  237. *
  238. * @return bool
  239. */
  240. protected function isPhpOutdated() {
  241. if (version_compare(PHP_VERSION, '7.1.0', '<')) {
  242. return true;
  243. }
  244. return false;
  245. }
  246. /**
  247. * Whether the php version is still supported (at time of release)
  248. * according to: https://secure.php.net/supported-versions.php
  249. *
  250. * @return array
  251. */
  252. private function isPhpSupported() {
  253. return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION];
  254. }
  255. /**
  256. * Check if the reverse proxy configuration is working as expected
  257. *
  258. * @return bool
  259. */
  260. private function forwardedForHeadersWorking() {
  261. $trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
  262. $remoteAddress = $this->request->getHeader('REMOTE_ADDR');
  263. if (empty($trustedProxies) && $this->request->getHeader('X-Forwarded-Host') !== '') {
  264. return false;
  265. }
  266. if (\is_array($trustedProxies) && \in_array($remoteAddress, $trustedProxies, true)) {
  267. return $remoteAddress !== $this->request->getRemoteAddress();
  268. }
  269. // either not enabled or working correctly
  270. return true;
  271. }
  272. /**
  273. * Checks if the correct memcache module for PHP is installed. Only
  274. * fails if memcached is configured and the working module is not installed.
  275. *
  276. * @return bool
  277. */
  278. private function isCorrectMemcachedPHPModuleInstalled() {
  279. if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') {
  280. return true;
  281. }
  282. // there are two different memcached modules for PHP
  283. // we only support memcached and not memcache
  284. // https://code.google.com/p/memcached/wiki/PHPClientComparison
  285. return !(!extension_loaded('memcached') && extension_loaded('memcache'));
  286. }
  287. /**
  288. * Checks if set_time_limit is not disabled.
  289. *
  290. * @return bool
  291. */
  292. private function isSettimelimitAvailable() {
  293. if (function_exists('set_time_limit')
  294. && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
  295. return true;
  296. }
  297. return false;
  298. }
  299. /**
  300. * @return RedirectResponse
  301. */
  302. public function rescanFailedIntegrityCheck() {
  303. $this->checker->runInstanceVerification();
  304. return new RedirectResponse(
  305. $this->urlGenerator->linkToRoute('settings.AdminSettings.index')
  306. );
  307. }
  308. /**
  309. * @NoCSRFRequired
  310. * @return DataResponse
  311. */
  312. public function getFailedIntegrityCheckFiles() {
  313. if(!$this->checker->isCodeCheckEnforced()) {
  314. return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
  315. }
  316. $completeResults = $this->checker->getResults();
  317. if(!empty($completeResults)) {
  318. $formattedTextResponse = 'Technical information
  319. =====================
  320. The following list covers which files have failed the integrity check. Please read
  321. the previous linked documentation to learn more about the errors and how to fix
  322. them.
  323. Results
  324. =======
  325. ';
  326. foreach($completeResults as $context => $contextResult) {
  327. $formattedTextResponse .= "- $context\n";
  328. foreach($contextResult as $category => $result) {
  329. $formattedTextResponse .= "\t- $category\n";
  330. if($category !== 'EXCEPTION') {
  331. foreach ($result as $key => $results) {
  332. $formattedTextResponse .= "\t\t- $key\n";
  333. }
  334. } else {
  335. foreach ($result as $key => $results) {
  336. $formattedTextResponse .= "\t\t- $results\n";
  337. }
  338. }
  339. }
  340. }
  341. $formattedTextResponse .= '
  342. Raw output
  343. ==========
  344. ';
  345. $formattedTextResponse .= print_r($completeResults, true);
  346. } else {
  347. $formattedTextResponse = 'No errors have been found.';
  348. }
  349. $response = new DataDisplayResponse(
  350. $formattedTextResponse,
  351. Http::STATUS_OK,
  352. [
  353. 'Content-Type' => 'text/plain',
  354. ]
  355. );
  356. return $response;
  357. }
  358. /**
  359. * Checks whether a PHP opcache is properly set up
  360. * @return bool
  361. */
  362. protected function isOpcacheProperlySetup() {
  363. $iniWrapper = new IniGetWrapper();
  364. if(!$iniWrapper->getBool('opcache.enable')) {
  365. return false;
  366. }
  367. if(!$iniWrapper->getBool('opcache.save_comments')) {
  368. return false;
  369. }
  370. if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
  371. return false;
  372. }
  373. if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) {
  374. return false;
  375. }
  376. if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
  377. return false;
  378. }
  379. return true;
  380. }
  381. /**
  382. * Check if the required FreeType functions are present
  383. * @return bool
  384. */
  385. protected function hasFreeTypeSupport() {
  386. return function_exists('imagettfbbox') && function_exists('imagettftext');
  387. }
  388. protected function hasMissingIndexes(): array {
  389. $indexInfo = new MissingIndexInformation();
  390. // Dispatch event so apps can also hint for pending index updates if needed
  391. $event = new GenericEvent($indexInfo);
  392. $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event);
  393. return $indexInfo->getListOfMissingIndexes();
  394. }
  395. protected function isSqliteUsed() {
  396. return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
  397. }
  398. protected function isReadOnlyConfig(): bool {
  399. return \OC_Helper::isReadOnlyConfigEnabled();
  400. }
  401. protected function hasValidTransactionIsolationLevel(): bool {
  402. try {
  403. if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
  404. return true;
  405. }
  406. return $this->db->getTransactionIsolation() === Connection::TRANSACTION_READ_COMMITTED;
  407. } catch (DBALException $e) {
  408. // ignore
  409. }
  410. return true;
  411. }
  412. protected function hasFileinfoInstalled(): bool {
  413. return \OC_Util::fileInfoLoaded();
  414. }
  415. protected function hasWorkingFileLocking(): bool {
  416. return !($this->lockingProvider instanceof NoopLockingProvider);
  417. }
  418. protected function getSuggestedOverwriteCliURL(): string {
  419. $suggestedOverwriteCliUrl = '';
  420. if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
  421. $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
  422. if (!$this->config->getSystemValue('config_is_read_only', false)) {
  423. // Set the overwrite URL when it was not set yet.
  424. $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
  425. $suggestedOverwriteCliUrl = '';
  426. }
  427. }
  428. return $suggestedOverwriteCliUrl;
  429. }
  430. protected function getLastCronInfo(): array {
  431. $lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
  432. return [
  433. 'diffInSeconds' => time() - $lastCronRun,
  434. 'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),
  435. 'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs',
  436. ];
  437. }
  438. protected function getCronErrors() {
  439. $errors = json_decode($this->config->getAppValue('core', 'cronErrors', ''), true);
  440. if (is_array($errors)) {
  441. return $errors;
  442. }
  443. return [];
  444. }
  445. protected function isPHPMailerUsed(): bool {
  446. return $this->config->getSystemValue('mail_smtpmode', 'smtp') === 'php';
  447. }
  448. protected function hasOpcacheLoaded(): bool {
  449. return function_exists('opcache_get_status');
  450. }
  451. /**
  452. * Iterates through the configured app roots and
  453. * tests if the subdirectories are owned by the same user than the current user.
  454. *
  455. * @return array
  456. */
  457. protected function getAppDirsWithDifferentOwner(): array {
  458. $currentUser = posix_getuid();
  459. $appDirsWithDifferentOwner = [[]];
  460. foreach (OC::$APPSROOTS as $appRoot) {
  461. if ($appRoot['writable'] === true) {
  462. $appDirsWithDifferentOwner[] = $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot);
  463. }
  464. }
  465. $appDirsWithDifferentOwner = array_merge(...$appDirsWithDifferentOwner);
  466. sort($appDirsWithDifferentOwner);
  467. return $appDirsWithDifferentOwner;
  468. }
  469. /**
  470. * Tests if the directories for one apps directory are writable by the current user.
  471. *
  472. * @param int $currentUser The current user
  473. * @param array $appRoot The app root config
  474. * @return string[] The none writable directory paths inside the app root
  475. */
  476. private function getAppDirsWithDifferentOwnerForAppRoot(int $currentUser, array $appRoot): array {
  477. $appDirsWithDifferentOwner = [];
  478. $appsPath = $appRoot['path'];
  479. $appsDir = new DirectoryIterator($appRoot['path']);
  480. foreach ($appsDir as $fileInfo) {
  481. if ($fileInfo->isDir() && !$fileInfo->isDot()) {
  482. $absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
  483. $appDirUser = fileowner($absAppPath);
  484. if ($appDirUser !== $currentUser) {
  485. $appDirsWithDifferentOwner[] = $absAppPath;
  486. }
  487. }
  488. }
  489. return $appDirsWithDifferentOwner;
  490. }
  491. /**
  492. * Checks for potential PHP modules that would improve the instance
  493. *
  494. * @return string[] A list of PHP modules that is recommended
  495. */
  496. protected function hasRecommendedPHPModules(): array {
  497. $recommendedPHPModules = [];
  498. if (!extension_loaded('intl')) {
  499. $recommendedPHPModules[] = 'intl';
  500. }
  501. if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
  502. if (!extension_loaded('imagick')) {
  503. $recommendedPHPModules[] = 'imagick';
  504. }
  505. }
  506. return $recommendedPHPModules;
  507. }
  508. protected function isMysqlUsedWithoutUTF8MB4(): bool {
  509. return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
  510. }
  511. protected function hasBigIntConversionPendingColumns(): array {
  512. // copy of ConvertFilecacheBigInt::getColumnsByTable()
  513. $tables = [
  514. 'activity' => ['activity_id', 'object_id'],
  515. 'activity_mq' => ['mail_id'],
  516. 'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
  517. 'mimetypes' => ['id'],
  518. 'storages' => ['numeric_id'],
  519. ];
  520. $schema = new SchemaWrapper($this->db);
  521. $isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform;
  522. $pendingColumns = [];
  523. foreach ($tables as $tableName => $columns) {
  524. if (!$schema->hasTable($tableName)) {
  525. continue;
  526. }
  527. $table = $schema->getTable($tableName);
  528. foreach ($columns as $columnName) {
  529. $column = $table->getColumn($columnName);
  530. $isAutoIncrement = $column->getAutoincrement();
  531. $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
  532. if ($column->getType()->getName() !== Type::BIGINT && !$isAutoIncrementOnSqlite) {
  533. $pendingColumns[] = $tableName . '.' . $columnName;
  534. }
  535. }
  536. }
  537. return $pendingColumns;
  538. }
  539. protected function isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(): bool {
  540. $objectStore = $this->config->getSystemValue('objectstore', null);
  541. $objectStoreMultibucket = $this->config->getSystemValue('objectstore_multibucket', null);
  542. if (!isset($objectStoreMultibucket) && !isset($objectStore)) {
  543. return true;
  544. }
  545. if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== 'OC\\Files\\ObjectStore\\S3') {
  546. return true;
  547. }
  548. if (isset($objectStore['class']) && $objectStore['class'] !== 'OC\\Files\\ObjectStore\\S3') {
  549. return true;
  550. }
  551. $tempPath = sys_get_temp_dir();
  552. if (!is_dir($tempPath)) {
  553. $this->logger->error('Error while checking the temporary PHP path - it was not properly set to a directory. value: ' . $tempPath);
  554. return false;
  555. }
  556. $freeSpaceInTemp = disk_free_space($tempPath);
  557. if ($freeSpaceInTemp === false) {
  558. $this->logger->error('Error while checking the available disk space of temporary PHP path - no free disk space returned. temporary path: ' . $tempPath);
  559. return false;
  560. }
  561. $freeSpaceInTempInGB = $freeSpaceInTemp / 1024 / 1024 / 1024;
  562. if ($freeSpaceInTempInGB > 50) {
  563. return true;
  564. }
  565. $this->logger->warning('Checking the available space in the temporary path resulted in ' . round($freeSpaceInTempInGB, 1) . ' GB instead of the recommended 50GB. Path: ' . $tempPath);
  566. return false;
  567. }
  568. /**
  569. * @return DataResponse
  570. */
  571. public function check() {
  572. return new DataResponse(
  573. [
  574. 'isGetenvServerWorking' => !empty(getenv('PATH')),
  575. 'isReadOnlyConfig' => $this->isReadOnlyConfig(),
  576. 'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
  577. 'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
  578. 'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
  579. 'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
  580. 'cronInfo' => $this->getLastCronInfo(),
  581. 'cronErrors' => $this->getCronErrors(),
  582. 'serverHasInternetConnectionProblems' => $this->hasInternetConnectivityProblems(),
  583. 'isMemcacheConfigured' => $this->isMemcacheConfigured(),
  584. 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
  585. 'isRandomnessSecure' => $this->isRandomnessSecure(),
  586. 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
  587. 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
  588. 'phpSupported' => $this->isPhpSupported(),
  589. 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
  590. 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
  591. 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
  592. 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
  593. 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
  594. 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
  595. 'hasOpcacheLoaded' => $this->hasOpcacheLoaded(),
  596. 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
  597. 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
  598. 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(),
  599. 'missingIndexes' => $this->hasMissingIndexes(),
  600. 'isSqliteUsed' => $this->isSqliteUsed(),
  601. 'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
  602. 'isPHPMailerUsed' => $this->isPHPMailerUsed(),
  603. 'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin'),
  604. 'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
  605. 'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
  606. 'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
  607. 'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
  608. 'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
  609. 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
  610. ]
  611. );
  612. }
  613. }