aboutsummaryrefslogtreecommitdiffstats
path: root/settings/Controller/CheckSetupController.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-06-13 11:45:49 +0200
committerMorris Jobke <hey@morrisjobke.de>2018-06-13 15:25:08 +0200
commit9c4aecb53956df33ef16c51f6a195320b1032d58 (patch)
tree0cd5fba6a0399e5d0eb934c6adab6d8507f3eb93 /settings/Controller/CheckSetupController.php
parentcd87a40eb3a2b7026dfd1822e6e43e131edd3423 (diff)
downloadnextcloud-server-9c4aecb53956df33ef16c51f6a195320b1032d58.tar.gz
nextcloud-server-9c4aecb53956df33ef16c51f6a195320b1032d58.zip
Merge all setup checks into one controller
* renamed hasMissingIndexes to missingIndexes Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'settings/Controller/CheckSetupController.php')
-rw-r--r--settings/Controller/CheckSetupController.php98
1 files changed, 96 insertions, 2 deletions
diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php
index b4619ee4bb0..f83d0966eda 100644
--- a/settings/Controller/CheckSetupController.php
+++ b/settings/Controller/CheckSetupController.php
@@ -31,21 +31,27 @@
namespace OC\Settings\Controller;
use bantu\IniGetWrapper\IniGetWrapper;
+use Doctrine\DBAL\DBALException;
+use Doctrine\DBAL\Platforms\SqlitePlatform;
use GuzzleHttp\Exception\ClientException;
use OC\AppFramework\Http;
+use OC\DB\Connection;
use OC\DB\MissingIndexInformation;
use OC\IntegrityCheck\Checker;
+use OC\Lock\NoopLockingProvider;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
+use OCP\IDateTimeFormatter;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IURLGenerator;
+use OCP\Lock\ILockingProvider;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
@@ -69,6 +75,12 @@ class CheckSetupController extends Controller {
private $logger;
/** @var EventDispatcherInterface */
private $dispatcher;
+ /** @var IDBConnection|Connection */
+ private $db;
+ /** @var ILockingProvider */
+ private $lockingProvider;
+ /** @var IDateTimeFormatter */
+ private $dateTimeFormatter;
public function __construct($AppName,
IRequest $request,
@@ -79,7 +91,10 @@ class CheckSetupController extends Controller {
IL10N $l10n,
Checker $checker,
ILogger $logger,
- EventDispatcherInterface $dispatcher) {
+ EventDispatcherInterface $dispatcher,
+ IDBConnection $db,
+ ILockingProvider $lockingProvider,
+ IDateTimeFormatter $dateTimeFormatter) {
parent::__construct($AppName, $request);
$this->config = $config;
$this->clientService = $clientService;
@@ -89,6 +104,9 @@ class CheckSetupController extends Controller {
$this->checker = $checker;
$this->logger = $logger;
$this->dispatcher = $dispatcher;
+ $this->db = $db;
+ $this->lockingProvider = $lockingProvider;
+ $this->dateTimeFormatter = $dateTimeFormatter;
}
/**
@@ -424,16 +442,92 @@ Raw output
return $indexInfo->getListOfMissingIndexes();
}
+ /**
+ * warn if outdated version of a memcache module is used
+ */
+ protected function getOutdatedCaches(): array {
+ $caches = [
+ 'apcu' => ['name' => 'APCu', 'version' => '4.0.6'],
+ 'redis' => ['name' => 'Redis', 'version' => '2.2.5'],
+ ];
+ $outdatedCaches = [];
+ foreach ($caches as $php_module => $data) {
+ $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<');
+ if ($isOutdated) {
+ $outdatedCaches[] = $data;
+ }
+ }
+
+ return $outdatedCaches;
+ }
+
protected function isSqliteUsed() {
return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
}
+ protected function isReadOnlyConfig(): bool {
+ return \OC_Helper::isReadOnlyConfigEnabled();
+ }
+
+ protected function hasValidTransactionIsolationLevel(): bool {
+ try {
+ if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
+ return true;
+ }
+
+ return $this->db->getTransactionIsolation() === Connection::TRANSACTION_READ_COMMITTED;
+ } catch (DBALException $e) {
+ // ignore
+ }
+
+ return true;
+ }
+
+ protected function hasFileinfoInstalled(): bool {
+ return \OC_Util::fileInfoLoaded();
+ }
+
+ protected function hasWorkingFileLocking(): bool {
+ return !($this->lockingProvider instanceof NoopLockingProvider);
+ }
+
+ protected function getSuggestedOverwriteCliURL(): string {
+ $suggestedOverwriteCliUrl = '';
+ if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
+ $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
+ if (!$this->config->getSystemValue('config_is_read_only', false)) {
+ // Set the overwrite URL when it was not set yet.
+ $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
+ $suggestedOverwriteCliUrl = '';
+ }
+ }
+ return $suggestedOverwriteCliUrl;
+ }
+
+ protected function getLastCronInfo(): array {
+ $lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
+ return [
+ 'diffInSeconds' => time() - $lastCronRun,
+ 'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),
+ 'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs',
+ ];
+ }
+
/**
* @return DataResponse
*/
public function check() {
return new DataResponse(
[
+ 'isGetenvServerWorking' => !empty(getenv('PATH')),
+ 'isReadOnlyConfig' => $this->isReadOnlyConfig(),
+ 'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
+ 'outdatedCaches' => $this->getOutdatedCaches(),
+ 'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
+ 'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
+ 'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
+ 'cronInfo' => $this->getLastCronInfo(),
+ 'cronErrors' => json_decode($this->config->getAppValue('core', 'cronErrors', ''), true),
'serverHasInternetConnection' => $this->isInternetConnectionWorking(),
'isMemcacheConfigured' => $this->isMemcacheConfigured(),
'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
@@ -450,7 +544,7 @@ Raw output
'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
'hasFreeTypeSupport' => $this->hasFreeTypeSupport(),
- 'hasMissingIndexes' => $this->hasMissingIndexes(),
+ 'missingIndexes' => $this->hasMissingIndexes(),
'isSqliteUsed' => $this->isSqliteUsed(),
'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
]