diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-03-10 23:44:29 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-03-11 09:27:12 +0100 |
commit | 6c1a1234f8c5a064a72cb23cd397edcb9c6f0577 (patch) | |
tree | 531cc7f3dd6b70f6604f719828f7ba98c37dda63 /core/setup | |
parent | 81fa9550a0e136421c1dacad3d26fdb19e9c63a3 (diff) | |
download | nextcloud-server-6c1a1234f8c5a064a72cb23cd397edcb9c6f0577.tar.gz nextcloud-server-6c1a1234f8c5a064a72cb23cd397edcb9c6f0577.zip |
Properly handle available databases at runtime and respect setup checks in command line as well
Diffstat (limited to 'core/setup')
-rw-r--r-- | core/setup/controller.php | 121 |
1 files changed, 9 insertions, 112 deletions
diff --git a/core/setup/controller.php b/core/setup/controller.php index cc7f4a3a985..fa3637dd8fd 100644 --- a/core/setup/controller.php +++ b/core/setup/controller.php @@ -9,42 +9,20 @@ namespace OC\Core\Setup; -use bantu\IniGetWrapper\IniGetWrapper; -use OCP\IConfig; -use OCP\IL10N; +use OC\Setup; class Controller { - /** - * @var \OCP\IConfig - */ - protected $config; - /** @var IniGetWrapper */ - protected $iniWrapper; - /** @var IL10N */ - protected $l10n; - /** @var \OC_Defaults */ - protected $defaults; - - /** - * @var string - */ + /** @var Setup */ + protected $setupHelper; + /** @var string */ private $autoConfigFile; /** - * @param IConfig $config - * @param IniGetWrapper $iniWrapper - * @param IL10N $l10n - * @param \OC_Defaults $defaults + * @param Setup $setupHelper */ - function __construct(IConfig $config, - IniGetWrapper $iniWrapper, - IL10N $l10n, - \OC_Defaults $defaults) { + function __construct(Setup $setupHelper) { $this->autoConfigFile = \OC::$SERVERROOT.'/config/autoconfig.php'; - $this->config = $config; - $this->iniWrapper = $iniWrapper; - $this->l10n = $l10n; - $this->defaults = $defaults; + $this->setupHelper = $setupHelper; } /** @@ -53,7 +31,7 @@ class Controller { public function run($post) { // Check for autosetup: $post = $this->loadAutoConfig($post); - $opts = $this->getSystemInfo(); + $opts = $this->setupHelper->getSystemInfo(); // convert 'abcpassword' to 'abcpass' if (isset($post['adminpassword'])) { @@ -65,7 +43,7 @@ class Controller { if(isset($post['install']) AND $post['install']=='true') { // We have to launch the installation process : - $e = \OC\Setup::install($post); + $e = $this->setupHelper->install($post); $errors = array('errors' => $e); if(count($e) > 0) { @@ -126,85 +104,4 @@ class Controller { return $post; } - - /** - * Gathers system information like database type and does - * a few system checks. - * - * @return array of system info, including an "errors" value - * in case of errors/warnings - */ - public function getSystemInfo() { - $setup = new \OC\Setup($this->config); - $databases = $setup->getSupportedDatabases(); - - $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data'); - - $errors = array(); - - // Create data directory to test whether the .htaccess works - // Notice that this is not necessarily the same data directory as the one - // that will effectively be used. - @mkdir($dataDir); - $htAccessWorking = true; - if (is_dir($dataDir) && is_writable($dataDir)) { - // Protect data directory here, so we can test if the protection is working - \OC\Setup::protectDataDirectory(); - - try { - $htAccessWorking = \OC_Util::isHtaccessWorking(); - } catch (\OC\HintException $e) { - $errors[] = array( - 'error' => $e->getMessage(), - 'hint' => $e->getHint() - ); - $htAccessWorking = false; - } - } - - - if (\OC_Util::runningOnMac()) { - $errors[] = array( - 'error' => $this->l10n->t( - 'Mac OS X is not supported and %s will not work properly on this platform. ' . - 'Use it at your own risk! ', - $this->defaults->getName() - ), - 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.') - ); - } - - if($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) { - $errors[] = array( - 'error' => $this->l10n->t( - 'It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' . - 'This will lead to problems with files over 4 GB and is highly discouraged.', - $this->defaults->getName() - ), - 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP.') - ); - } - if(!function_exists('curl_init') && PHP_INT_SIZE === 4) { - $errors[] = array( - 'error' => $this->l10n->t( - 'It seems that this %s instance is running on a 32-bit PHP environment and cURL is not installed. ' . - 'This will lead to problems with files over 4 GB and is highly discouraged.', - $this->defaults->getName() - ), - 'hint' => $this->l10n->t('Please install the cURL extension and restart your webserver.') - ); - } - - return array( - 'hasSQLite' => isset($databases['sqlite']), - 'hasMySQL' => isset($databases['mysql']), - 'hasPostgreSQL' => isset($databases['pgsql']), - 'hasOracle' => isset($databases['oci']), - 'hasMSSQL' => isset($databases['mssql']), - 'databases' => $databases, - 'directory' => $dataDir, - 'htaccessWorking' => $htAccessWorking, - 'errors' => $errors, - ); - } } |