summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-01-27 15:54:57 +0100
committerLukas Reschke <lukas@owncloud.com>2016-01-27 18:30:18 +0100
commitcb1a64b94935b76f877696cbb028271862228464 (patch)
treed4152cb688105fe8d5a62facf5105db5b64eb4ca /lib
parent816c23c17a71443d8774107d54ada8bda7486f32 (diff)
downloadnextcloud-server-cb1a64b94935b76f877696cbb028271862228464.tar.gz
nextcloud-server-cb1a64b94935b76f877696cbb028271862228464.zip
Check whether ownCloud is installed
ownCloud might not yet be setup. This causes an issue as the user config requires a setup ownCloud. Thus this needs a block whether ownCloud is installed or not. Fixes https://github.com/owncloud/core/issues/21955
Diffstat (limited to 'lib')
-rw-r--r--lib/private/l10n/factory.php32
-rw-r--r--lib/private/server.php3
2 files changed, 30 insertions, 5 deletions
diff --git a/lib/private/l10n/factory.php b/lib/private/l10n/factory.php
index 09496cba410..f4f7d897061 100644
--- a/lib/private/l10n/factory.php
+++ b/lib/private/l10n/factory.php
@@ -27,6 +27,7 @@ namespace OC\L10N;
use OCP\IConfig;
use OCP\IRequest;
+use OCP\IUserSession;
use OCP\L10N\IFactory;
/**
@@ -59,13 +60,20 @@ class Factory implements IFactory {
/** @var IRequest */
protected $request;
+ /** @var IUserSession */
+ protected $userSession;
+
/**
* @param IConfig $config
* @param IRequest $request
+ * @param IUserSession $userSession
*/
- public function __construct(IConfig $config, IRequest $request) {
+ public function __construct(IConfig $config,
+ IRequest $request,
+ IUserSession $userSession) {
$this->config = $config;
$this->request = $request;
+ $this->userSession = $userSession;
}
/**
@@ -107,9 +115,25 @@ class Factory implements IFactory {
return $this->requestLanguage;
}
- $userId = \OC_User::getUser(); // FIXME not available in non-static?
+ /**
+ * At this point ownCloud might not yet be installed and thus the lookup
+ * in the preferences table might fail. For this reason we need to check
+ * whether the instance has already been installed
+ *
+ * @link https://github.com/owncloud/core/issues/21955
+ */
+ if($this->config->getSystemValue('installed', false)) {
+ $userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() : null;
+ if(!is_null($userId)) {
+ $userLang = $this->config->getUserValue($userId, 'core', 'lang', null);
+ } else {
+ $userLang = null;
+ }
+ } else {
+ $userId = null;
+ $userLang = null;
+ }
- $userLang = $userId !== false ? $this->config->getUserValue($userId, 'core', 'lang') : null;
if ($userLang) {
$this->requestLanguage = $userLang;
if ($this->languageExists($app, $userLang)) {
@@ -124,7 +148,7 @@ class Factory implements IFactory {
}
$lang = $this->setLanguageFromRequest($app);
- if ($userId !== false && $app === null && !$userLang) {
+ if ($userId !== null && $app === null && !$userLang) {
$this->config->setUserValue($userId, 'core', 'lang', $lang);
}
diff --git a/lib/private/server.php b/lib/private/server.php
index 81929d0c7b3..4f731300baf 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -265,7 +265,8 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService('L10NFactory', function (Server $c) {
return new \OC\L10N\Factory(
$c->getConfig(),
- $c->getRequest()
+ $c->getRequest(),
+ $c->getUserSession()
);
});
$this->registerService('URLGenerator', function (Server $c) {